mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: init database row init (#6127)
This commit is contained in:
parent
3324e7837b
commit
8139065113
@ -306,6 +306,8 @@ class MobileRowDetailPageContentState
|
|||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
rowController.initialize();
|
||||||
|
|
||||||
cellBuilder = EditableCellBuilder(
|
cellBuilder = EditableCellBuilder(
|
||||||
databaseController: widget.databaseController,
|
databaseController: widget.databaseController,
|
||||||
);
|
);
|
||||||
|
@ -35,6 +35,8 @@ class RelatedRowDetailPageBloc
|
|||||||
on<RelatedRowDetailPageEvent>((event, emit) async {
|
on<RelatedRowDetailPageEvent>((event, emit) async {
|
||||||
event.when(
|
event.when(
|
||||||
didInitialize: (databaseController, rowController) {
|
didInitialize: (databaseController, rowController) {
|
||||||
|
rowController.initialize();
|
||||||
|
|
||||||
state.maybeWhen(
|
state.maybeWhen(
|
||||||
ready: (_, oldRowController) async {
|
ready: (_, oldRowController) async {
|
||||||
await oldRowController.dispose();
|
await oldRowController.dispose();
|
||||||
@ -93,6 +95,7 @@ class RelatedRowDetailPageBloc
|
|||||||
viewId: inlineView.id,
|
viewId: inlineView.id,
|
||||||
rowCache: databaseController.rowCache,
|
rowCache: databaseController.rowCache,
|
||||||
);
|
);
|
||||||
|
|
||||||
add(
|
add(
|
||||||
RelatedRowDetailPageEvent.didInitialize(
|
RelatedRowDetailPageEvent.didInitialize(
|
||||||
databaseController,
|
databaseController,
|
||||||
|
@ -38,6 +38,9 @@ class RowController {
|
|||||||
|
|
||||||
List<CellContext> loadCells() => _rowCache.loadCells(rowMeta);
|
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 {
|
Future<void> initialize() async {
|
||||||
await _rowBackendSvc.initRow(rowMeta.id);
|
await _rowBackendSvc.initRow(rowMeta.id);
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -397,6 +397,7 @@ class HiddenGroupPopupItemList extends StatelessWidget {
|
|||||||
viewId: viewId,
|
viewId: viewId,
|
||||||
rowCache: rowCache,
|
rowCache: rowCache,
|
||||||
);
|
);
|
||||||
|
rowController.initialize();
|
||||||
|
|
||||||
final databaseController =
|
final databaseController =
|
||||||
context.read<BoardBloc>().databaseController;
|
context.read<BoardBloc>().databaseController;
|
||||||
|
@ -29,6 +29,8 @@ class CalendarEventEditorBloc
|
|||||||
(event, emit) async {
|
(event, emit) async {
|
||||||
await event.when(
|
await event.when(
|
||||||
initial: () {
|
initial: () {
|
||||||
|
rowController.initialize();
|
||||||
|
|
||||||
_startListening();
|
_startListening();
|
||||||
final primaryFieldId = fieldController.fieldInfos
|
final primaryFieldId = fieldController.fieldInfos
|
||||||
.firstWhere((fieldInfo) => fieldInfo.isPrimary)
|
.firstWhere((fieldInfo) => fieldInfo.isPrimary)
|
||||||
|
@ -20,6 +20,8 @@ class RowDetailBloc extends Bloc<RowDetailEvent, RowDetailState> {
|
|||||||
_dispatch();
|
_dispatch();
|
||||||
_startListening();
|
_startListening();
|
||||||
_init();
|
_init();
|
||||||
|
|
||||||
|
rowController.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
final FieldController fieldController;
|
final FieldController fieldController;
|
||||||
|
@ -32,6 +32,7 @@ class CardBloc extends Bloc<CardEvent, CardState> {
|
|||||||
rowController.rowMeta,
|
rowController.rowMeta,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
|
rowController.initialize();
|
||||||
_dispatch();
|
_dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:appflowy/plugins/database/application/database_controller.dart';
|
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_controller.dart';
|
||||||
import 'package:appflowy/plugins/database/application/row/row_service.dart';
|
import 'package:appflowy/plugins/database/application/row/row_service.dart';
|
||||||
@ -87,6 +89,8 @@ class DatabaseDocumentTitleBloc
|
|||||||
viewId: view.id,
|
viewId: view.id,
|
||||||
rowCache: databaseController.rowCache,
|
rowCache: databaseController.rowCache,
|
||||||
);
|
);
|
||||||
|
unawaited(rowController.initialize());
|
||||||
|
|
||||||
final primaryFieldId =
|
final primaryFieldId =
|
||||||
await FieldBackendService.getPrimaryField(viewId: view.id).fold(
|
await FieldBackendService.getPrimaryField(viewId: view.id).fold(
|
||||||
(primaryField) => primaryField.id,
|
(primaryField) => primaryField.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user