fix: send database notification on create row (#2926)

Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Mohammad Zolfaghari
2023-07-13 05:09:16 +03:30
committed by GitHub
parent 5b1afeb85d
commit d4a23657d7

View File

@ -216,14 +216,12 @@ impl DatabaseViewEditor {
group_id: &Option<String>, group_id: &Option<String>,
index: usize, index: usize,
) { ) {
let changes: RowsChangePB;
// Send the group notification if the current view has groups // Send the group notification if the current view has groups
match group_id.as_ref() { match group_id.as_ref() {
None => { None => {
let row = InsertedRowPB::new(RowMetaPB::from(&row_detail.meta)).with_index(index as i32); let row = InsertedRowPB::new(RowMetaPB::from(&row_detail.meta)).with_index(index as i32);
let changes = RowsChangePB::from_insert(self.view_id.clone(), row); changes = RowsChangePB::from_insert(self.view_id.clone(), row);
send_notification(&self.view_id, DatabaseNotification::DidUpdateViewRows)
.payload(changes)
.send();
}, },
Some(group_id) => { Some(group_id) => {
self self
@ -238,10 +236,16 @@ impl DatabaseViewEditor {
index: Some(index as i32), index: Some(index as i32),
is_new: true, is_new: true,
}; };
let changeset = GroupRowsNotificationPB::insert(group_id.clone(), vec![inserted_row]); let changeset =
GroupRowsNotificationPB::insert(group_id.clone(), vec![inserted_row.clone()]);
notify_did_update_group_rows(changeset).await; notify_did_update_group_rows(changeset).await;
changes = RowsChangePB::from_insert(self.view_id.clone(), inserted_row);
}, },
} }
send_notification(&self.view_id, DatabaseNotification::DidUpdateViewRows)
.payload(changes)
.send();
} }
#[tracing::instrument(level = "trace", skip_all)] #[tracing::instrument(level = "trace", skip_all)]