Merge pull request #199 from jgibbon/bugfix/functions-appnotification

fix functions scope; make appNotification global
This commit is contained in:
Sebastian Wolf 2020-11-23 21:11:05 +01:00 committed by GitHub
commit 4712d3dc0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 24 deletions

View file

@ -192,9 +192,6 @@ SilicaFlickable {
id: membersList id: membersList
} }
AppNotification {
id: infoNotification
}
PullDownMenu { PullDownMenu {
MenuItem { MenuItem {
visible: (chatInformationPage.isSuperGroup || chatInformationPage.isBasicGroup) && chatInformationPage.groupInformation && chatInformationPage.groupInformation.status["@type"] !== "chatMemberStatusBanned" visible: (chatInformationPage.isSuperGroup || chatInformationPage.isBasicGroup) && chatInformationPage.groupInformation && chatInformationPage.groupInformation.status["@type"] !== "chatMemberStatusBanned"
@ -420,7 +417,7 @@ SilicaFlickable {
anchors.verticalCenter: inviteLinkItem.verticalCenter anchors.verticalCenter: inviteLinkItem.verticalCenter
onClicked: { onClicked: {
Clipboard.text = chatInformationPage.groupFullInformation.invite_link Clipboard.text = chatInformationPage.groupFullInformation.invite_link
infoNotification.show(qsTr("The Invite Link has been copied to the clipboard.")); appNotification.show(qsTr("The Invite Link has been copied to the clipboard."));
} }
} }
} }

View file

@ -19,6 +19,8 @@
import QtQuick 2.6 import QtQuick 2.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import "pages" import "pages"
import "components"
import "./js/functions.js" as Functions
ApplicationWindow ApplicationWindow
{ {
@ -37,4 +39,16 @@ ApplicationWindow
appWindow.activate(); appWindow.activate();
} }
} }
AppNotification {
id: appNotification
parent: pageStack.currentPage
}
Component.onCompleted: {
Functions.setGlobals({
tdLibWrapper: tdLibWrapper,
appNotification: appNotification
});
}
} }

View file

@ -21,6 +21,13 @@
.import "debug.js" as Debug .import "debug.js" as Debug
.import Sailfish.Silica 1.0 as Silica .import Sailfish.Silica 1.0 as Silica
var tdLibWrapper;
var appNotification;
function setGlobals(globals) {
tdLibWrapper = globals.tdLibWrapper;
appNotification = globals.appNotification;
}
function getUserName(userInformation) { function getUserName(userInformation) {
var firstName = typeof userInformation.first_name !== "undefined" ? userInformation.first_name : ""; var firstName = typeof userInformation.first_name !== "undefined" ? userInformation.first_name : "";
var lastName = typeof userInformation.last_name !== "undefined" ? userInformation.last_name : ""; var lastName = typeof userInformation.last_name !== "undefined" ? userInformation.last_name : "";

View file

@ -579,10 +579,6 @@ Page {
} }
} }
AppNotification {
id: appNotification
}
BackgroundItem { BackgroundItem {
id: headerMouseArea id: headerMouseArea
height: headerRow.height height: headerRow.height

View file

@ -82,11 +82,11 @@ Page {
} }
} }
onCopyToDownloadsSuccessful: { onCopyToDownloadsSuccessful: {
imageNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath); appNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath);
} }
onCopyToDownloadsError: { onCopyToDownloadsError: {
imageNotification.show(qsTr("Download failed.")); appNotification.show(qsTr("Download failed."));
} }
} }
@ -105,10 +105,6 @@ Page {
} }
} }
AppNotification {
id: imageNotification
}
SilicaFlickable { SilicaFlickable {
id: imageFlickable id: imageFlickable
anchors.fill: parent anchors.fill: parent

View file

@ -187,10 +187,6 @@ Page {
} }
} }
AppNotification {
id: appNotification
}
Column { Column {
id: column id: column
width: parent.width width: parent.width

View file

@ -74,18 +74,14 @@ Page {
} }
} }
onCopyToDownloadsSuccessful: { onCopyToDownloadsSuccessful: {
videoNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath); appNotification.show(qsTr("Download of %1 successful.").arg(fileName), filePath);
} }
onCopyToDownloadsError: { onCopyToDownloadsError: {
videoNotification.show(qsTr("Download failed.")); appNotification.show(qsTr("Download failed."));
} }
} }
AppNotification {
id: videoNotification
}
Item { Item {
width: videoPage.videoWidth * videoPage.sizingFactor width: videoPage.videoWidth * videoPage.sizingFactor
height: videoPage.videoHeight * videoPage.sizingFactor height: videoPage.videoHeight * videoPage.sizingFactor