chore: fix database filter (#6005)

* chore: fix filter
This commit is contained in:
Nathan.fooo 2024-08-19 09:47:37 +08:00 committed by GitHub
parent 5878379b2e
commit d0ce65f711
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 214 additions and 151 deletions

View File

@ -2,7 +2,9 @@ import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'package:appflowy/plugins/database/application/row/row_service.dart'; import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import '../defines.dart'; import '../defines.dart';
import '../field/field_controller.dart'; import '../field/field_controller.dart';
@ -91,6 +93,17 @@ class DatabaseViewCache {
(reorderRow) => _rowCache.reorderSingleRow(reorderRow), (reorderRow) => _rowCache.reorderSingleRow(reorderRow),
(err) => Log.error(err), (err) => Log.error(err),
), ),
onReloadRows: () {
final payload = DatabaseViewIdPB(value: viewId);
DatabaseEventGetAllRows(payload).send().then((result) {
result.fold(
(rows) {
_rowCache.setInitialRows(rows.items);
},
(err) => Log.error(err),
);
});
},
); );
_rowCache.onRowsChanged( _rowCache.onRowsChanged(

View File

@ -7,85 +7,96 @@ import 'package:appflowy_backend/protobuf/flowy-database2/sort_entities.pb.dart'
import 'package:appflowy_backend/protobuf/flowy-database2/view_entities.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/view_entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_result/appflowy_result.dart'; import 'package:appflowy_result/appflowy_result.dart';
import 'package:flowy_infra/notifier.dart';
typedef RowsVisibilityNotifierValue typedef RowsVisibilityCallback = void Function(
= FlowyResult<RowsVisibilityChangePB, FlowyError>; FlowyResult<RowsVisibilityChangePB, FlowyError>,
);
typedef NumberOfRowsNotifierValue = FlowyResult<RowsChangePB, FlowyError>; typedef NumberOfRowsCallback = void Function(
typedef ReorderAllRowsNotifierValue = FlowyResult<List<String>, FlowyError>; FlowyResult<RowsChangePB, FlowyError>,
typedef SingleRowNotifierValue = FlowyResult<ReorderSingleRowPB, FlowyError>; );
typedef ReorderAllRowsCallback = void Function(
FlowyResult<List<String>, FlowyError>,
);
typedef SingleRowCallback = void Function(
FlowyResult<ReorderSingleRowPB, FlowyError>,
);
class DatabaseViewListener { class DatabaseViewListener {
DatabaseViewListener({required this.viewId}); DatabaseViewListener({required this.viewId});
final String viewId; final String viewId;
PublishNotifier<NumberOfRowsNotifierValue>? _rowsNotifier = PublishNotifier();
PublishNotifier<ReorderAllRowsNotifierValue>? _reorderAllRows =
PublishNotifier();
PublishNotifier<SingleRowNotifierValue>? _reorderSingleRow =
PublishNotifier();
PublishNotifier<RowsVisibilityNotifierValue>? _rowsVisibility =
PublishNotifier();
DatabaseNotificationListener? _listener; DatabaseNotificationListener? _listener;
void start({ void start({
required void Function(NumberOfRowsNotifierValue) onRowsChanged, required NumberOfRowsCallback onRowsChanged,
required void Function(ReorderAllRowsNotifierValue) onReorderAllRows, required ReorderAllRowsCallback onReorderAllRows,
required void Function(SingleRowNotifierValue) onReorderSingleRow, required SingleRowCallback onReorderSingleRow,
required void Function(RowsVisibilityNotifierValue) onRowsVisibilityChanged, required RowsVisibilityCallback onRowsVisibilityChanged,
required void Function() onReloadRows,
}) { }) {
if (_listener != null) { // Stop any existing listener
_listener?.stop(); _listener?.stop();
}
// Initialize the notification listener
_listener = DatabaseNotificationListener( _listener = DatabaseNotificationListener(
objectId: viewId, objectId: viewId,
handler: _handler, handler: (ty, result) => _handler(
ty,
result,
onRowsChanged,
onReorderAllRows,
onReorderSingleRow,
onRowsVisibilityChanged,
onReloadRows,
),
); );
_rowsNotifier?.addPublishListener(onRowsChanged);
_rowsVisibility?.addPublishListener(onRowsVisibilityChanged);
_reorderAllRows?.addPublishListener(onReorderAllRows);
_reorderSingleRow?.addPublishListener(onReorderSingleRow);
} }
void _handler( void _handler(
DatabaseNotification ty, DatabaseNotification ty,
FlowyResult<Uint8List, FlowyError> result, FlowyResult<Uint8List, FlowyError> result,
NumberOfRowsCallback onRowsChanged,
ReorderAllRowsCallback onReorderAllRows,
SingleRowCallback onReorderSingleRow,
RowsVisibilityCallback onRowsVisibilityChanged,
void Function() onReloadRows,
) { ) {
switch (ty) { switch (ty) {
case DatabaseNotification.DidUpdateViewRowsVisibility: case DatabaseNotification.DidUpdateViewRowsVisibility:
result.fold( result.fold(
(payload) => _rowsVisibility?.value = (payload) => onRowsVisibilityChanged(
FlowyResult.success(RowsVisibilityChangePB.fromBuffer(payload)), FlowyResult.success(RowsVisibilityChangePB.fromBuffer(payload)),
(error) => _rowsVisibility?.value = FlowyResult.failure(error), ),
(error) => onRowsVisibilityChanged(FlowyResult.failure(error)),
); );
break; break;
case DatabaseNotification.DidUpdateRow: case DatabaseNotification.DidUpdateRow:
result.fold( result.fold(
(payload) => _rowsNotifier?.value = (payload) => onRowsChanged(
FlowyResult.success(RowsChangePB.fromBuffer(payload)), FlowyResult.success(RowsChangePB.fromBuffer(payload)),
(error) => _rowsNotifier?.value = FlowyResult.failure(error), ),
(error) => onRowsChanged(FlowyResult.failure(error)),
); );
break; break;
case DatabaseNotification.DidReorderRows: case DatabaseNotification.DidReorderRows:
result.fold( result.fold(
(payload) => _reorderAllRows?.value = FlowyResult.success( (payload) => onReorderAllRows(
ReorderAllRowsPB.fromBuffer(payload).rowOrders, FlowyResult.success(ReorderAllRowsPB.fromBuffer(payload).rowOrders),
), ),
(error) => _reorderAllRows?.value = FlowyResult.failure(error), (error) => onReorderAllRows(FlowyResult.failure(error)),
); );
break; break;
case DatabaseNotification.DidReorderSingleRow: case DatabaseNotification.DidReorderSingleRow:
result.fold( result.fold(
(payload) => _reorderSingleRow?.value = (payload) => onReorderSingleRow(
FlowyResult.success(ReorderSingleRowPB.fromBuffer(payload)), FlowyResult.success(ReorderSingleRowPB.fromBuffer(payload)),
(error) => _reorderSingleRow?.value = FlowyResult.failure(error), ),
(error) => onReorderSingleRow(FlowyResult.failure(error)),
); );
break; break;
case DatabaseNotification.ReloadRows:
onReloadRows();
break;
default: default:
break; break;
} }
@ -93,16 +104,6 @@ class DatabaseViewListener {
Future<void> stop() async { Future<void> stop() async {
await _listener?.stop(); await _listener?.stop();
_rowsVisibility?.dispose(); _listener = null;
_rowsVisibility = null;
_rowsNotifier?.dispose();
_rowsNotifier = null;
_reorderAllRows?.dispose();
_reorderAllRows = null;
_reorderSingleRow?.dispose();
_reorderSingleRow = null;
} }
} }

View File

@ -963,7 +963,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -988,7 +988,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1018,7 +1018,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1038,7 +1038,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1057,7 +1057,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1100,7 +1100,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1180,7 +1180,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -2176,6 +2176,7 @@ dependencies = [
"strum", "strum",
"strum_macros 0.25.2", "strum_macros 0.25.2",
"tokio", "tokio",
"tokio-util",
"tracing", "tracing",
"url", "url",
"validator", "validator",

View File

@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -946,7 +946,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -971,7 +971,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1001,7 +1001,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1021,7 +1021,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1040,7 +1040,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -1083,7 +1083,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1163,7 +1163,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -2206,6 +2206,7 @@ dependencies = [
"strum", "strum",
"strum_macros 0.25.3", "strum_macros 0.25.3",
"tokio", "tokio",
"tokio-util",
"tracing", "tracing",
"url", "url",
"validator", "validator",

View File

@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -824,7 +824,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -849,7 +849,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -879,7 +879,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -899,7 +899,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -918,7 +918,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -961,7 +961,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1041,7 +1041,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0af7f361d52611842a862b982b2c72e4fa12cda1#0af7f361d52611842a862b982b2c72e4fa12cda1" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ba00c1e430f6157a2b6cbda89992d3b154ea6fb#2ba00c1e430f6157a2b6cbda89992d3b154ea6fb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -2002,6 +2002,7 @@ dependencies = [
"strum", "strum",
"strum_macros 0.25.2", "strum_macros 0.25.2",
"tokio", "tokio",
"tokio-util",
"tracing", "tracing",
"url", "url",
"validator", "validator",

View File

@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0af7f361d52611842a862b982b2c72e4fa12cda1" } collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ba00c1e430f6157a2b6cbda89992d3b154ea6fb" }
# Working directory: frontend # Working directory: frontend
# To update the commit ID, run: # To update the commit ID, run:

View File

@ -49,6 +49,7 @@ csv = "1.1.6"
strum = "0.25" strum = "0.25"
strum_macros = "0.25" strum_macros = "0.25"
validator = { workspace = true, features = ["derive"] } validator = { workspace = true, features = ["derive"] }
tokio-util.workspace = true
[dev-dependencies] [dev-dependencies]
event-integration-test = { path = "../event-integration-test", default-features = false } event-integration-test = { path = "../event-integration-test", default-features = false }

View File

@ -68,6 +68,12 @@ pub struct RowMetaPB {
pub is_document_empty: bool, pub is_document_empty: bool,
} }
#[derive(Debug, Default, ProtoBuf)]
pub struct RepeatedRowMetaPB {
#[pb(index = 1)]
pub items: Vec<RowMetaPB>,
}
impl std::convert::From<&RowDetail> for RowMetaPB { impl std::convert::From<&RowDetail> for RowMetaPB {
fn from(row_detail: &RowDetail) -> Self { fn from(row_detail: &RowDetail) -> Self {
Self { Self {
@ -213,18 +219,6 @@ pub struct OptionalRowPB {
pub row: Option<RowPB>, pub row: Option<RowPB>,
} }
#[derive(Debug, Default, ProtoBuf)]
pub struct RepeatedRowPB {
#[pb(index = 1)]
pub items: Vec<RowPB>,
}
impl std::convert::From<Vec<RowPB>> for RepeatedRowPB {
fn from(items: Vec<RowPB>) -> Self {
Self { items }
}
}
#[derive(Debug, Clone, Default, ProtoBuf)] #[derive(Debug, Clone, Default, ProtoBuf)]
pub struct InsertedRowPB { pub struct InsertedRowPB {
#[pb(index = 1)] #[pb(index = 1)]

View File

@ -47,6 +47,20 @@ pub(crate) async fn get_database_data_handler(
data_result_ok(data) data_result_ok(data)
} }
#[tracing::instrument(level = "trace", skip_all, err)]
pub(crate) async fn get_all_rows_handler(
data: AFPluginData<DatabaseViewIdPB>,
manager: AFPluginState<Weak<DatabaseManager>>,
) -> DataResult<RepeatedRowMetaPB, FlowyError> {
let manager = upgrade_manager(manager)?;
let view_id: DatabaseViewIdPB = data.into_inner();
let database_id = manager
.get_database_id_with_view_id(view_id.as_ref())
.await?;
let database_editor = manager.get_database_editor(&database_id).await?;
let data = database_editor.get_all_rows(view_id.as_ref()).await?;
data_result_ok(data)
}
#[tracing::instrument(level = "trace", skip_all, err)] #[tracing::instrument(level = "trace", skip_all, err)]
pub(crate) async fn open_database_handler( pub(crate) async fn open_database_handler(
data: AFPluginData<DatabaseViewIdPB>, data: AFPluginData<DatabaseViewIdPB>,

View File

@ -14,6 +14,7 @@ pub fn init(database_manager: Weak<DatabaseManager>) -> AFPlugin {
.state(database_manager); .state(database_manager);
plugin plugin
.event(DatabaseEvent::GetDatabase, get_database_data_handler) .event(DatabaseEvent::GetDatabase, get_database_data_handler)
.event(DatabaseEvent::GetAllRows, get_all_rows_handler)
.event(DatabaseEvent::GetDatabaseData, get_database_data_handler) .event(DatabaseEvent::GetDatabaseData, get_database_data_handler)
.event(DatabaseEvent::GetDatabaseId, get_database_id_handler) .event(DatabaseEvent::GetDatabaseId, get_database_id_handler)
.event(DatabaseEvent::GetDatabaseSetting, get_database_setting_handler) .event(DatabaseEvent::GetDatabaseSetting, get_database_setting_handler)
@ -381,4 +382,7 @@ pub enum DatabaseEvent {
#[event(input = "RowIdPB")] #[event(input = "RowIdPB")]
InitRow = 176, InitRow = 176,
#[event(input = "DatabaseViewIdPB", output = "RepeatedRowMetaPB")]
GetAllRows = 177,
} }

View File

@ -290,15 +290,14 @@ impl DatabaseManager {
.await .await
.ok_or_else(|| FlowyError::collab_not_sync().with_context("open database error"))?; .ok_or_else(|| FlowyError::collab_not_sync().with_context("open database error"))?;
let editor = Arc::new( let editor = DatabaseEditor::new(
DatabaseEditor::new( self.user.clone(),
self.user.clone(), database,
database, self.task_scheduler.clone(),
self.task_scheduler.clone(), self.collab_builder.clone(),
self.collab_builder.clone(), )
) .await?;
.await?,
);
self self
.editors .editors
.lock() .lock()

View File

@ -52,6 +52,7 @@ pub enum DatabaseNotification {
DidUpdateFieldSettings = 86, DidUpdateFieldSettings = 86,
// Trigger when Calculation changed // Trigger when Calculation changed
DidUpdateCalculation = 87, DidUpdateCalculation = 87,
ReloadRows = 88,
} }
impl std::convert::From<DatabaseNotification> for i32 { impl std::convert::From<DatabaseNotification> for i32 {

View File

@ -43,7 +43,7 @@ use tracing::{debug, error, event, instrument, trace, warn};
pub struct DatabaseEditor { pub struct DatabaseEditor {
pub(crate) database: Arc<RwLock<Database>>, pub(crate) database: Arc<RwLock<Database>>,
pub cell_cache: CellCache, pub cell_cache: CellCache,
database_views: Arc<DatabaseViews>, pub(crate) database_views: Arc<DatabaseViews>,
#[allow(dead_code)] #[allow(dead_code)]
/// Used to send notification to the frontend. /// Used to send notification to the frontend.
notification_sender: Arc<DebounceNotificationSender>, notification_sender: Arc<DebounceNotificationSender>,
@ -57,7 +57,7 @@ impl DatabaseEditor {
database: Arc<RwLock<Database>>, database: Arc<RwLock<Database>>,
task_scheduler: Arc<RwLock<TaskDispatcher>>, task_scheduler: Arc<RwLock<TaskDispatcher>>,
collab_builder: Arc<AppFlowyCollabBuilder>, collab_builder: Arc<AppFlowyCollabBuilder>,
) -> FlowyResult<Self> { ) -> FlowyResult<Arc<Self>> {
let notification_sender = Arc::new(DebounceNotificationSender::new(200)); let notification_sender = Arc::new(DebounceNotificationSender::new(200));
let cell_cache = AnyTypeCache::<u64>::new(); let cell_cache = AnyTypeCache::<u64>::new();
let database_id = database.read().await.get_database_id(); let database_id = database.read().await.get_database_id();
@ -66,7 +66,6 @@ impl DatabaseEditor {
// observe_view_change(&database_id, &database).await; // observe_view_change(&database_id, &database).await;
// observe_field_change(&database_id, &database).await; // observe_field_change(&database_id, &database).await;
observe_rows_change(&database_id, &database, &notification_sender).await; observe_rows_change(&database_id, &database, &notification_sender).await;
observe_block_event(&database_id, &database).await;
// Used to cache the view of the database for fast access. // Used to cache the view of the database for fast access.
let editor_by_view_id = Arc::new(RwLock::new(EditorByViewId::default())); let editor_by_view_id = Arc::new(RwLock::new(EditorByViewId::default()));
@ -99,15 +98,16 @@ impl DatabaseEditor {
CollabBuilderConfig::default(), CollabBuilderConfig::default(),
database.clone(), database.clone(),
)?; )?;
let this = Arc::new(Self {
Ok(Self {
user, user,
database, database,
cell_cache, cell_cache,
database_views, database_views,
notification_sender, notification_sender,
collab_builder, collab_builder,
}) });
observe_block_event(&database_id, &this).await;
Ok(this)
} }
pub async fn close_view(&self, view_id: &str) { pub async fn close_view(&self, view_id: &str) {
@ -1299,7 +1299,7 @@ impl DatabaseEditor {
.await .await
.ok_or_else(FlowyError::record_not_found)?; .ok_or_else(FlowyError::record_not_found)?;
let row_orders = self.database.read().await.get_row_orders_for_view(&view_id); let row_details = database_view.v_get_row_details().await;
let (database_id, fields, is_linked) = { let (database_id, fields, is_linked) = {
let database = self.database.read().await; let database = self.database.read().await;
let database_id = database.get_database_id(); let database_id = database.get_database_id();
@ -1312,15 +1312,9 @@ impl DatabaseEditor {
(database_id, fields, is_linked) (database_id, fields, is_linked)
}; };
let rows = row_orders let rows = row_details
.into_iter() .into_iter()
.map(|row_order| RowMetaPB { .map(|detail| RowMetaPB::from(detail.as_ref()))
id: row_order.id.to_string(),
document_id: "".to_string(),
icon: None,
cover: None,
is_document_empty: false,
})
.collect::<Vec<RowMetaPB>>(); .collect::<Vec<RowMetaPB>>();
Ok(DatabasePB { Ok(DatabasePB {
id: database_id, id: database_id,
@ -1331,6 +1325,16 @@ impl DatabaseEditor {
}) })
} }
pub async fn get_all_rows(&self, view_id: &str) -> FlowyResult<RepeatedRowMetaPB> {
let database_view = self.database_views.get_view_editor(view_id).await?;
let row_details = database_view.v_get_row_details().await;
let rows = row_details
.into_iter()
.map(|detail| RowMetaPB::from(detail.as_ref()))
.collect::<Vec<RowMetaPB>>();
Ok(RepeatedRowMetaPB { items: rows })
}
pub async fn export_csv(&self, style: CSVFormat) -> FlowyResult<String> { pub async fn export_csv(&self, style: CSVFormat) -> FlowyResult<String> {
let database = self.database.clone(); let database = self.database.clone();
let database_guard = database.read().await; let database_guard = database.read().await;

View File

@ -1,6 +1,6 @@
use crate::entities::{DatabaseSyncStatePB, DidFetchRowPB, RowsChangePB}; use crate::entities::{DatabaseSyncStatePB, DidFetchRowPB, RowsChangePB};
use crate::notification::{send_notification, DatabaseNotification, DATABASE_OBSERVABLE_SOURCE}; use crate::notification::{send_notification, DatabaseNotification, DATABASE_OBSERVABLE_SOURCE};
use crate::services::database::UpdatedRow; use crate::services::database::{DatabaseEditor, UpdatedRow};
use collab_database::blocks::BlockEvent; use collab_database::blocks::BlockEvent;
use collab_database::database::Database; use collab_database::database::Database;
use collab_database::fields::FieldChange; use collab_database::fields::FieldChange;
@ -10,7 +10,9 @@ use flowy_notification::{DebounceNotificationSender, NotificationBuilder};
use futures::StreamExt; use futures::StreamExt;
use lib_dispatch::prelude::af_spawn; use lib_dispatch::prelude::af_spawn;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration;
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tokio_util::sync::CancellationToken;
use tracing::{trace, warn}; use tracing::{trace, warn};
pub(crate) async fn observe_sync_state(database_id: &str, database: &Arc<RwLock<Database>>) { pub(crate) async fn observe_sync_state(database_id: &str, database: &Arc<RwLock<Database>>) {
@ -136,13 +138,18 @@ pub(crate) async fn observe_view_change(database_id: &str, database: &Arc<RwLock
}); });
} }
pub(crate) async fn observe_block_event(database_id: &str, database: &Arc<RwLock<Database>>) { pub(crate) async fn observe_block_event(database_id: &str, database_editor: &Arc<DatabaseEditor>) {
let database_id = database_id.to_string(); let database_id = database_id.to_string();
let weak_database = Arc::downgrade(database); let mut block_event_rx = database_editor
let mut block_event_rx = database.read().await.subscribe_block_event(); .database
.read()
.await
.subscribe_block_event();
let database_editor = Arc::downgrade(database_editor);
af_spawn(async move { af_spawn(async move {
let token = CancellationToken::new();
while let Ok(event) = block_event_rx.recv().await { while let Ok(event) = block_event_rx.recv().await {
if weak_database.upgrade().is_none() { if database_editor.upgrade().is_none() {
break; break;
} }
@ -155,12 +162,31 @@ pub(crate) async fn observe_block_event(database_id: &str, database: &Arc<RwLock
BlockEvent::DidFetchRow(row_details) => { BlockEvent::DidFetchRow(row_details) => {
for row_detail in row_details { for row_detail in row_details {
trace!("Did fetch row: {:?}", row_detail.row.id); trace!("Did fetch row: {:?}", row_detail.row.id);
let row_id = row_detail.row.id.clone(); let row_id = row_detail.row.id.clone();
let pb = DidFetchRowPB::from(row_detail); let pb = DidFetchRowPB::from(row_detail);
send_notification(&row_id, DatabaseNotification::DidFetchRow) send_notification(&row_id, DatabaseNotification::DidFetchRow)
.payload(pb) .payload(pb)
.send(); .send();
} }
let cloned_token = token.clone();
let cloned_database_editor = database_editor.clone();
tokio::spawn(async move {
tokio::time::sleep(Duration::from_secs(2)).await;
if cloned_token.is_cancelled() {
return;
}
if let Some(database_editor) = cloned_database_editor.upgrade() {
for view_editor in database_editor.database_views.editors().await {
send_notification(
&view_editor.view_id.clone(),
DatabaseNotification::ReloadRows,
)
.send();
}
}
});
}, },
} }
} }

View File

@ -293,11 +293,9 @@ impl DatabaseViewEditor {
// Each row update will trigger a calculations, filter and sort operation. We don't want // Each row update will trigger a calculations, filter and sort operation. We don't want
// to block the main thread, so we spawn a new task to do the work. // to block the main thread, so we spawn a new task to do the work.
if let Some(field_id) = field_id { self
self .gen_did_update_row_view_tasks(row_detail.row.id.clone(), field_id)
.gen_did_update_row_view_tasks(row_detail.row.id.clone(), field_id) .await;
.await;
}
} }
pub async fn v_filter_rows(&self, row_details: &mut Vec<Arc<RowDetail>>) { pub async fn v_filter_rows(&self, row_details: &mut Vec<Arc<RowDetail>>) {
@ -682,7 +680,6 @@ impl DatabaseViewEditor {
#[tracing::instrument(level = "trace", skip(self), err)] #[tracing::instrument(level = "trace", skip(self), err)]
pub async fn v_modify_filters(&self, changeset: FilterChangeset) -> FlowyResult<()> { pub async fn v_modify_filters(&self, changeset: FilterChangeset) -> FlowyResult<()> {
let notification = self.filter_controller.apply_changeset(changeset).await; let notification = self.filter_controller.apply_changeset(changeset).await;
notify_did_update_filter(notification).await; notify_did_update_filter(notification).await;
let group_controller_read_guard = self.group_controller.read().await; let group_controller_read_guard = self.group_controller.read().await;
@ -1100,7 +1097,7 @@ impl DatabaseViewEditor {
} }
} }
async fn gen_did_update_row_view_tasks(&self, row_id: RowId, field_id: String) { async fn gen_did_update_row_view_tasks(&self, row_id: RowId, field_id: Option<String>) {
let weak_filter_controller = Arc::downgrade(&self.filter_controller); let weak_filter_controller = Arc::downgrade(&self.filter_controller);
let weak_sort_controller = Arc::downgrade(&self.sort_controller); let weak_sort_controller = Arc::downgrade(&self.sort_controller);
let weak_calculations_controller = Arc::downgrade(&self.calculations_controller); let weak_calculations_controller = Arc::downgrade(&self.calculations_controller);
@ -1117,10 +1114,13 @@ impl DatabaseViewEditor {
.did_receive_row_changed(row_id.clone()) .did_receive_row_changed(row_id.clone())
.await; .await;
} }
if let Some(calculations_controller) = weak_calculations_controller.upgrade() { if let Some(calculations_controller) = weak_calculations_controller.upgrade() {
calculations_controller if let Some(field_id) = field_id {
.did_receive_cell_changed(field_id) calculations_controller
.await; .did_receive_cell_changed(field_id)
.await;
}
} }
}); });
} }

View File

@ -7,11 +7,11 @@ use collab_database::database::gen_database_filter_id;
use collab_database::fields::Field; use collab_database::fields::Field;
use collab_database::rows::{Cell, Cells, Row, RowDetail, RowId}; use collab_database::rows::{Cell, Cells, Row, RowDetail, RowId};
use dashmap::DashMap; use dashmap::DashMap;
use serde::{Deserialize, Serialize};
use tokio::sync::RwLock;
use flowy_error::FlowyResult; use flowy_error::FlowyResult;
use lib_infra::priority_task::{QualityOfService, Task, TaskContent, TaskDispatcher}; use lib_infra::priority_task::{QualityOfService, Task, TaskContent, TaskDispatcher};
use serde::{Deserialize, Serialize};
use tokio::sync::RwLock;
use tracing::error;
use crate::entities::filter_entities::*; use crate::entities::filter_entities::*;
use crate::entities::{FieldType, InsertedRowPB, RowMetaPB}; use crate::entities::{FieldType, InsertedRowPB, RowMetaPB};
@ -185,8 +185,9 @@ impl FilterController {
.iter_mut() .iter_mut()
.find_map(|filter| filter.find_filter(&parent_filter_id)) .find_map(|filter| filter.find_filter(&parent_filter_id))
{ {
// TODO(RS): error handling for inserting filters if let Err(err) = parent_filter.insert_filter(new_filter) {
let _result = parent_filter.insert_filter(new_filter); error!("error while inserting filter: {}", err);
}
} }
}, },
None => { None => {
@ -214,7 +215,9 @@ impl FilterController {
.find_map(|filter| filter.find_filter(&filter_id)) .find_map(|filter| filter.find_filter(&filter_id))
{ {
// TODO(RS): error handling for updating filter data // TODO(RS): error handling for updating filter data
let _result = filter.update_filter_data(data); if let Err(error) = filter.update_filter_data(data) {
error!("error while updating filter data: {}", error);
}
} }
}, },
FilterChangeset::Delete { FilterChangeset::Delete {