Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: sort with original row orders (#6314)

Nathan.fooo877236baf9b6
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock
index 89b449dac0..71cb1d577f 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock
@@ -976,7 +976,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -1001,7 +1001,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-trait",
@@ -1024,6 +1024,7 @@ dependencies = [
"thiserror",
"tokio",
"tokio-stream",
+ "tokio-util",
"tracing",
"uuid",
]
@@ -1031,7 +1032,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -1051,7 +1052,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"bytes",
@@ -1071,7 +1072,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -1114,7 +1115,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-stream",
@@ -1194,7 +1195,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"collab",
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml
index 9996b68c05..13971fafe3 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml
@@ -119,13 +119,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
# Working directory: frontend
# To update the commit ID, run:
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock
index 23b5ba3a89..91974a8b37 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.lock
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock
@@ -959,7 +959,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -984,7 +984,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-trait",
@@ -1007,6 +1007,7 @@ dependencies = [
"thiserror",
"tokio",
"tokio-stream",
+ "tokio-util",
"tracing",
"uuid",
]
@@ -1014,7 +1015,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -1034,7 +1035,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"bytes",
@@ -1054,7 +1055,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -1097,7 +1098,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-stream",
@@ -1177,7 +1178,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"collab",
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml
index 4d0fac080c..ef41f03c50 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.toml
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml
@@ -117,13 +117,13 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
# Working directory: frontend
# To update the commit ID, run:
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 1b151ad1a8..7c463f277e 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -837,7 +837,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -862,7 +862,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-trait",
@@ -885,6 +885,7 @@ dependencies = [
"thiserror",
"tokio",
"tokio-stream",
+ "tokio-util",
"tracing",
"uuid",
]
@@ -892,7 +893,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -912,7 +913,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"bytes",
@@ -932,7 +933,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"arc-swap",
@@ -975,7 +976,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"async-stream",
@@ -1055,7 +1056,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=58ed2b714806a74a4152956005374b4f8c1adf63#58ed2b714806a74a4152956005374b4f8c1adf63"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=36c193e770e8e19182fdb2311dbd1b7c2ba0ed53#36c193e770e8e19182fdb2311dbd1b7c2ba0ed53"
dependencies = [
"anyhow",
"collab",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 17c97a0268..b5bd96956c 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -141,13 +141,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "58ed2b714806a74a4152956005374b4f8c1adf63" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "36c193e770e8e19182fdb2311dbd1b7c2ba0ed53" }
# Working directory: frontend
# To update the commit ID, run:
diff --git a/frontend/rust-lib/flowy-core/Cargo.toml b/frontend/rust-lib/flowy-core/Cargo.toml
index 9e5823d9f4..8c222eacb2 100644
--- a/frontend/rust-lib/flowy-core/Cargo.toml
+++ b/frontend/rust-lib/flowy-core/Cargo.toml
@@ -27,7 +27,7 @@ flowy-search = { workspace = true }
flowy-search-pub = { workspace = true }
collab-entity = { workspace = true }
collab-plugins = { workspace = true }
-collab = { workspace = true }
+collab = { workspace = true, features = ["verbose_log"] }
diesel.workspace = true
uuid.workspace = true
flowy-storage = { workspace = true }
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 dfd39aa619..9247701961 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
@@ -37,6 +37,7 @@ use collab_integrate::collab_builder::{AppFlowyCollabBuilder, CollabBuilderConfi
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
use flowy_notification::DebounceNotificationSender;
use futures::future::join_all;
+use futures::{pin_mut, StreamExt};
use lib_infra::box_any::BoxAny;
use lib_infra::priority_task::TaskDispatcher;
use lib_infra::util::timestamp;
@@ -906,22 +907,29 @@ impl DatabaseEditor {
if let Some(field) = database.get_field(field_id) {
let field_type = FieldType::from(field.field_type);
match field_type {
- FieldType::LastEditedTime | FieldType::CreatedTime => database
- .get_rows_for_view(view_id)
- .await
- .into_iter()
- .map(|row| {
- let data = if field_type.is_created_time() {
- TimestampCellData::new(row.created_at)
- } else {
- TimestampCellData::new(row.modified_at)
- };
- RowCell {
- row_id: row.id,
- cell: Some(Cell::from(data)),
- }
- })
- .collect(),
+ FieldType::LastEditedTime | FieldType::CreatedTime => {
+ database
+ .get_rows_for_view(view_id, None)
+ .await
+ .filter_map(|result| async {
+ match result {
+ Ok(row) => {
+ let data = if field_type.is_created_time() {
+ TimestampCellData::new(row.created_at)
+ } else {
+ TimestampCellData::new(row.modified_at)
+ };
+ Some(RowCell {
+ row_id: row.id,
+ cell: Some(Cell::from(data)),
+ })
+ },
+ Err(_) => None,
+ }
+ })
+ .collect()
+ .await
+ },
_ => database.get_cells_for_field(view_id, field_id).await,
}
} else {
@@ -1480,34 +1488,31 @@ impl DatabaseEditor {
)
};
- let mut order_row_metas = row_orders
- .into_iter()
- .map(RowMetaPB::from)
+ // the order_rows are not filtered and sorted yet
+ let mut order_rows = row_orders
+ .iter()
+ .map(|row_order| RowMetaPB::from(row_order.clone()))
.collect::<Vec<RowMetaPB>>();
trace!(
"[Database]: database: {}, num fields: {}, num rows: {}",
database_id,
fields.len(),
- order_row_metas.len()
+ order_rows.len()
);
let view_editor = self.database_views.get_or_init_view_editor(view_id).await?;
- let blocking_read = notify_finish.is_some() || order_row_metas.len() < 50;
+ let blocking_read = notify_finish.is_some() || order_rows.len() < 50;
+
let (tx, rx) = oneshot::channel();
- self.async_load_rows(view_editor, Some(tx), new_token, blocking_read);
+ self.async_load_rows(view_editor, Some(tx), new_token, blocking_read, row_orders);
if blocking_read {
+ // the rows returned here are applied with filters and sorts
if let Ok(rows) = rx.await {
- let mut un_order_rows = rows
+ order_rows = rows
.into_iter()
- .map(|row| (row.id.to_string(), RowMetaPB::from(row.as_ref())))
- .collect::<HashMap<String, RowMetaPB>>();
-
- order_row_metas.iter_mut().for_each(|row_meta| {
- if let Some(un_order_row) = un_order_rows.remove(&row_meta.id) {
- *row_meta = un_order_row;
- }
- });
+ .map(|row| RowMetaPB::from(row.as_ref()))
+ .collect();
}
}
@@ -1518,7 +1523,7 @@ impl DatabaseEditor {
let result = Ok(DatabasePB {
id: database_id,
fields,
- rows: order_row_metas,
+ rows: order_rows,
layout_type: view_layout.into(),
is_linked,
});
@@ -1547,6 +1552,7 @@ impl DatabaseEditor {
notify_finish: Option<Sender<Vec<Arc<Row>>>>,
new_token: CancellationToken,
blocking_read: bool,
+ original_row_orders: Vec<RowOrder>,
) {
trace!(
"[Database]: start loading rows, blocking: {}",
@@ -1569,6 +1575,8 @@ impl DatabaseEditor {
} else {
view_editor.v_filter_rows_and_notify(&mut loaded_rows).await;
}
+ } else {
+ trace!("[Database]: no filter to apply");
}
if view_editor.has_sorts().await {
@@ -1578,9 +1586,23 @@ impl DatabaseEditor {
} else {
view_editor.v_sort_rows_and_notify(&mut loaded_rows).await;
}
+ loaded_rows
+ } else {
+ trace!("[Database]: no sort to apply");
+ // if there are no sorts, use the original row orders to sort the loaded rows
+ let mut map = loaded_rows
+ .into_iter()
+ .map(|row| (row.id.clone(), row))
+ .collect::<HashMap<RowId, Arc<Row>>>();
+
+ let mut order_rows = vec![];
+ for row_order in original_row_orders {
+ if let Some(row) = map.remove(&row_order.id) {
+ order_rows.push(row);
+ }
+ }
+ order_rows
}
-
- loaded_rows
};
let mut loaded_rows = vec![];
@@ -1601,13 +1623,18 @@ impl DatabaseEditor {
.map(|row_order| row_order.id.clone())
.collect();
- if let Ok(rows) = database.read().await.init_database_rows(row_ids).await {
- for row in rows {
- if let Some(row) = row.read().await.get_row() {
- loaded_rows.push(Arc::new(row));
- }
- }
- }
+ let new_loaded_rows: Vec<Arc<Row>> = database
+ .read()
+ .await
+ .init_database_rows(row_ids, None)
+ .filter_map(|result| async {
+ let database_row = result.ok()?;
+ let read_guard = database_row.read().await;
+ read_guard.get_row().map(Arc::new)
+ })
+ .collect()
+ .await;
+ loaded_rows.extend(new_loaded_rows);
// Check for cancellation after each chunk
if new_token.is_cancelled() {
@@ -1726,22 +1753,26 @@ impl DatabaseEditor {
match row_ids {
None => {
- warn!("Get all related rows will cause performance issue");
- let rows = database.get_all_rows().await;
let mut row_data = vec![];
- for row in rows {
- let title = database
- .get_cell(&primary_field.id, &row.id)
- .await
- .cell
- .and_then(|cell| handler.handle_get_boxed_cell_data(&cell, &primary_field))
- .and_then(|cell_data| cell_data.unbox_or_none())
- .unwrap_or_else(|| StringCellData("".to_string()));
- row_data.push(RelatedRowDataPB {
- row_id: row.id.to_string(),
- name: title.0,
- })
+ let rows_stream = database.get_all_rows(None).await;
+ pin_mut!(rows_stream);
+ while let Some(result) = rows_stream.next().await {
+ if let Ok(row) = result {
+ let title = database
+ .get_cell(&primary_field.id, &row.id)
+ .await
+ .cell
+ .and_then(|cell| handler.handle_get_boxed_cell_data(&cell, &primary_field))
+ .and_then(|cell_data| cell_data.unbox_or_none())
+ .unwrap_or_else(|| StringCellData("".to_string())); // Default to empty string
+
+ row_data.push(RelatedRowDataPB {
+ row_id: row.id.to_string(),
+ name: title.0,
+ });
+ }
}
+
Ok(row_data)
},
Some(row_ids) => {
@@ -1898,28 +1929,28 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl {
let view_id = view_id.to_string();
trace!("{} has total row orders: {}", view_id, row_orders.len());
let mut all_rows = vec![];
- // Loading the rows in chunks of 10 rows in order to prevent blocking the main asynchronous runtime
- const CHUNK_SIZE: usize = 10;
let cancellation = self
.database_cancellation
.read()
.await
.as_ref()
.map(|c| c.clone());
- for chunk in row_orders.chunks(CHUNK_SIZE) {
- let database_read_guard = self.database.read().await;
- let chunk = chunk.to_vec();
- let rows = database_read_guard.get_rows_from_row_orders(&chunk).await;
- if let Some(cancellation) = &cancellation {
- if cancellation.is_cancelled() {
- info!("Get all database row is cancelled:{}", view_id);
- return vec![];
- }
+
+ let read_guard = self.database.read().await;
+ let rows_stream = read_guard
+ .get_rows_from_row_orders(&row_orders, cancellation)
+ .await;
+ pin_mut!(rows_stream);
+
+ while let Some(result) = rows_stream.next().await {
+ match result {
+ Ok(row) => {
+ all_rows.push(row);
+ },
+ Err(err) => error!("Error while loading rows: {}", err),
}
- all_rows.extend(rows);
- drop(database_read_guard);
- tokio::task::yield_now().await;
}
+
trace!("total row details: {}", all_rows.len());
all_rows.into_iter().map(Arc::new).collect()
}
diff --git a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
index 521c87168a..55b524d059 100644
--- a/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/filter/controller.rs
@@ -406,13 +406,15 @@ impl FilterController {
);
});
+ let len = rows.len();
rows.retain(|row| {
self
.result_by_row_id
.get(&row.id)
.map(|result| *result)
- .unwrap_or(false)
+ .unwrap_or(true)
});
+ trace!("[Database]: filter out {} invisible rows", len - rows.len());
rows
}
@@ -468,7 +470,6 @@ fn filter_row(
for filter in filters {
if let Some(is_visible) = apply_filter(row, field_by_field_id, cell_data_cache, filter) {
new_is_visible = new_is_visible && is_visible;
-
// short-circuit as soon as one filter tree returns false
if !new_is_visible {
break;
diff --git a/frontend/rust-lib/flowy-database2/src/services/share/csv/export.rs b/frontend/rust-lib/flowy-database2/src/services/share/csv/export.rs
index 3a3a63249b..fd1b3ee70d 100644
--- a/frontend/rust-lib/flowy-database2/src/services/share/csv/export.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/share/csv/export.rs
@@ -1,6 +1,7 @@
use collab_database::database::Database;
use collab_database::fields::Field;
use collab_database::rows::Cell;
+use futures::StreamExt;
use indexmap::IndexMap;
use flowy_error::{FlowyError, FlowyResult};
@@ -47,7 +48,12 @@ impl CSVExport {
fields.into_iter().for_each(|field| {
field_by_field_id.insert(field.id.clone(), field);
});
- let rows = database.get_rows_for_view(&inline_view_id).await;
+ let rows = database
+ .get_rows_for_view(&inline_view_id, None)
+ .await
+ .filter_map(|result| async { result.ok() })
+ .collect::<Vec<_>>()
+ .await;
let stringify = |cell: &Cell, field: &Field, style: CSVFormat| match style {
CSVFormat::Original => stringify_cell(cell, field),
diff --git a/frontend/rust-lib/flowy-database2/tests/database/filter_test/advanced_filter_test.rs b/frontend/rust-lib/flowy-database2/tests/database/filter_test/advanced_filter_test.rs
index 107e588fed..bc71718437 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/filter_test/advanced_filter_test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/filter_test/advanced_filter_test.rs
@@ -59,7 +59,6 @@ async fn create_advanced_filter_test() {
// OR
let or_filter = test.get_filter(FilterType::Or, None).await.unwrap();
-
let checkbox_filter_bytes: Result<Bytes, ProtobufError> = create_checkbox_filter().try_into();
let checkbox_filter_bytes = checkbox_filter_bytes.unwrap().to_vec();