From: Lionel Duboeuf Date: Tue, 7 Jan 2025 10:40:00 +0100 Subject: [PATCH 10/14] Auto sync on first account creation Signed-off-by: Mike Gabriel --- src/qml/CalendarChoicePopup.qml | 17 +++++++++++++++++ src/qml/OnlineAccountsHelper.qml | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/qml/CalendarChoicePopup.qml b/src/qml/CalendarChoicePopup.qml index 90e1ad7..34aa202 100644 --- a/src/qml/CalendarChoicePopup.qml +++ b/src/qml/CalendarChoicePopup.qml @@ -89,6 +89,18 @@ Page { flickable: flickable } + Timer { + id: contactFirstSyncTimer + + interval: 500 + repeat: false + onTriggered: { + if (calendarChoicePage.canSynchronize) { + buteoSync.synchronize() + } + } + } + ListModel { id: calendarModel } @@ -466,6 +478,11 @@ Page { anchors.fill: parent asynchronous: true source: sourceFile + + Connections { + target: onlineAccountHelper.item ? onlineAccountHelper.item : null + onFinished: contactFirstSyncTimer.restart() + } } Component { diff --git a/src/qml/OnlineAccountsHelper.qml b/src/qml/OnlineAccountsHelper.qml index b651028..772d695 100644 --- a/src/qml/OnlineAccountsHelper.qml +++ b/src/qml/OnlineAccountsHelper.qml @@ -24,6 +24,8 @@ Item { id: root property var dialogInstance: null + signal finished() + signal canceled() function run(){ if (!root.dialogInstance) { @@ -86,6 +88,15 @@ Item { providerId: "google" onFinished: { PopupUtils.close(root.dialogInstance) + if (reply != null && reply.errorName !== undefined) { + if (reply.errorName === "com.lomiri.OnlineAccountsUi.UserCanceled") { + root.canceled() + } else { + root.finished() + } + } else { + root.finished() + } } } }