chore: refresh UI after deleting all sorts (#2573)

* chore: disable snapshot for now

* chore: notify the fronted to refresh after deleting all the sorts
This commit is contained in:
Nathan.fooo 2023-05-21 12:08:14 +08:00 committed by GitHub
parent 6c31cf9555
commit eaa1dcdeb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 25 deletions

View File

@ -80,7 +80,7 @@ class SortBackendService {
required String sortId,
required FieldType fieldType,
}) {
final deleteFilterPayload = DeleteSortPayloadPB.create()
final deleteSortPayload = DeleteSortPayloadPB.create()
..fieldId = fieldId
..sortId = sortId
..viewId = viewId
@ -88,7 +88,7 @@ class SortBackendService {
final payload = DatabaseSettingChangesetPB.create()
..viewId = viewId
..deleteSort = deleteFilterPayload;
..deleteSort = deleteSortPayload;
return DatabaseEventUpdateDatabaseSetting(payload).send().then((result) {
return result.fold(

View File

@ -99,7 +99,7 @@ checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "appflowy-integrate"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"collab",
"collab-database",
@ -575,9 +575,9 @@ dependencies = [
[[package]]
name = "bindgen"
version = "0.64.0"
version = "0.65.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
dependencies = [
"bitflags",
"cexpr",
@ -585,12 +585,13 @@ dependencies = [
"lazy_static",
"lazycell",
"peeking_take_while",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 1.0.109",
"syn 2.0.16",
]
[[package]]
@ -1020,7 +1021,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"anyhow",
"bytes",
@ -1037,7 +1038,7 @@ dependencies = [
[[package]]
name = "collab-client-ws"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"bytes",
"collab-sync",
@ -1055,7 +1056,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"anyhow",
"async-trait",
@ -1079,7 +1080,7 @@ dependencies = [
[[package]]
name = "collab-derive"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"proc-macro2",
"quote",
@ -1091,7 +1092,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"anyhow",
"collab",
@ -1108,7 +1109,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"anyhow",
"collab",
@ -1126,7 +1127,7 @@ dependencies = [
[[package]]
name = "collab-persistence"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"bincode",
"chrono",
@ -1146,7 +1147,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"anyhow",
"async-trait",
@ -1172,7 +1173,7 @@ dependencies = [
[[package]]
name = "collab-sync"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d074c9#d074c94471f222e2701fe451f13c51aab39d2bf8"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=7a2e97#7a2e97d9bfe746f5db18753ab0b59347ec5bf23f"
dependencies = [
"bytes",
"collab",
@ -3107,9 +3108,9 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
[[package]]
name = "librocksdb-sys"
version = "0.10.0+7.9.2"
version = "0.11.0+8.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b"
checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e"
dependencies = [
"bindgen",
"bzip2-sys",
@ -4005,6 +4006,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "prettyplease"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "617feabb81566b593beb4886fb8c1f38064169dae4dccad0e3220160c3b37203"
dependencies = [
"proc-macro2",
"syn 2.0.16",
]
[[package]]
name = "proc-macro-crate"
version = "0.1.5"
@ -4475,9 +4486,9 @@ dependencies = [
[[package]]
name = "rocksdb"
version = "0.20.1"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99"
checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe"
dependencies = [
"libc",
"librocksdb-sys",

View File

@ -51,9 +51,7 @@ impl DatabaseManager2 {
*self.user_database.lock() = Some(InnerUserDatabase::new(
user_id,
db,
RocksDBConfig::default()
.enable_snapshot(true)
.snapshot_per_update(10),
RocksDBConfig::default(),
UserDatabaseCollabBuilderImpl(self.collab_builder.clone()),
));
// do nothing

View File

@ -465,8 +465,9 @@ impl DatabaseViewEditor {
pub async fn v_delete_all_sorts(&self) -> FlowyResult<()> {
let all_sorts = self.v_get_all_sorts().await;
self.delegate.remove_all_sorts(&self.view_id);
self.sort_controller.write().await.delete_all_sorts().await;
self.delegate.remove_all_sorts(&self.view_id);
let mut notification = SortChangesetNotificationPB::new(self.view_id.clone());
notification.delete_sorts = all_sorts.into_iter().map(SortPB::from).collect();
notify_did_update_sort(notification).await;

View File

@ -90,7 +90,7 @@ impl SortController {
let event_type = SortEvent::from_str(predicate).unwrap();
let mut rows = self.delegate.get_rows(&self.view_id).await;
match event_type {
SortEvent::SortDidChanged => {
SortEvent::SortDidChanged | SortEvent::DeleteAllSorts => {
self.sort_rows(&mut rows).await;
let row_orders = rows
.iter()
@ -165,7 +165,7 @@ impl SortController {
pub async fn delete_all_sorts(&mut self) {
self.sorts.clear();
self
.gen_task(SortEvent::SortDidChanged, QualityOfService::Background)
.gen_task(SortEvent::DeleteAllSorts, QualityOfService::Background)
.await;
}
@ -292,6 +292,7 @@ fn cmp_cell(
enum SortEvent {
SortDidChanged,
RowDidChanged(RowId),
DeleteAllSorts,
}
impl ToString for SortEvent {