diff --git a/lib/core/configuration.dart b/lib/core/configuration.dart index 8d112ccf7..70366d5f9 100644 --- a/lib/core/configuration.dart +++ b/lib/core/configuration.dart @@ -53,4 +53,8 @@ class Configuration { void setPassword(String password) async { await _preferences.setString(_passwordKey, password); } + + bool hasConfiguredAccount() { + return getEndpoint() != null && getToken() != null; + } } diff --git a/lib/folder_service.dart b/lib/folder_service.dart index 70d953489..599940a60 100644 --- a/lib/folder_service.dart +++ b/lib/folder_service.dart @@ -26,6 +26,9 @@ class FolderSharingService { FolderSharingService._privateConstructor(); void sync() { + if (!Configuration.instance.hasConfiguredAccount()) { + return; + } getFolders().then((f) async { var folders = f.toSet(); var currentFolders = await FolderDB.instance.getFolders(); diff --git a/lib/photo_sync_manager.dart b/lib/photo_sync_manager.dart index df5de28e8..afd4c1735 100644 --- a/lib/photo_sync_manager.dart +++ b/lib/photo_sync_manager.dart @@ -98,10 +98,13 @@ class PhotoSyncManager { } } - Future _syncWithRemote(SharedPreferences prefs) { + _syncWithRemote(SharedPreferences prefs) { // TODO: Fix race conditions triggered due to concurrent syncs. // Add device_id/last_sync_timestamp to the upload request? - return _downloadDiff(prefs).then((_) { + if (!Configuration.instance.hasConfiguredAccount()) { + return; + } + _downloadDiff(prefs).then((_) { _uploadDiff(prefs).then((_) { _deletePhotosOnServer(); });