fix: init database row init (#6127)

This commit is contained in:
Nathan.fooo 2024-08-30 22:12:20 +08:00 committed by GitHub
parent 3324e7837b
commit 8139065113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 18 additions and 0 deletions

View File

@ -306,6 +306,8 @@ class MobileRowDetailPageContentState
viewId: viewId,
rowCache: rowCache,
);
rowController.initialize();
cellBuilder = EditableCellBuilder(
databaseController: widget.databaseController,
);

View File

@ -35,6 +35,8 @@ class RelatedRowDetailPageBloc
on<RelatedRowDetailPageEvent>((event, emit) async {
event.when(
didInitialize: (databaseController, rowController) {
rowController.initialize();
state.maybeWhen(
ready: (_, oldRowController) async {
await oldRowController.dispose();
@ -93,6 +95,7 @@ class RelatedRowDetailPageBloc
viewId: inlineView.id,
rowCache: databaseController.rowCache,
);
add(
RelatedRowDetailPageEvent.didInitialize(
databaseController,

View File

@ -38,6 +38,9 @@ class RowController {
List<CellContext> loadCells() => _rowCache.loadCells(rowMeta);
/// This method must be called to initialize the row controller; otherwise, the row will not sync between devices.
/// When creating a row controller, calling [initialize] immediately may not be necessary.
/// Only call [initialize] when the row becomes visible. This approach helps reduce unnecessary sync operations.
Future<void> initialize() async {
await _rowBackendSvc.initRow(rowMeta.id);
unawaited(

View File

@ -397,6 +397,7 @@ class HiddenGroupPopupItemList extends StatelessWidget {
viewId: viewId,
rowCache: rowCache,
);
rowController.initialize();
final databaseController =
context.read<BoardBloc>().databaseController;

View File

@ -29,6 +29,8 @@ class CalendarEventEditorBloc
(event, emit) async {
await event.when(
initial: () {
rowController.initialize();
_startListening();
final primaryFieldId = fieldController.fieldInfos
.firstWhere((fieldInfo) => fieldInfo.isPrimary)

View File

@ -20,6 +20,8 @@ class RowDetailBloc extends Bloc<RowDetailEvent, RowDetailState> {
_dispatch();
_startListening();
_init();
rowController.initialize();
}
final FieldController fieldController;

View File

@ -32,6 +32,7 @@ class CardBloc extends Bloc<CardEvent, CardState> {
rowController.rowMeta,
),
) {
rowController.initialize();
_dispatch();
}

View File

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:appflowy/plugins/database/application/database_controller.dart';
import 'package:appflowy/plugins/database/application/row/row_controller.dart';
import 'package:appflowy/plugins/database/application/row/row_service.dart';
@ -87,6 +89,8 @@ class DatabaseDocumentTitleBloc
viewId: view.id,
rowCache: databaseController.rowCache,
);
unawaited(rowController.initialize());
final primaryFieldId =
await FieldBackendService.getPrimaryField(viewId: view.id).fold(
(primaryField) => primaryField.id,