Create Account sync state interface to allow for multiple sync services

Needed to add the package sync

CURA-7290
This commit is contained in:
Nino van Hooff 2020-05-04 13:52:40 +02:00
parent 81d02d5d58
commit 049c1946d4
2 changed files with 38 additions and 13 deletions

View file

@ -27,6 +27,7 @@ class CloudOutputDeviceManager:
META_CLUSTER_ID = "um_cloud_cluster_id"
META_NETWORK_KEY = "um_network_key"
SYNC_SERVICE_NAME = "CloudOutputDeviceManager"
# The interval with which the remote clusters are checked
CHECK_CLUSTER_INTERVAL = 30.0 # seconds
@ -103,7 +104,7 @@ class CloudOutputDeviceManager:
self._update_timer.stop()
self._syncing = True
self._account.isSyncingChanged.emit("syncing")
self._account.setSyncState(self.SYNC_SERVICE_NAME, "syncing")
self._api.getClusters(self._onGetRemoteClustersFinished, self._onGetRemoteClusterFailed)
def _onGetRemoteClustersFinished(self, clusters: List[CloudClusterResponse]) -> None:
@ -133,13 +134,13 @@ class CloudOutputDeviceManager:
self._connectToActiveMachine()
self._syncing = False
self._account.isSyncingChanged.emit("success")
self._account.setSyncState(self.SYNC_SERVICE_NAME, "success")
# Schedule a new update
self._update_timer.start()
def _onGetRemoteClusterFailed(self):
self._syncing = False
self._account.isSyncingChanged.emit("error")
self._account.setSyncState(self.SYNC_SERVICE_NAME, "error")
# Schedule a new update
self._update_timer.start()