-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ShishkinDaniil/feature/add-stream-sync-sta…
…te-info Add new class for getting info about sync
- Loading branch information
Showing
6 changed files
with
220 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
library in_sync_interface; | ||
|
||
export 'src/sync_repository.dart'; | ||
export 'src/sync_state_info.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/// Synchronization status information, including errors. | ||
class SyncStateInfo { | ||
final SyncState state; | ||
final SyncError? syncError; | ||
|
||
const SyncStateInfo( | ||
this.state, { | ||
this.syncError, | ||
}); | ||
|
||
/// Fatal error. | ||
bool get isFatalError => | ||
syncError == SyncError.authIncorrectCriticalVersion || | ||
syncError == SyncError.syncIncorrectData || | ||
syncError == SyncError.syncFieldNotFound || | ||
syncError == SyncError.syncEmptyFile; | ||
|
||
/// Temporary error. | ||
bool get isTemporaryError => | ||
syncError == SyncError.syncBlocked || | ||
syncError == SyncError.syncTemporarilyImpossible || | ||
syncError == SyncError.networkError || | ||
syncError == SyncError.syncInternalSyncError || | ||
syncError == SyncError.temporaryServerError; | ||
} | ||
|
||
/// Synchronization error name. | ||
enum SyncError { | ||
/// Unsupported client version. | ||
authIncorrectCriticalVersion, | ||
|
||
/// The transmitted data is incorrect. | ||
syncIncorrectData, | ||
|
||
/// Synchronization is blocked. | ||
/// | ||
/// Another client is synchronizing. | ||
syncBlocked, | ||
|
||
/// Error while saving data. | ||
/// | ||
/// Internal error when saving on the server. | ||
syncNotSaved, | ||
|
||
/// The entity could not be found. | ||
/// | ||
/// The creation event was not processed on the server | ||
/// this entity, so it can't update. | ||
syncEntityNotFound, | ||
|
||
/// Could not find the field. | ||
/// | ||
/// An entity field update was sent that the server does not know about. | ||
syncFieldNotFound, | ||
|
||
/// An empty file was transferred. | ||
/// | ||
/// An attempt was made to load a file of zero size. | ||
syncEmptyFile, | ||
|
||
/// Internal synchronization error on the server. | ||
syncInternalSyncError, | ||
|
||
/// Synchronization is temporarily unavailable. | ||
syncTemporarilyImpossible, | ||
|
||
/// Error updating entities. | ||
updateEntityError, | ||
|
||
/// Error downloading files. | ||
downloadFilesError, | ||
|
||
/// Network error. | ||
networkError, | ||
|
||
/// Authorisation error. | ||
authError, | ||
|
||
/// Temporary server error. | ||
temporaryServerError, | ||
|
||
/// Internal error. | ||
internalError, | ||
|
||
/// Error updating links. | ||
updateLinksExeption, | ||
|
||
/// Unknown error. | ||
unknown, | ||
} | ||
|
||
/// Sync status. | ||
enum SyncState { | ||
/// Initialization. | ||
initializing, | ||
|
||
/// Synchronization was completed successfully. | ||
ok, | ||
|
||
/// The last synchronization attempt failed with an error. | ||
failed, | ||
|
||
/// Synchronization is disabled. | ||
disabled, | ||
|
||
/// Synchronization in progress. | ||
pending, | ||
|
||
/// Waiting for first synchronization. | ||
waiting, | ||
} |
Oops, something went wrong.