chore: notification parser (#1745)

This commit is contained in:
Nathan.fooo 2023-01-27 22:57:23 +08:00 committed by GitHub
parent 7a750e5255
commit 4fb2afe82e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 143 additions and 78 deletions

View File

@ -10,22 +10,22 @@ import 'notification_helper.dart';
// GridPB // GridPB
typedef GridNotificationCallback = void Function( typedef GridNotificationCallback = void Function(
GridDartNotification, Either<Uint8List, FlowyError>); GridNotification, Either<Uint8List, FlowyError>);
class GridNotificationParser class GridNotificationParser
extends NotificationParser<GridDartNotification, FlowyError> { extends NotificationParser<GridNotification, FlowyError> {
GridNotificationParser( GridNotificationParser(
{String? id, required GridNotificationCallback callback}) {String? id, required GridNotificationCallback callback})
: super( : super(
id: id, id: id,
callback: callback, callback: callback,
tyParser: (ty) => GridDartNotification.valueOf(ty), tyParser: (ty) => GridNotification.valueOf(ty),
errorParser: (bytes) => FlowyError.fromBuffer(bytes), errorParser: (bytes) => FlowyError.fromBuffer(bytes),
); );
} }
typedef GridNotificationHandler = Function( typedef GridNotificationHandler = Function(
GridDartNotification ty, Either<Uint8List, FlowyError> result); GridNotification ty, Either<Uint8List, FlowyError> result);
class GridNotificationListener { class GridNotificationListener {
StreamSubscription<SubscribeObject>? _subscription; StreamSubscription<SubscribeObject>? _subscription;

View File

@ -32,18 +32,18 @@ class BoardListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateGroupView: case GridNotification.DidUpdateGroupView:
result.fold( result.fold(
(payload) => _groupUpdateNotifier?.value = (payload) => _groupUpdateNotifier?.value =
left(GroupViewChangesetPB.fromBuffer(payload)), left(GroupViewChangesetPB.fromBuffer(payload)),
(error) => _groupUpdateNotifier?.value = right(error), (error) => _groupUpdateNotifier?.value = right(error),
); );
break; break;
case GridDartNotification.DidGroupByNewField: case GridNotification.DidGroupByNewField:
result.fold( result.fold(
(payload) => _groupByNewFieldNotifier?.value = (payload) => _groupByNewFieldNotifier?.value =
left(GroupViewChangesetPB.fromBuffer(payload).newGroups), left(GroupViewChangesetPB.fromBuffer(payload).newGroups),

View File

@ -27,11 +27,11 @@ class GroupListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateGroup: case GridNotification.DidUpdateGroup:
result.fold( result.fold(
(payload) => _groupNotifier?.value = (payload) => _groupNotifier?.value =
left(GroupRowsNotificationPB.fromBuffer(payload)), left(GroupRowsNotificationPB.fromBuffer(payload)),

View File

@ -22,9 +22,9 @@ class CellListener {
objectId: "$rowId:$fieldId", handler: _handler); objectId: "$rowId:$fieldId", handler: _handler);
} }
void _handler(GridDartNotification ty, Either<Uint8List, FlowyError> result) { void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateCell: case GridNotification.DidUpdateCell:
result.fold( result.fold(
(payload) => _updateCellNotifier?.value = left(unit), (payload) => _updateCellNotifier?.value = left(unit),
(error) => _updateCellNotifier?.value = right(error), (error) => _updateCellNotifier?.value = right(error),

View File

@ -27,11 +27,11 @@ class SingleFieldListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateField: case GridNotification.DidUpdateField:
result.fold( result.fold(
(payload) => (payload) =>
_updateFieldNotifier?.value = left(FieldPB.fromBuffer(payload)), _updateFieldNotifier?.value = left(FieldPB.fromBuffer(payload)),

View File

@ -25,9 +25,9 @@ class GridFieldsListener {
); );
} }
void _handler(GridDartNotification ty, Either<Uint8List, FlowyError> result) { void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateGridFields: case GridNotification.DidUpdateGridFields:
result.fold( result.fold(
(payload) => updateFieldsNotifier?.value = (payload) => updateFieldsNotifier?.value =
left(GridFieldChangesetPB.fromBuffer(payload)), left(GridFieldChangesetPB.fromBuffer(payload)),

View File

@ -30,11 +30,11 @@ class FiltersListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateFilter: case GridNotification.DidUpdateFilter:
result.fold( result.fold(
(payload) => _filterNotifier?.value = (payload) => _filterNotifier?.value =
left(FilterChangesetNotificationPB.fromBuffer(payload)), left(FilterChangesetNotificationPB.fromBuffer(payload)),
@ -100,11 +100,11 @@ class FilterListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateFilter: case GridNotification.DidUpdateFilter:
result.fold( result.fold(
(payload) => handleChangeset( (payload) => handleChangeset(
FilterChangesetNotificationPB.fromBuffer(payload)), FilterChangesetNotificationPB.fromBuffer(payload)),

View File

@ -23,9 +23,9 @@ class RowListener {
_listener = GridNotificationListener(objectId: rowId, handler: _handler); _listener = GridNotificationListener(objectId: rowId, handler: _handler);
} }
void _handler(GridDartNotification ty, Either<Uint8List, FlowyError> result) { void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateRow: case GridNotification.DidUpdateRow:
result.fold( result.fold(
(payload) => (payload) =>
updateRowNotifier?.value = left(RowPB.fromBuffer(payload)), updateRowNotifier?.value = left(RowPB.fromBuffer(payload)),

View File

@ -24,9 +24,9 @@ class SettingListener {
_listener = GridNotificationListener(objectId: gridId, handler: _handler); _listener = GridNotificationListener(objectId: gridId, handler: _handler);
} }
void _handler(GridDartNotification ty, Either<Uint8List, FlowyError> result) { void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateGridSetting: case GridNotification.DidUpdateGridSetting:
result.fold( result.fold(
(payload) => _updateSettingNotifier?.value = left( (payload) => _updateSettingNotifier?.value = left(
GridSettingPB.fromBuffer(payload), GridSettingPB.fromBuffer(payload),

View File

@ -27,11 +27,11 @@ class SortsListener {
} }
void _handler( void _handler(
GridDartNotification ty, GridNotification ty,
Either<Uint8List, FlowyError> result, Either<Uint8List, FlowyError> result,
) { ) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateSort: case GridNotification.DidUpdateSort:
result.fold( result.fold(
(payload) => _notifier?.value = (payload) => _notifier?.value =
left(SortChangesetNotificationPB.fromBuffer(payload)), left(SortChangesetNotificationPB.fromBuffer(payload)),

View File

@ -51,30 +51,30 @@ class GridViewListener {
_reorderSingleRow?.addPublishListener(onReorderSingleRow); _reorderSingleRow?.addPublishListener(onReorderSingleRow);
} }
void _handler(GridDartNotification ty, Either<Uint8List, FlowyError> result) { void _handler(GridNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) { switch (ty) {
case GridDartNotification.DidUpdateGridViewRowsVisibility: case GridNotification.DidUpdateGridViewRowsVisibility:
result.fold( result.fold(
(payload) => _rowsVisibility?.value = (payload) => _rowsVisibility?.value =
left(GridRowsVisibilityChangesetPB.fromBuffer(payload)), left(GridRowsVisibilityChangesetPB.fromBuffer(payload)),
(error) => _rowsVisibility?.value = right(error), (error) => _rowsVisibility?.value = right(error),
); );
break; break;
case GridDartNotification.DidUpdateGridViewRows: case GridNotification.DidUpdateGridViewRows:
result.fold( result.fold(
(payload) => _rowsNotifier?.value = (payload) => _rowsNotifier?.value =
left(GridViewRowsChangesetPB.fromBuffer(payload)), left(GridViewRowsChangesetPB.fromBuffer(payload)),
(error) => _rowsNotifier?.value = right(error), (error) => _rowsNotifier?.value = right(error),
); );
break; break;
case GridDartNotification.DidReorderRows: case GridNotification.DidReorderRows:
result.fold( result.fold(
(payload) => _reorderAllRows?.value = (payload) => _reorderAllRows?.value =
left(ReorderAllRowsPB.fromBuffer(payload).rowOrders), left(ReorderAllRowsPB.fromBuffer(payload).rowOrders),
(error) => _reorderAllRows?.value = right(error), (error) => _reorderAllRows?.value = right(error),
); );
break; break;
case GridDartNotification.DidReorderSingleRow: case GridNotification.DidReorderSingleRow:
result.fold( result.fold(
(payload) => _reorderSingleRow?.value = (payload) => _reorderSingleRow?.value =
left(ReorderSingleRowPB.fromBuffer(payload)), left(ReorderSingleRowPB.fromBuffer(payload)),

View File

@ -16,10 +16,14 @@ function App() {
name: "abc", name: "abc",
}); });
let listener = await new UserNotificationListener("", (userProfile) => { let listener = await new UserNotificationListener({
onUserSignIn: (userProfile) => {
console.log(userProfile); console.log(userProfile);
}, onProfileUpdate(userProfile) {
console.log(userProfile);
// stop listening the changes
listener.stop(); listener.stop();
}); }});
listener.start(); listener.start();

View File

@ -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<GridNotification> {
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;
};

View File

@ -1,13 +1,12 @@
import { Result } from "ts-results/result"; import { UserNotification } from "../../../../../services/backend";
import { UserNotification, FlowyError } from "../../../../../services/backend";
import { NotificationParser, OnNotificationError } from "../../../../../services/backend/notifications/parser"; import { NotificationParser, OnNotificationError } from "../../../../../services/backend/notifications/parser";
declare type UserNotificationCallback = (ty: UserNotification, payload: Uint8Array) => void; declare type UserNotificationCallback = (ty: UserNotification, payload: Uint8Array) => void;
export class UserNotificationParser extends NotificationParser<UserNotification> { export class UserNotificationParser extends NotificationParser<UserNotification> {
constructor(callback: UserNotificationCallback, id?: String, onError?: OnNotificationError) { constructor(params: { id?: String; callback: UserNotificationCallback; onError?: OnNotificationError }) {
super( super(
callback, params.callback,
(ty) => { (ty) => {
let notification = UserNotification[ty]; let notification = UserNotification[ty];
if (isUserNotification(notification)) { if (isUserNotification(notification)) {
@ -16,8 +15,8 @@ export class UserNotificationParser extends NotificationParser<UserNotification>
return UserNotification.Unknown; return UserNotification.Unknown;
} }
}, },
id, params.id,
onError params.onError
); );
} }
} }

View File

@ -3,32 +3,40 @@ import { AFNotificationListener, OnNotificationError } from "../../../../../serv
import { UserNotificationParser } from "./parser"; import { UserNotificationParser } from "./parser";
declare type OnUserProfileUpdate = (userProfile: UserProfilePB) => void; declare type OnUserProfileUpdate = (userProfile: UserProfilePB) => void;
declare type OnUserSignIn = (userProfile: UserProfilePB) => void;
export class UserNotificationListener extends AFNotificationListener<UserNotification> { export class UserNotificationListener extends AFNotificationListener<UserNotification> {
onProfileUpdate?: OnUserProfileUpdate; onProfileUpdate?: OnUserProfileUpdate;
onUserSignIn?: OnUserSignIn;
constructor(userId?: String, onProfileUpdate?: OnUserProfileUpdate, onError?: OnNotificationError) { constructor(params: {
let parser = new UserNotificationParser( userId?: String;
(notification, payload) => { onUserSignIn?: OnUserSignIn;
onProfileUpdate?: OnUserProfileUpdate;
onError?: OnNotificationError;
}) {
let parser = new UserNotificationParser({
callback: (notification, payload) => {
switch (notification) { switch (notification) {
case UserNotification.UserAuthChanged: case UserNotification.UserAuthChanged:
break; break;
case UserNotification.UserProfileUpdated: case UserNotification.UserProfileUpdated:
this.onProfileUpdate?.(UserProfilePB.deserializeBinary(payload));
break; break;
case UserNotification.UserUnauthorized: case UserNotification.UserUnauthorized:
break; break;
case UserNotification.UserSignIn: case UserNotification.UserSignIn:
let userProfile = UserProfilePB.deserializeBinary(payload); this.onUserSignIn?.(UserProfilePB.deserializeBinary(payload));
this.onProfileUpdate?.(userProfile);
break; break;
default: default:
break; break;
} }
}, },
userId, id: params.userId,
onError onError: params.onError,
); });
super(parser); super(parser);
this.onProfileUpdate = onProfileUpdate; this.onProfileUpdate = params.onProfileUpdate;
this.onUserSignIn = params.onUserSignIn;
} }
} }

View File

@ -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<FolderNotification> {
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;
};

View File

@ -162,8 +162,8 @@ pub enum GridEvent {
/// [UpdateSelectOption] event is used to update a FieldTypeOptionData whose field_type is /// [UpdateSelectOption] event is used to update a FieldTypeOptionData whose field_type is
/// FieldType::SingleSelect or FieldType::MultiSelect. /// FieldType::SingleSelect or FieldType::MultiSelect.
/// ///
/// This event may trigger the GridDartNotification::DidUpdateCell event. /// This event may trigger the GridNotification::DidUpdateCell event.
/// For example, GridDartNotification::DidUpdateCell will be triggered if the [SelectOptionChangesetPB] /// For example, GridNotification::DidUpdateCell will be triggered if the [SelectOptionChangesetPB]
/// carries a change that updates the name of the option. /// carries a change that updates the name of the option.
#[event(input = "SelectOptionChangesetPB")] #[event(input = "SelectOptionChangesetPB")]
UpdateSelectOption = 32, UpdateSelectOption = 32,

View File

@ -3,7 +3,7 @@ use flowy_notification::NotificationBuilder;
const OBSERVABLE_CATEGORY: &str = "Grid"; const OBSERVABLE_CATEGORY: &str = "Grid";
#[derive(ProtoBuf_Enum, Debug)] #[derive(ProtoBuf_Enum, Debug)]
pub enum GridDartNotification { pub enum GridNotification {
Unknown = 0, Unknown = 0,
DidCreateBlock = 11, DidCreateBlock = 11,
DidUpdateGridViewRows = 20, DidUpdateGridViewRows = 20,
@ -22,19 +22,19 @@ pub enum GridDartNotification {
DidUpdateGridSetting = 70, DidUpdateGridSetting = 70,
} }
impl std::default::Default for GridDartNotification { impl std::default::Default for GridNotification {
fn default() -> Self { fn default() -> Self {
GridDartNotification::Unknown GridNotification::Unknown
} }
} }
impl std::convert::From<GridDartNotification> for i32 { impl std::convert::From<GridNotification> for i32 {
fn from(notification: GridDartNotification) -> Self { fn from(notification: GridNotification) -> Self {
notification as i32 notification as i32
} }
} }
#[tracing::instrument(level = "trace")] #[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) NotificationBuilder::new(id, ty, OBSERVABLE_CATEGORY)
} }

View File

@ -1,6 +1,6 @@
use crate::entities::{CellChangesetPB, InsertedRowPB, UpdatedRowPB}; use crate::entities::{CellChangesetPB, InsertedRowPB, UpdatedRowPB};
use crate::manager::GridUser; 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::block_editor::{GridBlockRevisionEditor, GridBlockRevisionMergeable};
use crate::services::persistence::block_index::BlockIndexCache; use crate::services::persistence::block_index::BlockIndexCache;
use crate::services::persistence::rev_sqlite::{ use crate::services::persistence::rev_sqlite::{
@ -262,7 +262,7 @@ impl GridBlockManager {
async fn notify_did_update_cell(&self, changeset: CellChangesetPB) -> FlowyResult<()> { async fn notify_did_update_cell(&self, changeset: CellChangesetPB) -> FlowyResult<()> {
let id = format!("{}:{}", changeset.row_id, changeset.field_id); let id = format!("{}:{}", changeset.row_id, changeset.field_id);
send_notification(&id, GridDartNotification::DidUpdateCell).send(); send_notification(&id, GridNotification::DidUpdateCell).send();
Ok(()) Ok(())
} }
} }

View File

@ -1,7 +1,7 @@
use crate::entities::CellPathParams; use crate::entities::CellPathParams;
use crate::entities::*; use crate::entities::*;
use crate::manager::GridUser; 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::block_manager::GridBlockManager;
use crate::services::cell::{ use crate::services::cell::{
apply_cell_data_changeset, decode_type_cell_data, stringify_cell_data, AnyTypeCache, AtomicCellDataCache, 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; 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. /// to dart side.
/// ///
/// It will do nothing if the passed-in type_option_data is empty /// 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()]); let notified_changeset = GridFieldChangesetPB::update(&self.grid_id, vec![updated_field.clone()]);
self.notify_did_update_grid(notified_changeset).await?; self.notify_did_update_grid(notified_changeset).await?;
send_notification(field_id, GridDartNotification::DidUpdateField) send_notification(field_id, GridNotification::DidUpdateField)
.payload(updated_field) .payload(updated_field)
.send(); .send();
} }
@ -861,7 +861,7 @@ impl GridRevisionEditor {
} }
async fn notify_did_update_grid(&self, changeset: GridFieldChangesetPB) -> FlowyResult<()> { 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) .payload(changeset)
.send(); .send();
Ok(()) Ok(())

View File

@ -1,5 +1,5 @@
use crate::entities::{GridRowsVisibilityChangesetPB, ReorderAllRowsPB, ReorderSingleRowPB}; 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::filter::FilterResultNotification;
use crate::services::sort::{ReorderAllRowsResult, ReorderSingleRowResult}; use crate::services::sort::{ReorderAllRowsResult, ReorderSingleRowResult};
use async_stream::stream; use async_stream::stream;
@ -37,18 +37,15 @@ impl GridViewChangedReceiverRunner {
invisible_rows: notification.invisible_rows, invisible_rows: notification.invisible_rows,
}; };
send_notification( send_notification(&changeset.view_id, GridNotification::DidUpdateGridViewRowsVisibility)
&changeset.view_id, .payload(changeset)
GridDartNotification::DidUpdateGridViewRowsVisibility, .send()
)
.payload(changeset)
.send()
} }
GridViewChanged::ReorderAllRowsNotification(notification) => { GridViewChanged::ReorderAllRowsNotification(notification) => {
let row_orders = ReorderAllRowsPB { let row_orders = ReorderAllRowsPB {
row_orders: notification.row_orders, row_orders: notification.row_orders,
}; };
send_notification(&notification.view_id, GridDartNotification::DidReorderRows) send_notification(&notification.view_id, GridNotification::DidReorderRows)
.payload(row_orders) .payload(row_orders)
.send() .send()
} }
@ -58,7 +55,7 @@ impl GridViewChangedReceiverRunner {
old_index: notification.old_index as i32, old_index: notification.old_index as i32,
new_index: notification.new_index as i32, new_index: notification.new_index as i32,
}; };
send_notification(&notification.view_id, GridDartNotification::DidReorderSingleRow) send_notification(&notification.view_id, GridNotification::DidReorderSingleRow)
.payload(reorder_row) .payload(reorder_row)
.send() .send()
} }

View File

@ -1,5 +1,5 @@
use crate::entities::*; use crate::entities::*;
use crate::notification::{send_notification, GridDartNotification}; use crate::notification::{send_notification, GridNotification};
use crate::services::block_manager::GridBlockEvent; use crate::services::block_manager::GridBlockEvent;
use crate::services::cell::{AtomicCellDataCache, TypeCellData}; use crate::services::cell::{AtomicCellDataCache, TypeCellData};
use crate::services::field::{RowSingleCellData, TypeOptionCellDataHandler}; 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) .payload(changeset)
.send(); .send();
} }
@ -616,7 +616,7 @@ impl GridViewRevisionEditor {
debug_assert!(!changeset.is_empty()); debug_assert!(!changeset.is_empty());
if !changeset.is_empty() { if !changeset.is_empty() {
send_notification(&changeset.view_id, GridDartNotification::DidGroupByNewField) send_notification(&changeset.view_id, GridNotification::DidGroupByNewField)
.payload(changeset) .payload(changeset)
.send(); .send();
} }
@ -630,33 +630,33 @@ impl GridViewRevisionEditor {
async fn notify_did_update_setting(&self) { async fn notify_did_update_setting(&self) {
let setting = self.get_view_setting().await; let setting = self.get_view_setting().await;
send_notification(&self.view_id, GridDartNotification::DidUpdateGridSetting) send_notification(&self.view_id, GridNotification::DidUpdateGridSetting)
.payload(setting) .payload(setting)
.send(); .send();
} }
pub async fn notify_did_update_group_rows(&self, payload: GroupRowsNotificationPB) { 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) .payload(payload)
.send(); .send();
} }
pub async fn notify_did_update_filter(&self, notification: FilterChangesetNotificationPB) { pub async fn notify_did_update_filter(&self, notification: FilterChangesetNotificationPB) {
send_notification(&notification.view_id, GridDartNotification::DidUpdateFilter) send_notification(&notification.view_id, GridNotification::DidUpdateFilter)
.payload(notification) .payload(notification)
.send(); .send();
} }
pub async fn notify_did_update_sort(&self, notification: SortChangesetNotificationPB) { pub async fn notify_did_update_sort(&self, notification: SortChangesetNotificationPB) {
if !notification.is_empty() { if !notification.is_empty() {
send_notification(&notification.view_id, GridDartNotification::DidUpdateSort) send_notification(&notification.view_id, GridNotification::DidUpdateSort)
.payload(notification) .payload(notification)
.send(); .send();
} }
} }
async fn notify_did_update_view(&self, changeset: GroupViewChangesetPB) { 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) .payload(changeset)
.send(); .send();
} }