fix: use full update states instead of patch update (#5371)

This commit is contained in:
Lucas.Xu
2024-05-20 21:51:40 +08:00
committed by GitHub
parent e6d166df3b
commit d303d5affd
8 changed files with 60 additions and 51 deletions

View File

@ -76,6 +76,8 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
StreamSubscription? _transactionSubscription;
bool isClosing = false;
final _updateSelectionDebounce = Debounce();
final _syncThrottle = Throttler(duration: const Duration(milliseconds: 500));
@ -92,6 +94,10 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
@override
Future<void> close() async {
isClosing = true;
_updateSelectionDebounce.dispose();
_syncThrottle.dispose();
await _documentService.syncAwarenessStates(documentId: documentId);
await _documentListener.stop();
await _syncStateListener.stop();
await _viewListener?.stop();
@ -354,6 +360,9 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
}
Future<void> _onSelectionUpdate() async {
if (isClosing) {
return;
}
final user = state.userProfilePB;
final deviceId = ApplicationInfo.deviceId;
if (!FeatureFlag.syncDocument.isOn || user == null) {