mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: update last modified on icon change (#4798)
* fix: update last modified on icon change * fix: clippy * chore: clean code * chore: reorder operations * chore: fix import after merge
This commit is contained in:
parent
8042be6575
commit
ec46a30e6c
frontend
appflowy_flutter/integration_test/desktop/database
rust-lib/flowy-database2/src
@ -1,9 +1,10 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:appflowy/plugins/database/widgets/row/row_banner.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-database2/field_entities.pbenum.dart';
|
||||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/text.dart';
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
@ -379,7 +379,9 @@ pub(crate) async fn update_row_meta_handler(
|
|||||||
let params: UpdateRowMetaParams = data.into_inner().try_into()?;
|
let params: UpdateRowMetaParams = data.into_inner().try_into()?;
|
||||||
let database_editor = manager.get_database_with_view_id(¶ms.view_id).await?;
|
let database_editor = manager.get_database_with_view_id(¶ms.view_id).await?;
|
||||||
let row_id = RowId::from(params.id.clone());
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ use lib_dispatch::prelude::af_spawn;
|
|||||||
use lib_infra::box_any::BoxAny;
|
use lib_infra::box_any::BoxAny;
|
||||||
use lib_infra::future::{to_fut, Fut, FutureResult};
|
use lib_infra::future::{to_fut, Fut, FutureResult};
|
||||||
use lib_infra::priority_task::TaskDispatcher;
|
use lib_infra::priority_task::TaskDispatcher;
|
||||||
|
use lib_infra::util::timestamp;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{broadcast, RwLock};
|
use tokio::sync::{broadcast, RwLock};
|
||||||
@ -710,6 +711,11 @@ impl DatabaseEditor {
|
|||||||
send_notification(row_id.as_str(), DatabaseNotification::DidUpdateRowMeta)
|
send_notification(row_id.as_str(), DatabaseNotification::DidUpdateRowMeta)
|
||||||
.payload(RowMetaPB::from(&row_detail))
|
.payload(RowMetaPB::from(&row_detail))
|
||||||
.send();
|
.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
|
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.
|
/// Update a cell in the database.
|
||||||
/// This will notify all views that the cell has been updated.
|
/// This will notify all views that the cell has been updated.
|
||||||
pub async fn update_cell(
|
pub async fn update_cell(
|
||||||
@ -853,7 +879,7 @@ impl DatabaseEditor {
|
|||||||
if let Some(new_row_detail) = option_row {
|
if let Some(new_row_detail) = option_row {
|
||||||
for view in self.database_views.editors().await {
|
for view in self.database_views.editors().await {
|
||||||
view
|
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;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ impl DatabaseViewEditor {
|
|||||||
&self,
|
&self,
|
||||||
old_row: &Option<RowDetail>,
|
old_row: &Option<RowDetail>,
|
||||||
row_detail: &RowDetail,
|
row_detail: &RowDetail,
|
||||||
field_id: String,
|
field_id: Option<String>,
|
||||||
) {
|
) {
|
||||||
if let Some(controller) = self.group_controller.write().await.as_mut() {
|
if let Some(controller) = self.group_controller.write().await.as_mut() {
|
||||||
let field = self.delegate.get_field(controller.get_grouping_field_id());
|
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
|
// 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.
|
||||||
self
|
if let Some(field_id) = field_id {
|
||||||
.gen_did_update_row_view_tasks(row_detail.row.id.clone(), field_id)
|
self
|
||||||
.await;
|
.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<Arc<RowDetail>>) {
|
pub async fn v_filter_rows(&self, row_details: &mut Vec<Arc<RowDetail>>) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user