2023-08-17 14:50:48 +08:00
|
|
|
import 'dart:async';
|
2024-03-28 17:46:31 +08:00
|
|
|
import 'dart:convert';
|
2023-08-17 14:50:48 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
import 'package:appflowy/plugins/document/application/doc_awareness_metadata.dart';
|
|
|
|
import 'package:appflowy/plugins/document/application/doc_collab_adapter.dart';
|
|
|
|
import 'package:appflowy/plugins/document/application/doc_listener.dart';
|
2023-08-17 14:50:48 +08:00
|
|
|
import 'package:appflowy/plugins/document/application/doc_service.dart';
|
2024-03-28 17:46:31 +08:00
|
|
|
import 'package:appflowy/plugins/document/application/doc_sync_state_listener.dart';
|
2023-05-16 14:58:24 +08:00
|
|
|
import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';
|
|
|
|
import 'package:appflowy/plugins/document/application/editor_transaction_adapter.dart';
|
2023-02-26 16:27:17 +08:00
|
|
|
import 'package:appflowy/plugins/trash/application/trash_service.dart';
|
2024-03-21 12:26:48 +07:00
|
|
|
import 'package:appflowy/shared/feature_flags.dart';
|
2024-01-20 23:16:18 +08:00
|
|
|
import 'package:appflowy/startup/startup.dart';
|
2024-03-28 17:46:31 +08:00
|
|
|
import 'package:appflowy/startup/tasks/device_info_task.dart';
|
2024-01-20 23:16:18 +08:00
|
|
|
import 'package:appflowy/user/application/auth/auth_service.dart';
|
2024-03-28 17:46:31 +08:00
|
|
|
import 'package:appflowy/util/color_generator/color_generator.dart';
|
|
|
|
import 'package:appflowy/util/color_to_hex_string.dart';
|
|
|
|
import 'package:appflowy/util/debounce.dart';
|
2023-08-17 14:50:48 +08:00
|
|
|
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
2024-03-21 12:26:48 +07:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-document/entities.pb.dart';
|
2023-12-31 07:29:40 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart';
|
2023-01-08 12:10:53 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
2023-12-31 07:29:40 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
2024-02-25 17:50:35 +07:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
|
2023-08-17 14:50:48 +08:00
|
|
|
import 'package:appflowy_editor/appflowy_editor.dart'
|
|
|
|
show
|
|
|
|
EditorState,
|
|
|
|
LogLevel,
|
|
|
|
TransactionTime,
|
|
|
|
Selection,
|
|
|
|
Position,
|
|
|
|
paragraphNode;
|
2024-02-24 20:54:10 +07:00
|
|
|
import 'package:appflowy_result/appflowy_result.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
2021-09-11 21:30:58 +08:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2021-07-24 18:55:13 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2023-08-17 14:50:48 +08:00
|
|
|
|
2021-07-24 18:55:13 +08:00
|
|
|
part 'doc_bloc.freezed.dart';
|
|
|
|
|
2022-02-23 22:17:47 +08:00
|
|
|
class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
|
|
|
|
DocumentBloc({
|
2021-10-31 19:48:20 +08:00
|
|
|
required this.view,
|
2023-05-16 14:58:24 +08:00
|
|
|
}) : _documentListener = DocumentListener(id: view.id),
|
2023-12-21 08:12:40 +08:00
|
|
|
_syncStateListener = DocumentSyncStateListener(id: view.id),
|
2023-06-14 22:16:33 +08:00
|
|
|
_viewListener = ViewListener(viewId: view.id),
|
2022-10-26 10:38:57 +08:00
|
|
|
super(DocumentState.initial()) {
|
2023-05-16 14:58:24 +08:00
|
|
|
on<DocumentEvent>(_onDocumentEvent);
|
2021-07-24 18:55:13 +08:00
|
|
|
}
|
2021-09-11 21:30:58 +08:00
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
final ViewPB view;
|
2021-11-03 22:04:45 +08:00
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
final DocumentListener _documentListener;
|
2023-12-21 08:12:40 +08:00
|
|
|
final DocumentSyncStateListener _syncStateListener;
|
2023-05-16 14:58:24 +08:00
|
|
|
final ViewListener _viewListener;
|
2021-11-03 23:03:42 +08:00
|
|
|
|
2023-11-09 00:30:50 +01:00
|
|
|
final DocumentService _documentService = DocumentService();
|
|
|
|
final TrashService _trashService = TrashService();
|
2023-05-16 14:58:24 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
late DocumentCollabAdapter _documentCollabAdapter;
|
2024-03-21 12:26:48 +07:00
|
|
|
|
2023-11-09 00:30:50 +01:00
|
|
|
late final TransactionAdapter _transactionAdapter = TransactionAdapter(
|
|
|
|
documentId: view.id,
|
|
|
|
documentService: _documentService,
|
|
|
|
);
|
2023-05-16 14:58:24 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
StreamSubscription? _transactionSubscription;
|
|
|
|
|
|
|
|
final _updateSelectionDebounce = Debounce();
|
|
|
|
final _syncDocDebounce = Debounce();
|
2023-05-16 14:58:24 +08:00
|
|
|
|
2024-02-25 17:50:35 +07:00
|
|
|
bool get isLocalMode {
|
|
|
|
final userProfilePB = state.userProfilePB;
|
|
|
|
final type = userProfilePB?.authenticator ?? AuthenticatorPB.Local;
|
|
|
|
return type == AuthenticatorPB.Local;
|
|
|
|
}
|
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
@override
|
|
|
|
Future<void> close() async {
|
2023-12-10 20:26:23 +07:00
|
|
|
await _documentListener.stop();
|
2023-12-21 08:12:40 +08:00
|
|
|
await _syncStateListener.stop();
|
2023-05-16 14:58:24 +08:00
|
|
|
await _viewListener.stop();
|
2024-03-28 17:46:31 +08:00
|
|
|
await _transactionSubscription?.cancel();
|
2023-05-16 14:58:24 +08:00
|
|
|
await _documentService.closeDocument(view: view);
|
2023-12-28 12:37:10 +08:00
|
|
|
state.editorState?.service.keyboardService?.closeKeyboard();
|
2023-12-10 20:26:23 +07:00
|
|
|
state.editorState?.dispose();
|
2021-10-19 13:56:11 +08:00
|
|
|
return super.close();
|
|
|
|
}
|
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
Future<void> _onDocumentEvent(
|
|
|
|
DocumentEvent event,
|
|
|
|
Emitter<DocumentState> emit,
|
|
|
|
) async {
|
2023-12-21 08:12:40 +08:00
|
|
|
await event.when(
|
|
|
|
initial: () async {
|
2024-03-21 12:26:48 +07:00
|
|
|
final result = await _fetchDocumentState();
|
2023-12-10 20:26:23 +07:00
|
|
|
_onViewChanged();
|
|
|
|
_onDocumentChanged();
|
2024-03-21 12:26:48 +07:00
|
|
|
final newState = await result.fold(
|
2024-02-24 20:54:10 +07:00
|
|
|
(s) async {
|
2024-03-21 11:02:03 +07:00
|
|
|
final userProfilePB =
|
|
|
|
await getIt<AuthService>().getUser().toNullable();
|
|
|
|
return state.copyWith(
|
|
|
|
error: null,
|
|
|
|
editorState: s,
|
|
|
|
isLoading: false,
|
|
|
|
userProfilePB: userProfilePB,
|
2024-01-20 23:16:18 +08:00
|
|
|
);
|
|
|
|
},
|
2024-03-21 11:02:03 +07:00
|
|
|
(f) async => state.copyWith(
|
|
|
|
error: f,
|
|
|
|
editorState: null,
|
|
|
|
isLoading: false,
|
2024-02-24 20:54:10 +07:00
|
|
|
),
|
2023-12-10 20:26:23 +07:00
|
|
|
);
|
2024-03-21 11:02:03 +07:00
|
|
|
emit(newState);
|
2024-03-28 17:46:31 +08:00
|
|
|
if (newState.userProfilePB != null) {
|
|
|
|
await _updateCollaborator();
|
|
|
|
}
|
2022-10-22 21:57:44 +08:00
|
|
|
},
|
2023-12-21 08:12:40 +08:00
|
|
|
moveToTrash: () async {
|
2023-05-16 14:58:24 +08:00
|
|
|
emit(state.copyWith(isDeleted: true));
|
|
|
|
},
|
2023-12-21 08:12:40 +08:00
|
|
|
restore: () async {
|
2023-05-16 14:58:24 +08:00
|
|
|
emit(state.copyWith(isDeleted: false));
|
|
|
|
},
|
2023-12-21 08:12:40 +08:00
|
|
|
deletePermanently: () async {
|
2023-05-16 14:58:24 +08:00
|
|
|
final result = await _trashService.deleteViews([view.id]);
|
2023-06-05 13:10:14 +08:00
|
|
|
final forceClose = result.fold((l) => true, (r) => false);
|
|
|
|
emit(state.copyWith(forceClose: forceClose));
|
2023-05-16 14:58:24 +08:00
|
|
|
},
|
2023-12-21 08:12:40 +08:00
|
|
|
restorePage: () async {
|
2023-05-16 14:58:24 +08:00
|
|
|
final result = await _trashService.putback(view.id);
|
2023-06-05 13:10:14 +08:00
|
|
|
final isDeleted = result.fold((l) => false, (r) => true);
|
|
|
|
emit(state.copyWith(isDeleted: isDeleted));
|
2022-10-22 21:57:44 +08:00
|
|
|
},
|
2024-03-21 12:26:48 +07:00
|
|
|
syncStateChanged: (syncState) {
|
|
|
|
emit(state.copyWith(syncState: syncState.value));
|
2023-12-21 08:12:40 +08:00
|
|
|
},
|
2022-10-22 21:57:44 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
/// subscribe to the view(document page) change
|
|
|
|
void _onViewChanged() {
|
|
|
|
_viewListener.start(
|
2023-06-05 13:10:14 +08:00
|
|
|
onViewMoveToTrash: (r) {
|
2024-02-24 20:54:10 +07:00
|
|
|
r.map((r) => add(const DocumentEvent.moveToTrash()));
|
2023-06-05 13:10:14 +08:00
|
|
|
},
|
|
|
|
onViewDeleted: (r) {
|
2024-02-24 20:54:10 +07:00
|
|
|
r.map((r) => add(const DocumentEvent.moveToTrash()));
|
2023-06-05 13:10:14 +08:00
|
|
|
},
|
2024-02-24 20:54:10 +07:00
|
|
|
onViewRestored: (r) => r.map((r) => add(const DocumentEvent.restore())),
|
2023-05-16 14:58:24 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// subscribe to the document content change
|
|
|
|
void _onDocumentChanged() {
|
|
|
|
_documentListener.start(
|
2024-03-28 17:46:31 +08:00
|
|
|
onDocEventUpdate: _debounceSyncDoc,
|
|
|
|
onDocAwarenessUpdate: _onAwarenessStatesUpdate,
|
2022-05-05 21:15:01 +08:00
|
|
|
);
|
2023-12-21 08:12:40 +08:00
|
|
|
|
|
|
|
_syncStateListener.start(
|
|
|
|
didReceiveSyncState: (syncState) {
|
|
|
|
if (!isClosed) {
|
2024-03-21 12:26:48 +07:00
|
|
|
add(DocumentEvent.syncStateChanged(syncState));
|
2023-12-21 08:12:40 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2021-10-20 22:19:01 +08:00
|
|
|
}
|
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
/// Fetch document
|
2024-02-24 20:54:10 +07:00
|
|
|
Future<FlowyResult<EditorState?, FlowyError>> _fetchDocumentState() async {
|
2023-12-05 10:04:23 -08:00
|
|
|
final result = await _documentService.openDocument(viewId: view.id);
|
2023-12-10 20:26:23 +07:00
|
|
|
return result.fold(
|
2024-02-24 20:54:10 +07:00
|
|
|
(s) async => FlowyResult.success(await _initAppFlowyEditorState(s)),
|
|
|
|
(e) => FlowyResult.failure(e),
|
2023-04-13 18:53:51 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-10 20:26:23 +07:00
|
|
|
Future<EditorState?> _initAppFlowyEditorState(DocumentDataPB data) async {
|
2023-05-16 14:58:24 +08:00
|
|
|
final document = data.toDocument();
|
|
|
|
if (document == null) {
|
|
|
|
assert(false, 'document is null');
|
2023-12-10 20:26:23 +07:00
|
|
|
return null;
|
2023-05-16 14:58:24 +08:00
|
|
|
}
|
|
|
|
|
2023-05-23 19:55:43 +08:00
|
|
|
final editorState = EditorState(document: document);
|
2023-03-07 09:33:59 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
_documentCollabAdapter = DocumentCollabAdapter(editorState, view.id);
|
2024-03-21 12:26:48 +07:00
|
|
|
|
2023-05-16 14:58:24 +08:00
|
|
|
// subscribe to the document change from the editor
|
2024-03-28 17:46:31 +08:00
|
|
|
_transactionSubscription = editorState.transactionStream.listen(
|
|
|
|
(event) async {
|
|
|
|
final time = event.$1;
|
|
|
|
final transaction = event.$2;
|
|
|
|
if (time != TransactionTime.before) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// apply transaction to backend
|
|
|
|
await _transactionAdapter.apply(transaction, editorState);
|
|
|
|
|
|
|
|
// check if the document is empty.
|
|
|
|
await _applyRules();
|
|
|
|
|
|
|
|
if (!isClosed) {
|
|
|
|
// ignore: invalid_use_of_visible_for_testing_member
|
|
|
|
emit(state.copyWith(isDocumentEmpty: editorState.document.isEmpty));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
editorState.selectionNotifier.addListener(_debounceOnSelectionUpdate);
|
2023-05-16 14:58:24 +08:00
|
|
|
|
|
|
|
// output the log from the editor when debug mode
|
2023-03-07 09:33:59 +08:00
|
|
|
if (kDebugMode) {
|
2023-05-16 14:58:24 +08:00
|
|
|
editorState.logConfiguration
|
|
|
|
..level = LogLevel.all
|
|
|
|
..handler = (log) {
|
2023-05-23 23:55:21 +08:00
|
|
|
// Log.debug(log);
|
2023-05-16 14:58:24 +08:00
|
|
|
};
|
2023-03-07 09:33:59 +08:00
|
|
|
}
|
2023-12-10 20:26:23 +07:00
|
|
|
|
|
|
|
return editorState;
|
2021-10-20 22:19:01 +08:00
|
|
|
}
|
2023-07-02 11:46:45 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
Future<void> _applyRules() async {
|
2024-01-29 10:26:45 +08:00
|
|
|
await Future.wait([
|
2024-03-28 17:46:31 +08:00
|
|
|
_ensureAtLeastOneParagraphExists(),
|
|
|
|
_ensureLastNodeIsEditable(),
|
2024-01-29 10:26:45 +08:00
|
|
|
]);
|
2023-07-02 11:46:45 +08:00
|
|
|
}
|
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
Future<void> _ensureLastNodeIsEditable() async {
|
2023-12-10 20:26:23 +07:00
|
|
|
final editorState = state.editorState;
|
2023-07-02 11:46:45 +08:00
|
|
|
if (editorState == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final document = editorState.document;
|
|
|
|
final lastNode = document.root.children.lastOrNull;
|
|
|
|
if (lastNode == null || lastNode.delta == null) {
|
|
|
|
final transaction = editorState.transaction;
|
|
|
|
transaction.insertNode([document.root.children.length], paragraphNode());
|
2023-09-01 10:15:21 +03:30
|
|
|
transaction.afterSelection = transaction.beforeSelection;
|
2023-07-02 11:46:45 +08:00
|
|
|
await editorState.apply(transaction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
Future<void> _ensureAtLeastOneParagraphExists() async {
|
2023-12-10 20:26:23 +07:00
|
|
|
final editorState = state.editorState;
|
2023-07-02 11:46:45 +08:00
|
|
|
if (editorState == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final document = editorState.document;
|
|
|
|
if (document.root.children.isEmpty) {
|
|
|
|
final transaction = editorState.transaction;
|
|
|
|
transaction.insertNode([0], paragraphNode());
|
2023-08-17 14:50:48 +08:00
|
|
|
transaction.afterSelection = Selection.collapsed(
|
2024-01-25 16:37:36 +01:00
|
|
|
Position(path: [0]),
|
2023-08-17 14:50:48 +08:00
|
|
|
);
|
2023-07-02 11:46:45 +08:00
|
|
|
await editorState.apply(transaction);
|
|
|
|
}
|
|
|
|
}
|
2023-09-12 20:49:03 +08:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
Future<void> _onDocumentStateUpdate(DocEventPB docEvent) async {
|
2024-03-21 12:26:48 +07:00
|
|
|
if (!docEvent.isRemote || !FeatureFlag.syncDocument.isOn) {
|
|
|
|
return;
|
2024-03-21 11:02:03 +07:00
|
|
|
}
|
2024-03-21 12:26:48 +07:00
|
|
|
|
2024-03-28 17:46:31 +08:00
|
|
|
unawaited(_documentCollabAdapter.syncV3(docEvent));
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onAwarenessStatesUpdate(
|
|
|
|
DocumentAwarenessStatesPB awarenessStates,
|
|
|
|
) async {
|
|
|
|
if (!FeatureFlag.syncDocument.isOn) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final userId = state.userProfilePB?.id;
|
|
|
|
if (userId != null) {
|
|
|
|
await _documentCollabAdapter.updateRemoteSelection(
|
|
|
|
userId.toString(),
|
|
|
|
awarenessStates,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _debounceOnSelectionUpdate() {
|
|
|
|
_updateSelectionDebounce.call(_onSelectionUpdate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _debounceSyncDoc(DocEventPB docEvent) {
|
|
|
|
_syncDocDebounce.call(() {
|
|
|
|
_onDocumentStateUpdate(docEvent);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onSelectionUpdate() async {
|
|
|
|
final user = state.userProfilePB;
|
|
|
|
final deviceId = ApplicationInfo.deviceId;
|
|
|
|
if (!FeatureFlag.syncDocument.isOn || user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final editorState = state.editorState;
|
|
|
|
if (editorState == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final selection = editorState.selection;
|
|
|
|
|
|
|
|
// sync the selection
|
|
|
|
final id = user.id.toString() + deviceId;
|
|
|
|
final basicColor = ColorGenerator(id.toString()).toColor();
|
|
|
|
final metadata = DocumentAwarenessMetadata(
|
|
|
|
cursorColor: basicColor.toHexString(),
|
|
|
|
selectionColor: basicColor.withOpacity(0.6).toHexString(),
|
|
|
|
userName: user.name,
|
|
|
|
userAvatar: user.iconUrl,
|
|
|
|
);
|
|
|
|
await _documentService.syncAwarenessStates(
|
|
|
|
documentId: view.id,
|
|
|
|
selection: selection,
|
|
|
|
metadata: jsonEncode(metadata.toJson()),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _updateCollaborator() async {
|
|
|
|
final user = state.userProfilePB;
|
|
|
|
final deviceId = ApplicationInfo.deviceId;
|
|
|
|
if (!FeatureFlag.syncDocument.isOn || user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sync the selection
|
|
|
|
final id = user.id.toString() + deviceId;
|
|
|
|
final basicColor = ColorGenerator(id.toString()).toColor();
|
|
|
|
final metadata = DocumentAwarenessMetadata(
|
|
|
|
cursorColor: basicColor.toHexString(),
|
|
|
|
selectionColor: basicColor.withOpacity(0.6).toHexString(),
|
|
|
|
userName: user.name,
|
|
|
|
userAvatar: user.iconUrl,
|
|
|
|
);
|
|
|
|
await _documentService.syncAwarenessStates(
|
|
|
|
documentId: view.id,
|
|
|
|
metadata: jsonEncode(metadata.toJson()),
|
|
|
|
);
|
2023-09-12 20:49:03 +08:00
|
|
|
}
|
2021-07-24 18:55:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
2022-02-23 22:17:47 +08:00
|
|
|
class DocumentEvent with _$DocumentEvent {
|
|
|
|
const factory DocumentEvent.initial() = Initial;
|
2023-06-05 13:10:14 +08:00
|
|
|
const factory DocumentEvent.moveToTrash() = MoveToTrash;
|
2022-02-23 22:17:47 +08:00
|
|
|
const factory DocumentEvent.restore() = Restore;
|
|
|
|
const factory DocumentEvent.restorePage() = RestorePage;
|
|
|
|
const factory DocumentEvent.deletePermanently() = DeletePermanently;
|
2024-03-21 12:26:48 +07:00
|
|
|
const factory DocumentEvent.syncStateChanged(
|
|
|
|
final DocumentSyncStatePB syncState,
|
|
|
|
) = syncStateChanged;
|
2021-07-24 18:55:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@freezed
|
2022-02-23 22:17:47 +08:00
|
|
|
class DocumentState with _$DocumentState {
|
|
|
|
const factory DocumentState({
|
2024-03-21 12:26:48 +07:00
|
|
|
required final bool isDeleted,
|
|
|
|
required final bool forceClose,
|
|
|
|
required final bool isLoading,
|
|
|
|
required final DocumentSyncState syncState,
|
2023-11-09 00:30:50 +01:00
|
|
|
bool? isDocumentEmpty,
|
2023-02-16 10:17:08 +08:00
|
|
|
UserProfilePB? userProfilePB,
|
2023-12-10 20:26:23 +07:00
|
|
|
EditorState? editorState,
|
|
|
|
FlowyError? error,
|
2024-03-28 17:46:31 +08:00
|
|
|
@Default(null) DocumentAwarenessStatesPB? awarenessStates,
|
2022-02-23 22:17:47 +08:00
|
|
|
}) = _DocumentState;
|
2021-10-19 13:56:11 +08:00
|
|
|
|
2022-02-23 22:17:47 +08:00
|
|
|
factory DocumentState.initial() => const DocumentState(
|
2021-10-31 17:24:55 +08:00
|
|
|
isDeleted: false,
|
2021-10-31 20:27:37 +08:00
|
|
|
forceClose: false,
|
2023-12-10 20:26:23 +07:00
|
|
|
isLoading: true,
|
2024-03-21 12:26:48 +07:00
|
|
|
syncState: DocumentSyncState.Syncing,
|
2021-10-31 17:24:55 +08:00
|
|
|
);
|
2021-10-19 13:56:11 +08:00
|
|
|
}
|