🐛 Fix the is syncing state of chat shows wrongly
This commit is contained in:
@@ -332,9 +332,12 @@ class MessagesNotifier extends _$MessagesNotifier {
|
|||||||
_allRemoteMessagesFetched = false;
|
_allRemoteMessagesFetched = false;
|
||||||
|
|
||||||
talker.log('Starting message sync');
|
talker.log('Starting message sync');
|
||||||
if (!_disposed) {
|
// Use Future.microtask to set syncing state, but check disposal to avoid errors
|
||||||
Future.microtask(() => ref.read(chatSyncingProvider.notifier).set(true));
|
Future.microtask(() {
|
||||||
}
|
if (!_disposed) {
|
||||||
|
ref.read(chatSyncingProvider.notifier).set(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
final dbMessages = await _database.getMessagesForRoom(
|
final dbMessages = await _database.getMessagesForRoom(
|
||||||
_room.id,
|
_room.id,
|
||||||
@@ -411,11 +414,8 @@ class MessagesNotifier extends _$MessagesNotifier {
|
|||||||
showErrorAlert(err);
|
showErrorAlert(err);
|
||||||
} finally {
|
} finally {
|
||||||
talker.log('Finished message sync');
|
talker.log('Finished message sync');
|
||||||
if (!_disposed) {
|
// Always reset global syncing state, regardless of disposal
|
||||||
Future.microtask(
|
Future.microtask(() => ref.read(chatSyncingProvider.notifier).set(false));
|
||||||
() => ref.read(chatSyncingProvider.notifier).set(false),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_isSyncing = false;
|
_isSyncing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,11 +537,8 @@ class MessagesNotifier extends _$MessagesNotifier {
|
|||||||
);
|
);
|
||||||
showErrorAlert(err);
|
showErrorAlert(err);
|
||||||
} finally {
|
} finally {
|
||||||
if (!_disposed) {
|
// Always reset global syncing state, regardless of disposal
|
||||||
Future.microtask(
|
Future.microtask(() => ref.read(chatSyncingProvider.notifier).set(false));
|
||||||
() => ref.read(chatSyncingProvider.notifier).set(false),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user