diff --git a/frontend/app_flowy/lib/core/grid_notification.dart b/frontend/app_flowy/lib/core/grid_notification.dart index befebe277b..db474e5818 100644 --- a/frontend/app_flowy/lib/core/grid_notification.dart +++ b/frontend/app_flowy/lib/core/grid_notification.dart @@ -10,22 +10,22 @@ import 'notification_helper.dart'; // GridPB typedef GridNotificationCallback = void Function( - GridDartNotification, Either); + GridNotification, Either); class GridNotificationParser - extends NotificationParser { + extends NotificationParser { GridNotificationParser( {String? id, required GridNotificationCallback callback}) : super( id: id, callback: callback, - tyParser: (ty) => GridDartNotification.valueOf(ty), + tyParser: (ty) => GridNotification.valueOf(ty), errorParser: (bytes) => FlowyError.fromBuffer(bytes), ); } typedef GridNotificationHandler = Function( - GridDartNotification ty, Either result); + GridNotification ty, Either result); class GridNotificationListener { StreamSubscription? _subscription; diff --git a/frontend/app_flowy/lib/plugins/board/application/board_listener.dart b/frontend/app_flowy/lib/plugins/board/application/board_listener.dart index b64a6b6bed..ddc93ac93c 100644 --- a/frontend/app_flowy/lib/plugins/board/application/board_listener.dart +++ b/frontend/app_flowy/lib/plugins/board/application/board_listener.dart @@ -32,18 +32,18 @@ class BoardListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateGroupView: + case GridNotification.DidUpdateGroupView: result.fold( (payload) => _groupUpdateNotifier?.value = left(GroupViewChangesetPB.fromBuffer(payload)), (error) => _groupUpdateNotifier?.value = right(error), ); break; - case GridDartNotification.DidGroupByNewField: + case GridNotification.DidGroupByNewField: result.fold( (payload) => _groupByNewFieldNotifier?.value = left(GroupViewChangesetPB.fromBuffer(payload).newGroups), diff --git a/frontend/app_flowy/lib/plugins/board/application/group_listener.dart b/frontend/app_flowy/lib/plugins/board/application/group_listener.dart index 65a7e18ef4..ce23630d97 100644 --- a/frontend/app_flowy/lib/plugins/board/application/group_listener.dart +++ b/frontend/app_flowy/lib/plugins/board/application/group_listener.dart @@ -27,11 +27,11 @@ class GroupListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateGroup: + case GridNotification.DidUpdateGroup: result.fold( (payload) => _groupNotifier?.value = left(GroupRowsNotificationPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart index eb75e15610..54e02e2d0b 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/cell/cell_listener.dart @@ -22,9 +22,9 @@ class CellListener { objectId: "$rowId:$fieldId", handler: _handler); } - void _handler(GridDartNotification ty, Either result) { + void _handler(GridNotification ty, Either result) { switch (ty) { - case GridDartNotification.DidUpdateCell: + case GridNotification.DidUpdateCell: result.fold( (payload) => _updateCellNotifier?.value = left(unit), (error) => _updateCellNotifier?.value = right(error), diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart index 11a64f6c4f..363cf13723 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/field_listener.dart @@ -27,11 +27,11 @@ class SingleFieldListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateField: + case GridNotification.DidUpdateField: result.fold( (payload) => _updateFieldNotifier?.value = left(FieldPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart index e09312f117..11f4fd7132 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/field/grid_listener.dart @@ -25,9 +25,9 @@ class GridFieldsListener { ); } - void _handler(GridDartNotification ty, Either result) { + void _handler(GridNotification ty, Either result) { switch (ty) { - case GridDartNotification.DidUpdateGridFields: + case GridNotification.DidUpdateGridFields: result.fold( (payload) => updateFieldsNotifier?.value = left(GridFieldChangesetPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/filter/filter_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/filter/filter_listener.dart index d2e2446eec..644bf8dc04 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/filter/filter_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/filter/filter_listener.dart @@ -30,11 +30,11 @@ class FiltersListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateFilter: + case GridNotification.DidUpdateFilter: result.fold( (payload) => _filterNotifier?.value = left(FilterChangesetNotificationPB.fromBuffer(payload)), @@ -100,11 +100,11 @@ class FilterListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateFilter: + case GridNotification.DidUpdateFilter: result.fold( (payload) => handleChangeset( FilterChangesetNotificationPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart index 61aaa905be..615ade34be 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_listener.dart @@ -23,9 +23,9 @@ class RowListener { _listener = GridNotificationListener(objectId: rowId, handler: _handler); } - void _handler(GridDartNotification ty, Either result) { + void _handler(GridNotification ty, Either result) { switch (ty) { - case GridDartNotification.DidUpdateRow: + case GridNotification.DidUpdateRow: result.fold( (payload) => updateRowNotifier?.value = left(RowPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/setting/setting_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/setting/setting_listener.dart index a5c3cb5feb..e6ebd9b1b0 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/setting/setting_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/setting/setting_listener.dart @@ -24,9 +24,9 @@ class SettingListener { _listener = GridNotificationListener(objectId: gridId, handler: _handler); } - void _handler(GridDartNotification ty, Either result) { + void _handler(GridNotification ty, Either result) { switch (ty) { - case GridDartNotification.DidUpdateGridSetting: + case GridNotification.DidUpdateGridSetting: result.fold( (payload) => _updateSettingNotifier?.value = left( GridSettingPB.fromBuffer(payload), diff --git a/frontend/app_flowy/lib/plugins/grid/application/sort/sort_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/sort/sort_listener.dart index 8f60a1bb2c..8dce0c4da2 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/sort/sort_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/sort/sort_listener.dart @@ -27,11 +27,11 @@ class SortsListener { } void _handler( - GridDartNotification ty, + GridNotification ty, Either result, ) { switch (ty) { - case GridDartNotification.DidUpdateSort: + case GridNotification.DidUpdateSort: result.fold( (payload) => _notifier?.value = left(SortChangesetNotificationPB.fromBuffer(payload)), diff --git a/frontend/app_flowy/lib/plugins/grid/application/view/grid_view_listener.dart b/frontend/app_flowy/lib/plugins/grid/application/view/grid_view_listener.dart index 3be22e9b79..25cdc47d77 100644 --- a/frontend/app_flowy/lib/plugins/grid/application/view/grid_view_listener.dart +++ b/frontend/app_flowy/lib/plugins/grid/application/view/grid_view_listener.dart @@ -51,30 +51,30 @@ class GridViewListener { _reorderSingleRow?.addPublishListener(onReorderSingleRow); } - void _handler(GridDartNotification ty, Either result) { + void _handler(GridNotification ty, Either result) { switch (ty) { - case GridDartNotification.DidUpdateGridViewRowsVisibility: + case GridNotification.DidUpdateGridViewRowsVisibility: result.fold( (payload) => _rowsVisibility?.value = left(GridRowsVisibilityChangesetPB.fromBuffer(payload)), (error) => _rowsVisibility?.value = right(error), ); break; - case GridDartNotification.DidUpdateGridViewRows: + case GridNotification.DidUpdateGridViewRows: result.fold( (payload) => _rowsNotifier?.value = left(GridViewRowsChangesetPB.fromBuffer(payload)), (error) => _rowsNotifier?.value = right(error), ); break; - case GridDartNotification.DidReorderRows: + case GridNotification.DidReorderRows: result.fold( (payload) => _reorderAllRows?.value = left(ReorderAllRowsPB.fromBuffer(payload).rowOrders), (error) => _reorderAllRows?.value = right(error), ); break; - case GridDartNotification.DidReorderSingleRow: + case GridNotification.DidReorderSingleRow: result.fold( (payload) => _reorderSingleRow?.value = left(ReorderSingleRowPB.fromBuffer(payload)), diff --git a/frontend/appflowy_tauri/src/appflowy_app/App.tsx b/frontend/appflowy_tauri/src/appflowy_app/App.tsx index e1678969d5..0670a73ef1 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/App.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/App.tsx @@ -16,10 +16,14 @@ function App() { name: "abc", }); - let listener = await new UserNotificationListener("", (userProfile) => { + let listener = await new UserNotificationListener({ + onUserSignIn: (userProfile) => { console.log(userProfile); + }, onProfileUpdate(userProfile) { + console.log(userProfile); + // stop listening the changes listener.stop(); - }); + }}); listener.start(); diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/editor/application/notifications/index.ts b/frontend/appflowy_tauri/src/appflowy_app/components/editor/application/notifications/index.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/editor/application/notifications/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeAction.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeAction.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeReducer.test.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeReducer.test.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeReducer.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/RemoveMeReducer.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/index.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/notifications/index.ts similarity index 100% rename from frontend/appflowy_tauri/src/appflowy_app/components/grid/index.ts rename to frontend/appflowy_tauri/src/appflowy_app/components/grid/application/notifications/index.ts diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/notifications/parser.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/notifications/parser.ts new file mode 100644 index 0000000000..dab718fc8a --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/grid/application/notifications/parser.ts @@ -0,0 +1,26 @@ +import { GridNotification } from "../../../../../services/backend"; +import { NotificationParser, OnNotificationError } from "../../../../../services/backend/notifications/parser"; + +declare type GridNotificationCallback = (ty: GridNotification, payload: Uint8Array) => void; + +export class GridNotificationParser extends NotificationParser { + constructor(params: { id?: String; callback: GridNotificationCallback; onError?: OnNotificationError }) { + super( + params.callback, + (ty) => { + let notification = GridNotification[ty]; + if (isGridNotification(notification)) { + return GridNotification[notification]; + } else { + return GridNotification.Unknown; + } + }, + params.id, + params.onError + ); + } +} + +const isGridNotification = (notification: string): notification is keyof typeof GridNotification => { + return Object.values(GridNotification).indexOf(notification) !== -1; +}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/RemoveMeComponent.test.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/RemoveMeComponent.test.tsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/RemoveMeComponent.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/RemoveMeComponent.tsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/index.ts b/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/index.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/grid/presentation/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/index.ts b/frontend/appflowy_tauri/src/appflowy_app/components/index.ts index e69de29bb2..cb0ff5c3b5 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/index.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/parser.ts b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/parser.ts index d3adcc88fc..d56b9bf291 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/parser.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/parser.ts @@ -1,13 +1,12 @@ -import { Result } from "ts-results/result"; -import { UserNotification, FlowyError } from "../../../../../services/backend"; +import { UserNotification } from "../../../../../services/backend"; import { NotificationParser, OnNotificationError } from "../../../../../services/backend/notifications/parser"; declare type UserNotificationCallback = (ty: UserNotification, payload: Uint8Array) => void; export class UserNotificationParser extends NotificationParser { - constructor(callback: UserNotificationCallback, id?: String, onError?: OnNotificationError) { + constructor(params: { id?: String; callback: UserNotificationCallback; onError?: OnNotificationError }) { super( - callback, + params.callback, (ty) => { let notification = UserNotification[ty]; if (isUserNotification(notification)) { @@ -16,8 +15,8 @@ export class UserNotificationParser extends NotificationParser return UserNotification.Unknown; } }, - id, - onError + params.id, + params.onError ); } } diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts index a0ba2256d6..cae521b595 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/user/application/notifications/user_listener.ts @@ -3,32 +3,40 @@ import { AFNotificationListener, OnNotificationError } from "../../../../../serv import { UserNotificationParser } from "./parser"; declare type OnUserProfileUpdate = (userProfile: UserProfilePB) => void; +declare type OnUserSignIn = (userProfile: UserProfilePB) => void; export class UserNotificationListener extends AFNotificationListener { onProfileUpdate?: OnUserProfileUpdate; + onUserSignIn?: OnUserSignIn; - constructor(userId?: String, onProfileUpdate?: OnUserProfileUpdate, onError?: OnNotificationError) { - let parser = new UserNotificationParser( - (notification, payload) => { + constructor(params: { + userId?: String; + onUserSignIn?: OnUserSignIn; + onProfileUpdate?: OnUserProfileUpdate; + onError?: OnNotificationError; + }) { + let parser = new UserNotificationParser({ + callback: (notification, payload) => { switch (notification) { case UserNotification.UserAuthChanged: break; case UserNotification.UserProfileUpdated: + this.onProfileUpdate?.(UserProfilePB.deserializeBinary(payload)); break; case UserNotification.UserUnauthorized: break; case UserNotification.UserSignIn: - let userProfile = UserProfilePB.deserializeBinary(payload); - this.onProfileUpdate?.(userProfile); + this.onUserSignIn?.(UserProfilePB.deserializeBinary(payload)); break; default: break; } }, - userId, - onError - ); + id: params.userId, + onError: params.onError, + }); super(parser); - this.onProfileUpdate = onProfileUpdate; + this.onProfileUpdate = params.onProfileUpdate; + this.onUserSignIn = params.onUserSignIn; } } diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/user/presentation/index.ts b/frontend/appflowy_tauri/src/appflowy_app/components/user/presentation/index.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/components/user/presentation/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeAction.ts b/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeAction.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeReducer.test.ts b/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeReducer.test.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeReducer.ts b/frontend/appflowy_tauri/src/appflowy_app/home/application/RemoveMeReducer.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/index.ts b/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/index.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/parser.ts b/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/parser.ts new file mode 100644 index 0000000000..dfe6951a81 --- /dev/null +++ b/frontend/appflowy_tauri/src/appflowy_app/home/application/notifications/parser.ts @@ -0,0 +1,26 @@ +import { FolderNotification } from "../../../../services/backend"; +import { NotificationParser, OnNotificationError } from "../../../../services/backend/notifications/parser"; + +declare type FolderNotificationCallback = (ty: FolderNotification, payload: Uint8Array) => void; + +export class FolderNotificationParser extends NotificationParser { + constructor(params: { id?: String; callback: FolderNotificationCallback; onError?: OnNotificationError }) { + super( + params.callback, + (ty) => { + let notification = FolderNotification[ty]; + if (isFolderNotification(notification)) { + return FolderNotification[notification]; + } else { + return FolderNotification.Unknown; + } + }, + params.id, + params.onError + ); + } +} + +const isFolderNotification = (notification: string): notification is keyof typeof FolderNotification => { + return Object.values(FolderNotification).indexOf(notification) !== -1; +}; diff --git a/frontend/rust-lib/flowy-grid/src/event_map.rs b/frontend/rust-lib/flowy-grid/src/event_map.rs index e760fdd26d..056c27e80e 100644 --- a/frontend/rust-lib/flowy-grid/src/event_map.rs +++ b/frontend/rust-lib/flowy-grid/src/event_map.rs @@ -162,8 +162,8 @@ pub enum GridEvent { /// [UpdateSelectOption] event is used to update a FieldTypeOptionData whose field_type is /// FieldType::SingleSelect or FieldType::MultiSelect. /// - /// This event may trigger the GridDartNotification::DidUpdateCell event. - /// For example, GridDartNotification::DidUpdateCell will be triggered if the [SelectOptionChangesetPB] + /// This event may trigger the GridNotification::DidUpdateCell event. + /// For example, GridNotification::DidUpdateCell will be triggered if the [SelectOptionChangesetPB] /// carries a change that updates the name of the option. #[event(input = "SelectOptionChangesetPB")] UpdateSelectOption = 32, diff --git a/frontend/rust-lib/flowy-grid/src/notification.rs b/frontend/rust-lib/flowy-grid/src/notification.rs index 98a9ee3baa..3954f03985 100644 --- a/frontend/rust-lib/flowy-grid/src/notification.rs +++ b/frontend/rust-lib/flowy-grid/src/notification.rs @@ -3,7 +3,7 @@ use flowy_notification::NotificationBuilder; const OBSERVABLE_CATEGORY: &str = "Grid"; #[derive(ProtoBuf_Enum, Debug)] -pub enum GridDartNotification { +pub enum GridNotification { Unknown = 0, DidCreateBlock = 11, DidUpdateGridViewRows = 20, @@ -22,19 +22,19 @@ pub enum GridDartNotification { DidUpdateGridSetting = 70, } -impl std::default::Default for GridDartNotification { +impl std::default::Default for GridNotification { fn default() -> Self { - GridDartNotification::Unknown + GridNotification::Unknown } } -impl std::convert::From for i32 { - fn from(notification: GridDartNotification) -> Self { +impl std::convert::From for i32 { + fn from(notification: GridNotification) -> Self { notification as i32 } } #[tracing::instrument(level = "trace")] -pub fn send_notification(id: &str, ty: GridDartNotification) -> NotificationBuilder { +pub fn send_notification(id: &str, ty: GridNotification) -> NotificationBuilder { NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY) } diff --git a/frontend/rust-lib/flowy-grid/src/services/block_manager.rs b/frontend/rust-lib/flowy-grid/src/services/block_manager.rs index e3f05352a3..06f24dab2a 100644 --- a/frontend/rust-lib/flowy-grid/src/services/block_manager.rs +++ b/frontend/rust-lib/flowy-grid/src/services/block_manager.rs @@ -1,6 +1,6 @@ use crate::entities::{CellChangesetPB, InsertedRowPB, UpdatedRowPB}; use crate::manager::GridUser; -use crate::notification::{send_notification, GridDartNotification}; +use crate::notification::{send_notification, GridNotification}; use crate::services::block_editor::{GridBlockRevisionEditor, GridBlockRevisionMergeable}; use crate::services::persistence::block_index::BlockIndexCache; use crate::services::persistence::rev_sqlite::{ @@ -262,7 +262,7 @@ impl GridBlockManager { async fn notify_did_update_cell(&self, changeset: CellChangesetPB) -> FlowyResult<()> { let id = format!("{}:{}", changeset.row_id, changeset.field_id); - send_notification(&id, GridDartNotification::DidUpdateCell).send(); + send_notification(&id, GridNotification::DidUpdateCell).send(); Ok(()) } } diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs index 5d59058939..8b5144daae 100644 --- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs +++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs @@ -1,7 +1,7 @@ use crate::entities::CellPathParams; use crate::entities::*; use crate::manager::GridUser; -use crate::notification::{send_notification, GridDartNotification}; +use crate::notification::{send_notification, GridNotification}; use crate::services::block_manager::GridBlockManager; use crate::services::cell::{ apply_cell_data_changeset, decode_type_cell_data, stringify_cell_data, AnyTypeCache, AtomicCellDataCache, @@ -112,7 +112,7 @@ impl GridRevisionEditor { self.view_manager.close(&self.grid_id).await; } - /// Save the type-option data to disk and send a `GridDartNotification::DidUpdateField` notification + /// Save the type-option data to disk and send a `GridNotification::DidUpdateField` notification /// to dart side. /// /// It will do nothing if the passed-in type_option_data is empty @@ -852,7 +852,7 @@ impl GridRevisionEditor { let notified_changeset = GridFieldChangesetPB::update(&self.grid_id, vec![updated_field.clone()]); self.notify_did_update_grid(notified_changeset).await?; - send_notification(field_id, GridDartNotification::DidUpdateField) + send_notification(field_id, GridNotification::DidUpdateField) .payload(updated_field) .send(); } @@ -861,7 +861,7 @@ impl GridRevisionEditor { } async fn notify_did_update_grid(&self, changeset: GridFieldChangesetPB) -> FlowyResult<()> { - send_notification(&self.grid_id, GridDartNotification::DidUpdateGridFields) + send_notification(&self.grid_id, GridNotification::DidUpdateGridFields) .payload(changeset) .send(); Ok(()) diff --git a/frontend/rust-lib/flowy-grid/src/services/view_editor/changed_notifier.rs b/frontend/rust-lib/flowy-grid/src/services/view_editor/changed_notifier.rs index 0f36668396..55de2b5b47 100644 --- a/frontend/rust-lib/flowy-grid/src/services/view_editor/changed_notifier.rs +++ b/frontend/rust-lib/flowy-grid/src/services/view_editor/changed_notifier.rs @@ -1,5 +1,5 @@ use crate::entities::{GridRowsVisibilityChangesetPB, ReorderAllRowsPB, ReorderSingleRowPB}; -use crate::notification::{send_notification, GridDartNotification}; +use crate::notification::{send_notification, GridNotification}; use crate::services::filter::FilterResultNotification; use crate::services::sort::{ReorderAllRowsResult, ReorderSingleRowResult}; use async_stream::stream; @@ -37,18 +37,15 @@ impl GridViewChangedReceiverRunner { invisible_rows: notification.invisible_rows, }; - send_notification( - &changeset.view_id, - GridDartNotification::DidUpdateGridViewRowsVisibility, - ) - .payload(changeset) - .send() + send_notification(&changeset.view_id, GridNotification::DidUpdateGridViewRowsVisibility) + .payload(changeset) + .send() } GridViewChanged::ReorderAllRowsNotification(notification) => { let row_orders = ReorderAllRowsPB { row_orders: notification.row_orders, }; - send_notification(¬ification.view_id, GridDartNotification::DidReorderRows) + send_notification(¬ification.view_id, GridNotification::DidReorderRows) .payload(row_orders) .send() } @@ -58,7 +55,7 @@ impl GridViewChangedReceiverRunner { old_index: notification.old_index as i32, new_index: notification.new_index as i32, }; - send_notification(¬ification.view_id, GridDartNotification::DidReorderSingleRow) + send_notification(¬ification.view_id, GridNotification::DidReorderSingleRow) .payload(reorder_row) .send() } diff --git a/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs b/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs index 19c433772d..d5cda0cf44 100644 --- a/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs +++ b/frontend/rust-lib/flowy-grid/src/services/view_editor/editor.rs @@ -1,5 +1,5 @@ use crate::entities::*; -use crate::notification::{send_notification, GridDartNotification}; +use crate::notification::{send_notification, GridNotification}; use crate::services::block_manager::GridBlockEvent; use crate::services::cell::{AtomicCellDataCache, TypeCellData}; use crate::services::field::{RowSingleCellData, TypeOptionCellDataHandler}; @@ -184,7 +184,7 @@ impl GridViewRevisionEditor { } }; - send_notification(&self.view_id, GridDartNotification::DidUpdateGridViewRows) + send_notification(&self.view_id, GridNotification::DidUpdateGridViewRows) .payload(changeset) .send(); } @@ -616,7 +616,7 @@ impl GridViewRevisionEditor { debug_assert!(!changeset.is_empty()); if !changeset.is_empty() { - send_notification(&changeset.view_id, GridDartNotification::DidGroupByNewField) + send_notification(&changeset.view_id, GridNotification::DidGroupByNewField) .payload(changeset) .send(); } @@ -630,33 +630,33 @@ impl GridViewRevisionEditor { async fn notify_did_update_setting(&self) { let setting = self.get_view_setting().await; - send_notification(&self.view_id, GridDartNotification::DidUpdateGridSetting) + send_notification(&self.view_id, GridNotification::DidUpdateGridSetting) .payload(setting) .send(); } pub async fn notify_did_update_group_rows(&self, payload: GroupRowsNotificationPB) { - send_notification(&payload.group_id, GridDartNotification::DidUpdateGroup) + send_notification(&payload.group_id, GridNotification::DidUpdateGroup) .payload(payload) .send(); } pub async fn notify_did_update_filter(&self, notification: FilterChangesetNotificationPB) { - send_notification(¬ification.view_id, GridDartNotification::DidUpdateFilter) + send_notification(¬ification.view_id, GridNotification::DidUpdateFilter) .payload(notification) .send(); } pub async fn notify_did_update_sort(&self, notification: SortChangesetNotificationPB) { if !notification.is_empty() { - send_notification(¬ification.view_id, GridDartNotification::DidUpdateSort) + send_notification(¬ification.view_id, GridNotification::DidUpdateSort) .payload(notification) .send(); } } async fn notify_did_update_view(&self, changeset: GroupViewChangesetPB) { - send_notification(&self.view_id, GridDartNotification::DidUpdateGroupView) + send_notification(&self.view_id, GridNotification::DidUpdateGroupView) .payload(changeset) .send(); }