@@ -22,11 +22,11 @@ class SyncStatus {
2222 /// Time that a last sync has fully completed, if any.
2323 ///
2424 /// This is null while loading the database.
25- final DateTime ? lastSyncedAt;
25+ DateTime ? get lastSyncedAt => statusInPriority.lastOrNull ? . lastSyncedAt;
2626
2727 /// Indicates whether there has been at least one full sync, if any.
2828 /// Is null when unknown, for example when state is still being loaded from the database.
29- final bool ? hasSynced;
29+ bool ? get hasSynced => statusInPriority.lastOrNull ? . hasSynced;
3030
3131 /// Error during uploading.
3232 ///
@@ -38,15 +38,19 @@ class SyncStatus {
3838 /// Cleared on the next successful data download.
3939 final Object ? downloadError;
4040
41- const SyncStatus (
42- {this .connected = false ,
43- this .connecting = false ,
44- this .lastSyncedAt,
45- this .hasSynced,
46- this .downloading = false ,
47- this .uploading = false ,
48- this .downloadError,
49- this .uploadError});
41+ final List <SyncPriorityStatus > statusInPriority;
42+
43+ const SyncStatus ({
44+ this .connected = false ,
45+ this .connecting = false ,
46+ this .lastSyncedAt,
47+ this .hasSynced,
48+ this .downloading = false ,
49+ this .uploading = false ,
50+ this .downloadError,
51+ this .uploadError,
52+ this .statusInPriority = const [],
53+ });
5054
5155 @override
5256 bool operator == (Object other) {
@@ -100,6 +104,29 @@ class SyncStatus {
100104 }
101105}
102106
107+ /// The priority of a PowerSync bucket.
108+ extension type const BucketPriority ._(int priorityNumber) {
109+ static const _highest = 0 ;
110+ static const _lowests = 3 ;
111+
112+ factory BucketPriority (int i) {
113+ assert (i >= _highest && i <= _lowests);
114+ return BucketPriority ._(i);
115+ }
116+
117+ /// A [Comparator] instance suitable for comparing [BucketPriority] values.
118+ static Comparator <BucketPriority > comparator =
119+ (a, b) => - a.priorityNumber.compareTo (b.priorityNumber);
120+ }
121+
122+ /// Partial information about the synchronization status for buckets within a
123+ /// priority.
124+ typedef SyncPriorityStatus = ({
125+ BucketPriority priority,
126+ DateTime lastSyncedAt,
127+ bool hasSynced,
128+ });
129+
103130/// Stats of the local upload queue.
104131class UploadQueueStats {
105132 /// Number of records in the upload queue.
0 commit comments