Trigger sync only if the user has configured his account
This commit is contained in:
parent
1c42e32adf
commit
9584f2ede7
3 changed files with 12 additions and 2 deletions
|
@ -53,4 +53,8 @@ class Configuration {
|
|||
void setPassword(String password) async {
|
||||
await _preferences.setString(_passwordKey, password);
|
||||
}
|
||||
|
||||
bool hasConfiguredAccount() {
|
||||
return getEndpoint() != null && getToken() != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -98,10 +98,13 @@ class PhotoSyncManager {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _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();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue