diff --git a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart index 23dabda97c..c1d9e03fc6 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/database/database_row_page_test.dart @@ -1,9 +1,10 @@ +import 'package:flutter/material.dart'; + import 'package:appflowy/plugins/database/widgets/row/row_banner.dart'; import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; diff --git a/frontend/rust-lib/flowy-database2/src/event_handler.rs b/frontend/rust-lib/flowy-database2/src/event_handler.rs index 78528f255f..a60d0e9698 100644 --- a/frontend/rust-lib/flowy-database2/src/event_handler.rs +++ b/frontend/rust-lib/flowy-database2/src/event_handler.rs @@ -379,7 +379,9 @@ pub(crate) async fn update_row_meta_handler( let params: UpdateRowMetaParams = data.into_inner().try_into()?; let database_editor = manager.get_database_with_view_id(¶ms.view_id).await?; let row_id = RowId::from(params.id.clone()); - database_editor.update_row_meta(&row_id, params).await; + database_editor + .update_row_meta(&row_id.clone(), params) + .await; Ok(()) } diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs index fc1c8c5923..76c4e348e6 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs @@ -32,6 +32,7 @@ use lib_dispatch::prelude::af_spawn; use lib_infra::box_any::BoxAny; use lib_infra::future::{to_fut, Fut, FutureResult}; use lib_infra::priority_task::TaskDispatcher; +use lib_infra::util::timestamp; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::{broadcast, RwLock}; @@ -710,6 +711,11 @@ impl DatabaseEditor { send_notification(row_id.as_str(), DatabaseNotification::DidUpdateRowMeta) .payload(RowMetaPB::from(&row_detail)) .send(); + + // Update the last modified time of the row + self + .update_last_modified_time(row_detail.clone(), &changeset.view_id) + .await; } } @@ -800,6 +806,26 @@ impl DatabaseEditor { self.update_cell(view_id, row_id, field_id, new_cell).await } + async fn update_last_modified_time(&self, row_detail: RowDetail, view_id: &str) { + self + .database + .lock() + .update_row(&row_detail.row.id, |row_update| { + row_update.set_last_modified(timestamp()); + }); + + let editor = self.database_views.get_view_editor(view_id).await; + if let Ok(editor) = editor { + editor + .v_did_update_row(&Some(row_detail.clone()), &row_detail, None) + .await; + } + + self + .notify_update_row(view_id, row_detail.row.id, vec![]) + .await; + } + /// Update a cell in the database. /// This will notify all views that the cell has been updated. pub async fn update_cell( @@ -853,7 +879,7 @@ impl DatabaseEditor { if let Some(new_row_detail) = option_row { for view in self.database_views.editors().await { view - .v_did_update_row(&old_row, &new_row_detail, field_id.to_owned()) + .v_did_update_row(&old_row, &new_row_detail, Some(field_id.to_owned())) .await; } } diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs index 6cef8ccc45..a3522d8895 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs @@ -240,7 +240,7 @@ impl DatabaseViewEditor { &self, old_row: &Option, row_detail: &RowDetail, - field_id: String, + field_id: Option, ) { if let Some(controller) = self.group_controller.write().await.as_mut() { let field = self.delegate.get_field(controller.get_grouping_field_id()); @@ -283,9 +283,11 @@ impl DatabaseViewEditor { // 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. - self - .gen_did_update_row_view_tasks(row_detail.row.id.clone(), field_id) - .await; + if let Some(field_id) = field_id { + self + .gen_did_update_row_view_tasks(row_detail.row.id.clone(), field_id) + .await; + } } pub async fn v_filter_rows(&self, row_details: &mut Vec>) {