From 52f266ecbd34ce298a4bce93992ffbb631ae90f8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 9 Sep 2017 15:36:50 +0200 Subject: Centralized synchronization calls --- components/kube/contents/ui/Kube.qml | 65 ++++++++++++++++++++------------- framework/qml/FolderListView.qml | 1 - framework/qml/InlineAccountSwitcher.qml | 5 +-- framework/qml/Messages.qml | 1 + 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index e8b8a0c8..224b317e 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml @@ -34,6 +34,46 @@ Controls2.ApplicationWindow { //Application default font font.family: Kube.Font.fontFamily + //Application context + property variant currentFolder + onCurrentFolderChanged: { + if (!!currentFolder) { + Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": currentFolder}) + } + } + property variant currentAccount + onCurrentAccountChanged: { + if (!!currentAccount) { + console.warn("Synching account", currentAccount) + Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount}); + } + } + + //Interval sync + Timer { + id: intervalSync + //5min + interval: 300000 + running: !!app.currentFolder + repeat: true + onTriggered: Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": app.currentFolder}) + } + + Kube.StartupCheck { + onNoAccount: kubeViews.setAccountsView() + } + + //Listener + Kube.Listener { + filter: Kube.Messages.accountSelection + onMessageReceived: app.currentAccount = message.account + } + + Kube.Listener { + filter: Kube.Messages.folderSelection + onMessageReceived: app.currentFolder = message.folder + } + Kube.Listener { filter: Kube.Messages.notification onMessageReceived: { @@ -79,31 +119,6 @@ Controls2.ApplicationWindow { } //END Shortcuts - //Interval sync - Timer { - id: intervalSync - property variant folder: null - //5min - interval: 300000 - running: !!folder - repeat: true - onTriggered: Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": folder}) - } - - Kube.Listener { - filter: Kube.Messages.folderSelection - onMessageReceived: { - syncShortcut.folder = message.folder - intervalSync.folder = message.folder - } - } - - Kube.StartupCheck { - onNoAccount: { - kubeViews.setAccountsView() - } - } - //BEGIN background Rectangle { anchors.fill: parent diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml index ece6f280..25c6cbe5 100644 --- a/framework/qml/FolderListView.qml +++ b/framework/qml/FolderListView.qml @@ -42,7 +42,6 @@ Kube.TreeView { model.fetchMore(index); Kube.Fabric.postMessage(Kube.Messages.folderSelection, {"folder": model.data(index, Kube.FolderListModel.DomainObject), "trash": model.data(index, Kube.FolderListModel.Trash)}); - Kube.Fabric.postMessage(Kube.Messages.synchronize, {"folder": model.data(index, Kube.FolderListModel.DomainObject)}); } diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml index 511c38db..354150a5 100644 --- a/framework/qml/InlineAccountSwitcher.qml +++ b/framework/qml/InlineAccountSwitcher.qml @@ -24,10 +24,7 @@ FocusScope { id: root property string currentAccount onCurrentAccountChanged: { - if (!!currentAccount) { - Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": currentAccount}); - } - + Kube.Fabric.postMessage(Kube.Messages.accountSelection, {"account": currentAccount}); } ColumnLayout { diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml index 485f7816..1d2ca002 100644 --- a/framework/qml/Messages.qml +++ b/framework/qml/Messages.qml @@ -24,6 +24,7 @@ Item { //Selections property string folderSelection: "currentFolder" property string mailSelection: "currentMail" + property string accountSelection: "currentAccount" //Actions property string moveToTrash: "moveToTrash" -- cgit v1.2.3