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.

chore: reload workspace when fail to load at the first time (#4633)

Nathan.fooo3b51a6e6be1f
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock
index d37cc705e2..47aa98b6a7 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock
@@ -162,7 +162,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -714,7 +714,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"again",
"anyhow",
@@ -732,6 +732,7 @@ dependencies = [
"getrandom 0.2.10",
"gotrue",
"gotrue-entity",
+ "governor",
"mime",
"mime_guess",
"parking_lot 0.12.1",
@@ -816,7 +817,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-trait",
@@ -838,7 +839,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-trait",
@@ -867,7 +868,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -886,7 +887,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"bytes",
@@ -901,7 +902,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"chrono",
@@ -938,7 +939,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-stream",
@@ -977,7 +978,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -1311,7 +1312,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -2261,6 +2262,12 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
+[[package]]
+name = "futures-timer"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
+
[[package]]
name = "futures-util"
version = "0.3.30"
@@ -2577,7 +2584,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"futures-util",
@@ -2594,7 +2601,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -2605,6 +2612,24 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "governor"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "821239e5672ff23e2a7060901fa622950bbd80b649cdaadd78d1c1767ed14eb4"
+dependencies = [
+ "cfg-if",
+ "dashmap",
+ "futures",
+ "futures-timer",
+ "no-std-compat",
+ "nonzero_ext",
+ "parking_lot 0.12.1",
+ "quanta",
+ "rand 0.8.5",
+ "smallvec",
+]
+
[[package]]
name = "gtk"
version = "0.15.5"
@@ -3031,7 +3056,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"reqwest",
@@ -3391,6 +3416,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
+[[package]]
+name = "mach2"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "macroific"
version = "1.3.1"
@@ -3651,6 +3685,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
+[[package]]
+name = "no-std-compat"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
+
[[package]]
name = "nodrop"
version = "0.1.14"
@@ -3667,6 +3707,12 @@ dependencies = [
"minimal-lexical",
]
+[[package]]
+name = "nonzero_ext"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21"
+
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
@@ -4562,6 +4608,22 @@ dependencies = [
"psl-types",
]
+[[package]]
+name = "quanta"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab"
+dependencies = [
+ "crossbeam-utils",
+ "libc",
+ "mach2",
+ "once_cell",
+ "raw-cpuid",
+ "wasi 0.11.0+wasi-snapshot-preview1",
+ "web-sys",
+ "winapi",
+]
+
[[package]]
name = "quick-xml"
version = "0.28.2"
@@ -4678,6 +4740,15 @@ dependencies = [
"rand_core 0.5.1",
]
+[[package]]
+name = "raw-cpuid"
+version = "10.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
[[package]]
name = "raw-window-handle"
version = "0.5.2"
@@ -4709,7 +4780,7 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -4732,7 +4803,7 @@ dependencies = [
[[package]]
name = "realtime-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -5380,7 +5451,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -6860,7 +6931,7 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
[[package]]
name = "websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"futures-channel",
"futures-util",
@@ -7260,7 +7331,7 @@ dependencies = [
[[package]]
name = "workspace-template"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"async-trait",
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml
index 370d1edc57..f6a730e836 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml
@@ -82,7 +82,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23ad1c4de34c8333521b364f2e1f69695d72bb5" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a0851f485957cc6410ccf9d261c781c1d2f757" }
# Please use the following script to update collab.
# Working directory: frontend
#
@@ -92,10 +92,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
+collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
diff --git a/frontend/appflowy_web/wasm-libs/Cargo.lock b/frontend/appflowy_web/wasm-libs/Cargo.lock
index 8b15b1a27f..36621755a2 100644
--- a/frontend/appflowy_web/wasm-libs/Cargo.lock
+++ b/frontend/appflowy_web/wasm-libs/Cargo.lock
@@ -221,7 +221,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -545,7 +545,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"again",
"anyhow",
@@ -563,6 +563,7 @@ dependencies = [
"getrandom 0.2.12",
"gotrue",
"gotrue-entity",
+ "governor",
"mime",
"mime_guess",
"parking_lot 0.12.1",
@@ -616,7 +617,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-trait",
@@ -638,7 +639,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -657,7 +658,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"bytes",
@@ -672,7 +673,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"chrono",
@@ -709,7 +710,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-stream",
@@ -747,7 +748,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -944,7 +945,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -1376,6 +1377,7 @@ dependencies = [
"collab",
"collab-document",
"collab-entity",
+ "collab-folder",
"collab-plugins",
"flowy-database-pub",
"flowy-document-pub",
@@ -1569,6 +1571,12 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
+[[package]]
+name = "futures-timer"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
+
[[package]]
name = "futures-util"
version = "0.3.30"
@@ -1690,7 +1698,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"futures-util",
@@ -1707,7 +1715,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -1718,6 +1726,24 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "governor"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "821239e5672ff23e2a7060901fa622950bbd80b649cdaadd78d1c1767ed14eb4"
+dependencies = [
+ "cfg-if 1.0.0",
+ "dashmap",
+ "futures",
+ "futures-timer",
+ "no-std-compat",
+ "nonzero_ext",
+ "parking_lot 0.12.1",
+ "quanta",
+ "rand 0.8.5",
+ "smallvec",
+]
+
[[package]]
name = "h2"
version = "0.3.24"
@@ -2023,7 +2049,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"reqwest",
@@ -2258,6 +2284,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
+[[package]]
+name = "mach2"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "macroific"
version = "1.3.1"
@@ -2424,6 +2459,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
+[[package]]
+name = "no-std-compat"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
+
[[package]]
name = "nom"
version = "7.1.3"
@@ -2434,6 +2475,12 @@ dependencies = [
"minimal-lexical",
]
+[[package]]
+name = "nonzero_ext"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21"
+
[[package]]
name = "num-bigint"
version = "0.4.4"
@@ -3142,6 +3189,22 @@ dependencies = [
"psl-types",
]
+[[package]]
+name = "quanta"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab"
+dependencies = [
+ "crossbeam-utils",
+ "libc",
+ "mach2",
+ "once_cell",
+ "raw-cpuid",
+ "wasi 0.11.0+wasi-snapshot-preview1",
+ "web-sys",
+ "winapi",
+]
+
[[package]]
name = "quote"
version = "1.0.35"
@@ -3232,10 +3295,19 @@ dependencies = [
"rand_core 0.5.1",
]
+[[package]]
+name = "raw-cpuid"
+version = "10.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
[[package]]
name = "realtime-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -3258,7 +3330,7 @@ dependencies = [
[[package]]
name = "realtime-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -3705,7 +3777,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -4647,7 +4719,7 @@ checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
[[package]]
name = "websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"futures-channel",
"futures-util",
@@ -4954,4 +5026,4 @@ dependencies = [
[[patch.unused]]
name = "collab-database"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d00b477a9b844d86b5caeff573ca395dc5bf7198#d00b477a9b844d86b5caeff573ca395dc5bf7198"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
diff --git a/frontend/appflowy_web/wasm-libs/Cargo.toml b/frontend/appflowy_web/wasm-libs/Cargo.toml
index 24ddff37be..1cefba59ad 100644
--- a/frontend/appflowy_web/wasm-libs/Cargo.toml
+++ b/frontend/appflowy_web/wasm-libs/Cargo.toml
@@ -55,7 +55,7 @@ codegen-units = 1
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23ad1c4de34c8333521b364f2e1f69695d72bb5" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a0851f485957cc6410ccf9d261c781c1d2f757" }
# Please use the following script to update collab.
# Working directory: frontend
#
@@ -65,10 +65,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
+collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
diff --git a/frontend/appflowy_web/wasm-libs/af-wasm/src/integrate/server.rs b/frontend/appflowy_web/wasm-libs/af-wasm/src/integrate/server.rs
index d5263fab06..0dfbf45f05 100644
--- a/frontend/appflowy_web/wasm-libs/af-wasm/src/integrate/server.rs
+++ b/frontend/appflowy_web/wasm-libs/af-wasm/src/integrate/server.rs
@@ -41,6 +41,7 @@ impl ServerProviderWASM {
self.config.clone(),
true,
self.device_id.clone(),
+ "0.0.1"
));
*self.server.write() = Some(server.clone());
server
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 494c8af709..0ac19e2ddc 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -673,7 +673,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"again",
"anyhow",
@@ -691,6 +691,7 @@ dependencies = [
"getrandom 0.2.10",
"gotrue",
"gotrue-entity",
+ "governor",
"mime",
"mime_guess",
"parking_lot 0.12.1",
@@ -744,7 +745,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-trait",
@@ -766,7 +767,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-trait",
@@ -795,7 +796,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -814,7 +815,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"bytes",
@@ -829,7 +830,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"chrono",
@@ -866,7 +867,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"async-stream",
@@ -905,7 +906,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2ce95b948accd6d14b97ee886f4416295acd9c65#2ce95b948accd6d14b97ee886f4416295acd9c65"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=2de6d172f56fed29ee6f32b82040cca4867647ac#2de6d172f56fed29ee6f32b82040cca4867647ac"
dependencies = [
"anyhow",
"collab",
@@ -1235,7 +1236,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -2407,7 +2408,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"futures-util",
@@ -2424,7 +2425,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -2435,6 +2436,24 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "governor"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "821239e5672ff23e2a7060901fa622950bbd80b649cdaadd78d1c1767ed14eb4"
+dependencies = [
+ "cfg-if",
+ "dashmap",
+ "futures",
+ "futures-timer",
+ "no-std-compat",
+ "nonzero_ext",
+ "parking_lot 0.12.1",
+ "quanta",
+ "rand 0.8.5",
+ "smallvec",
+]
+
[[package]]
name = "h2"
version = "0.3.21"
@@ -2800,7 +2819,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"reqwest",
@@ -3053,6 +3072,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
+[[package]]
+name = "mach2"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "macroific"
version = "1.3.1"
@@ -3267,6 +3295,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
+[[package]]
+name = "no-std-compat"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
+
[[package]]
name = "nom"
version = "7.1.3"
@@ -3277,6 +3311,12 @@ dependencies = [
"minimal-lexical",
]
+[[package]]
+name = "nonzero_ext"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21"
+
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
@@ -4039,6 +4079,22 @@ dependencies = [
"psl-types",
]
+[[package]]
+name = "quanta"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab"
+dependencies = [
+ "crossbeam-utils",
+ "libc",
+ "mach2",
+ "once_cell",
+ "raw-cpuid",
+ "wasi 0.11.0+wasi-snapshot-preview1",
+ "web-sys",
+ "winapi",
+]
+
[[package]]
name = "quickcheck"
version = "1.0.3"
@@ -4196,6 +4252,15 @@ dependencies = [
"rand_core 0.5.1",
]
+[[package]]
+name = "raw-cpuid"
+version = "10.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
+dependencies = [
+ "bitflags 1.3.2",
+]
+
[[package]]
name = "rayon"
version = "1.7.0"
@@ -4230,7 +4295,7 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -4253,7 +4318,7 @@ dependencies = [
[[package]]
name = "realtime-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"bincode",
@@ -4841,7 +4906,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"app-error",
@@ -6016,7 +6081,7 @@ checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
[[package]]
name = "websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"futures-channel",
"futures-util",
@@ -6237,7 +6302,7 @@ dependencies = [
[[package]]
name = "workspace-template"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d23ad1c4de34c8333521b364f2e1f69695d72bb5#d23ad1c4de34c8333521b364f2e1f69695d72bb5"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=29a0851f485957cc6410ccf9d261c781c1d2f757#29a0851f485957cc6410ccf9d261c781c1d2f757"
dependencies = [
"anyhow",
"async-trait",
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 48ae3727f1..827b2724ea 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -105,7 +105,7 @@ incremental = false
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23ad1c4de34c8333521b364f2e1f69695d72bb5" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "29a0851f485957cc6410ccf9d261c781c1d2f757" }
# Please use the following script to update collab.
# Working directory: frontend
#
@@ -115,10 +115,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d23
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
-collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2ce95b948accd6d14b97ee886f4416295acd9c65" }
+collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
+collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "2de6d172f56fed29ee6f32b82040cca4867647ac" }
diff --git a/frontend/rust-lib/flowy-core/src/integrate/server.rs b/frontend/rust-lib/flowy-core/src/integrate/server.rs
index d65873c11f..c9a1402c4d 100644
--- a/frontend/rust-lib/flowy-core/src/integrate/server.rs
+++ b/frontend/rust-lib/flowy-core/src/integrate/server.rs
@@ -128,6 +128,7 @@ impl ServerProvider {
config,
*self.user_enable_sync.read(),
self.config.device_id.clone(),
+ &self.config.app_version,
));
Ok::<Arc<dyn AppFlowyServer>, FlowyError>(server)
diff --git a/frontend/rust-lib/flowy-core/src/integrate/user.rs b/frontend/rust-lib/flowy-core/src/integrate/user.rs
index 1959c2dd6e..e507221ef7 100644
--- a/frontend/rust-lib/flowy-core/src/integrate/user.rs
+++ b/frontend/rust-lib/flowy-core/src/integrate/user.rs
@@ -7,7 +7,7 @@ use tracing::event;
use collab_integrate::collab_builder::AppFlowyCollabBuilder;
use flowy_database2::DatabaseManager;
use flowy_document::manager::DocumentManager;
-use flowy_error::FlowyResult;
+use flowy_error::{FlowyError, FlowyResult};
use flowy_folder::manager::{FolderInitDataSource, FolderManager};
use flowy_user::event_map::UserStatusCallback;
use flowy_user_pub::cloud::{UserCloudConfig, UserCloudServiceProvider};
@@ -177,8 +177,13 @@ impl UserStatusCallback for UserStatusCallbackImpl {
}
},
},
- Err(_) => FolderInitDataSource::LocalDisk {
- create_if_not_exist: true,
+ Err(err) => match server_type {
+ Server::Local => FolderInitDataSource::LocalDisk {
+ create_if_not_exist: true,
+ },
+ Server::AppFlowyCloud | Server::Supabase => {
+ return Err(FlowyError::from(err));
+ },
},
};
diff --git a/frontend/rust-lib/flowy-core/src/lib.rs b/frontend/rust-lib/flowy-core/src/lib.rs
index 1d9a34e28b..041e407661 100644
--- a/frontend/rust-lib/flowy-core/src/lib.rs
+++ b/frontend/rust-lib/flowy-core/src/lib.rs
@@ -185,7 +185,7 @@ impl AppFlowyCore {
let cloned_user_manager = Arc::downgrade(&user_manager);
if let Some(user_manager) = cloned_user_manager.upgrade() {
if let Err(err) = user_manager
- .init(user_status_callback, collab_interact_impl)
+ .init_with_callback(user_status_callback, collab_interact_impl)
.await
{
error!("Init user failed: {}", err)
diff --git a/frontend/rust-lib/flowy-error/src/code.rs b/frontend/rust-lib/flowy-error/src/code.rs
index 1b02f368b4..8cc78a4ca0 100644
--- a/frontend/rust-lib/flowy-error/src/code.rs
+++ b/frontend/rust-lib/flowy-error/src/code.rs
@@ -24,23 +24,14 @@ pub enum ErrorCode {
#[error("Workspace name can not be empty or whitespace")]
WorkspaceNameInvalid = 5,
- #[error("Workspace id can not be empty or whitespace")]
- WorkspaceIdInvalid = 6,
-
- #[error("Color style of the App is invalid")]
- AppColorStyleInvalid = 7,
-
#[error("Workspace desc is invalid")]
WorkspaceDescTooLong = 8,
#[error("Workspace description too long")]
WorkspaceNameTooLong = 9,
- #[error("App id can not be empty or whitespace")]
- AppIdInvalid = 10,
-
- #[error("App name can not be empty or whitespace")]
- AppNameInvalid = 11,
+ #[error("Can't load the workspace data")]
+ WorkspaceInitializeError = 6,
#[error("View name can not be empty or whitespace")]
ViewNameInvalid = 12,
@@ -51,9 +42,6 @@ pub enum ErrorCode {
#[error("View id can not be empty or whitespace")]
ViewIdIsInvalid = 14,
- #[error("View desc too long")]
- ViewDescTooLong = 15,
-
#[error("View data is invalid")]
ViewDataInvalid = 16,
diff --git a/frontend/rust-lib/flowy-error/src/errors.rs b/frontend/rust-lib/flowy-error/src/errors.rs
index e532714cf6..96a735c2e4 100644
--- a/frontend/rust-lib/flowy-error/src/errors.rs
+++ b/frontend/rust-lib/flowy-error/src/errors.rs
@@ -70,16 +70,10 @@ impl FlowyError {
static_flowy_error!(internal, ErrorCode::Internal);
static_flowy_error!(record_not_found, ErrorCode::RecordNotFound);
- static_flowy_error!(workspace_name, ErrorCode::WorkspaceNameInvalid);
- static_flowy_error!(workspace_id, ErrorCode::WorkspaceIdInvalid);
- static_flowy_error!(color_style, ErrorCode::AppColorStyleInvalid);
- static_flowy_error!(workspace_desc, ErrorCode::WorkspaceDescTooLong);
- static_flowy_error!(app_name, ErrorCode::AppNameInvalid);
- static_flowy_error!(invalid_app_id, ErrorCode::AppIdInvalid);
+ static_flowy_error!(workspace_initialize, ErrorCode::WorkspaceInitializeError);
static_flowy_error!(view_name, ErrorCode::ViewNameInvalid);
static_flowy_error!(view_thumbnail, ErrorCode::ViewThumbnailInvalid);
static_flowy_error!(invalid_view_id, ErrorCode::ViewIdIsInvalid);
- static_flowy_error!(view_desc, ErrorCode::ViewDescTooLong);
static_flowy_error!(view_data, ErrorCode::ViewDataInvalid);
static_flowy_error!(unauthorized, ErrorCode::UserUnauthorized);
static_flowy_error!(email_empty, ErrorCode::EmailIsEmpty);
diff --git a/frontend/rust-lib/flowy-folder/src/entities/parser/view/mod.rs b/frontend/rust-lib/flowy-folder/src/entities/parser/view/mod.rs
index 399cc44c45..6d0faf330d 100644
--- a/frontend/rust-lib/flowy-folder/src/entities/parser/view/mod.rs
+++ b/frontend/rust-lib/flowy-folder/src/entities/parser/view/mod.rs
@@ -1,9 +1,7 @@
-mod view_desc;
mod view_id;
mod view_name;
mod view_thumbnail;
-pub use view_desc::*;
pub use view_id::*;
pub use view_name::*;
pub use view_thumbnail::*;
diff --git a/frontend/rust-lib/flowy-folder/src/entities/parser/view/view_desc.rs b/frontend/rust-lib/flowy-folder/src/entities/parser/view/view_desc.rs
deleted file mode 100644
index f88eb6ebff..0000000000
--- a/frontend/rust-lib/flowy-folder/src/entities/parser/view/view_desc.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-use flowy_error::ErrorCode;
-use unicode_segmentation::UnicodeSegmentation;
-
-#[derive(Debug)]
-pub struct ViewDesc(pub String);
-
-impl ViewDesc {
- pub fn parse(s: String) -> Result<ViewDesc, ErrorCode> {
- if s.graphemes(true).count() > 1000 {
- return Err(ErrorCode::ViewDescTooLong);
- }
-
- Ok(Self(s))
- }
-}
-
-impl AsRef<str> for ViewDesc {
- fn as_ref(&self) -> &str {
- &self.0
- }
-}
diff --git a/frontend/rust-lib/flowy-folder/src/entities/parser/workspace/workspace_id.rs b/frontend/rust-lib/flowy-folder/src/entities/parser/workspace/workspace_id.rs
index b3ce24c6c9..3bb30fa3dc 100644
--- a/frontend/rust-lib/flowy-folder/src/entities/parser/workspace/workspace_id.rs
+++ b/frontend/rust-lib/flowy-folder/src/entities/parser/workspace/workspace_id.rs
@@ -6,7 +6,7 @@ pub struct WorkspaceIdentify(pub String);
impl WorkspaceIdentify {
pub fn parse(s: String) -> Result<WorkspaceIdentify, ErrorCode> {
if s.trim().is_empty() {
- return Err(ErrorCode::WorkspaceIdInvalid);
+ return Err(ErrorCode::WorkspaceInitializeError);
}
Ok(Self(s))
diff --git a/frontend/rust-lib/flowy-folder/src/entities/view.rs b/frontend/rust-lib/flowy-folder/src/entities/view.rs
index 88d8187d39..7b756163a6 100644
--- a/frontend/rust-lib/flowy-folder/src/entities/view.rs
+++ b/frontend/rust-lib/flowy-folder/src/entities/view.rs
@@ -10,7 +10,7 @@ use flowy_error::ErrorCode;
use flowy_folder_pub::cloud::gen_view_id;
use crate::entities::icon::ViewIconPB;
-use crate::entities::parser::view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail};
+use crate::entities::parser::view::{ViewIdentify, ViewName, ViewThumbnail};
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
pub struct ChildViewUpdatePB {
@@ -336,11 +336,6 @@ impl TryInto<UpdateViewParams> for UpdateViewPayloadPB {
Some(name) => Some(ViewName::parse(name)?.0),
};
- let desc = match self.desc {
- None => None,
- Some(desc) => Some(ViewDesc::parse(desc)?.0),
- };
-
let thumbnail = match self.thumbnail {
None => None,
Some(thumbnail) => Some(ViewThumbnail::parse(thumbnail)?.0),
@@ -351,7 +346,7 @@ impl TryInto<UpdateViewParams> for UpdateViewPayloadPB {
Ok(UpdateViewParams {
view_id,
name,
- desc,
+ desc: self.desc,
thumbnail,
is_favorite,
layout: self.layout.map(|ty| ty.into()),
diff --git a/frontend/rust-lib/flowy-folder/src/event_handler.rs b/frontend/rust-lib/flowy-folder/src/event_handler.rs
index 2d42edc212..7eee016727 100644
--- a/frontend/rust-lib/flowy-folder/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_handler.rs
@@ -329,3 +329,11 @@ pub(crate) async fn get_folder_snapshots_handler(
let snapshots = folder.get_folder_snapshots(&data.value, 10).await?;
data_result_ok(RepeatedFolderSnapshotPB { items: snapshots })
}
+
+pub(crate) async fn reload_workspace_handler(
+ folder: AFPluginState<Weak<FolderManager>>,
+) -> Result<(), FlowyError> {
+ let folder = upgrade_folder(folder)?;
+ folder.reload_workspace().await?;
+ Ok(())
+}
diff --git a/frontend/rust-lib/flowy-folder/src/event_map.rs b/frontend/rust-lib/flowy-folder/src/event_map.rs
index 2e6c8855d7..6a4d1faa20 100644
--- a/frontend/rust-lib/flowy-folder/src/event_map.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_map.rs
@@ -37,6 +37,7 @@ pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
.event(FolderEvent::ReadRecentViews, read_recent_views_handler)
.event(FolderEvent::ToggleFavorite, toggle_favorites_handler)
.event(FolderEvent::UpdateRecentViews, update_recent_views_handler)
+ .event(FolderEvent::ReloadWorkspace, reload_workspace_handler)
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
@@ -152,4 +153,7 @@ pub enum FolderEvent {
// used for add or remove recent views, like history
#[event(input = "UpdateRecentViewPayloadPB")]
UpdateRecentViews = 37,
+
+ #[event()]
+ ReloadWorkspace = 38,
}
diff --git a/frontend/rust-lib/flowy-folder/src/manager.rs b/frontend/rust-lib/flowy-folder/src/manager.rs
index 72fbd27154..a2e8d951e6 100644
--- a/frontend/rust-lib/flowy-folder/src/manager.rs
+++ b/frontend/rust-lib/flowy-folder/src/manager.rs
@@ -72,15 +72,39 @@ impl FolderManager {
Ok(manager)
}
+ pub async fn reload_workspace(&self) -> FlowyResult<()> {
+ let workspace_id = self
+ .workspace_id
+ .read()
+ .as_ref()
+ .ok_or_else(|| {
+ FlowyError::internal().with_context("workspace id is empty when trying to reload workspace")
+ })?
+ .clone();
+
+ let uid = self.user.user_id()?;
+ let doc_state = self
+ .cloud_service
+ .get_folder_doc_state(&workspace_id, uid, CollabType::Folder, &workspace_id)
+ .await?;
+
+ self
+ .initialize(uid, &workspace_id, FolderInitDataSource::Cloud(doc_state))
+ .await?;
+ Ok(())
+ }
+
#[instrument(level = "debug", skip(self), err)]
pub async fn get_current_workspace(&self) -> FlowyResult<WorkspacePB> {
self.with_folder(
|| {
let uid = self.user.user_id()?;
- let workspace_id = self.workspace_id.read().as_ref().cloned().ok_or(
- FlowyError::from(ErrorCode::WorkspaceIdInvalid)
- .with_context("Unexpected empty workspace id"),
- )?;
+ let workspace_id = self
+ .workspace_id
+ .read()
+ .as_ref()
+ .cloned()
+ .ok_or_else(|| FlowyError::from(ErrorCode::WorkspaceInitializeError))?;
Err(workspace_data_not_sync_error(uid, &workspace_id))
},
|folder| {
diff --git a/frontend/rust-lib/flowy-folder/src/manager_init.rs b/frontend/rust-lib/flowy-folder/src/manager_init.rs
index b83ef2fc5a..5d3475a10d 100644
--- a/frontend/rust-lib/flowy-folder/src/manager_init.rs
+++ b/frontend/rust-lib/flowy-folder/src/manager_init.rs
@@ -1,10 +1,9 @@
-use std::sync::{Arc, Weak};
-
+use collab_entity::CollabType;
use collab_folder::{Folder, FolderNotify, UserId};
-use tracing::{event, Level};
-
use collab_integrate::CollabKVDB;
-use flowy_error::{ErrorCode, FlowyError, FlowyResult};
+use flowy_error::{FlowyError, FlowyResult};
+use std::sync::{Arc, Weak};
+use tracing::{event, Level};
use crate::manager::{FolderInitDataSource, FolderManager};
use crate::manager_observer::{
@@ -47,25 +46,34 @@ impl FolderManager {
create_if_not_exist,
} => {
let is_exist = self.is_workspace_exist_in_local(uid, &workspace_id).await;
+ // 1. if the folder exists, open it from local disk
if is_exist {
self
.open_local_folder(uid, &workspace_id, collab_db, folder_notifier)
.await?
} else if create_if_not_exist {
+ // 2. if the folder doesn't exist and create_if_not_exist is true, create a default folder
// Currently, this branch is only used when the server type is supabase. For appflowy cloud,
// the default workspace is already created when the user sign up.
self
.create_default_folder(uid, &workspace_id, collab_db, folder_notifier)
.await?
} else {
- return Err(FlowyError::new(
- ErrorCode::RecordNotFound,
- "Can't find any workspace data",
- ));
+ // 3. If the folder doesn't exist and create_if_not_exist is false, try to fetch the folder data from cloud/
+ // This will happen user can't fetch the folder data when the user sign in.
+ let doc_state = self
+ .cloud_service
+ .get_folder_doc_state(&workspace_id, uid, CollabType::Folder, &workspace_id)
+ .await?;
+
+ let collab = self
+ .collab_for_folder(uid, &workspace_id, collab_db.clone(), doc_state)
+ .await?;
+ Folder::open(UserId::from(uid), collab, Some(folder_notifier.clone()))?
}
},
- FolderInitDataSource::Cloud(raw_data) => {
- if raw_data.is_empty() {
+ FolderInitDataSource::Cloud(doc_state) => {
+ if doc_state.is_empty() {
event!(Level::ERROR, "remote folder data is empty, open from local");
self
.open_local_folder(uid, &workspace_id, collab_db, folder_notifier)
@@ -73,7 +81,7 @@ impl FolderManager {
} else {
event!(Level::INFO, "Restore folder with remote data");
let collab = self
- .collab_for_folder(uid, &workspace_id, collab_db.clone(), raw_data)
+ .collab_for_folder(uid, &workspace_id, collab_db.clone(), doc_state)
.await?;
Folder::open(UserId::from(uid), collab, Some(folder_notifier.clone()))?
}
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
index 57de02de31..73717798f0 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
@@ -331,7 +331,9 @@ async fn get_admin_client(client: &Arc<AFCloudClient>) -> FlowyResult<Client> {
client.base_url(),
client.ws_addr(),
client.gotrue_url(),
+ &client.device_id,
ClientConfiguration::default(),
+ &client.client_id,
);
admin_client
.sign_in_password(&admin_email, &admin_password)
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/server.rs b/frontend/rust-lib/flowy-server/src/af_cloud/server.rs
index 9a9a8cd57b..f82297356c 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/server.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/server.rs
@@ -12,7 +12,8 @@ use client_api::{Client, ClientConfiguration};
use flowy_storage::ObjectStorageService;
use tokio::sync::watch;
use tokio_stream::wrappers::WatchStream;
-use tracing::{error, event, info};
+use tracing::{error, event, info, warn};
+use uuid::Uuid;
use flowy_database_pub::cloud::DatabaseCloudService;
use flowy_document_pub::cloud::DocumentCloudService;
@@ -38,20 +39,32 @@ pub struct AppFlowyCloudServer {
pub(crate) client: Arc<AFCloudClient>,
enable_sync: Arc<AtomicBool>,
network_reachable: Arc<AtomicBool>,
- #[allow(dead_code)]
- device_id: String,
+ pub device_id: String,
ws_client: Arc<WSClient>,
}
impl AppFlowyCloudServer {
- pub fn new(config: AFCloudConfiguration, enable_sync: bool, device_id: String) -> Self {
+ pub fn new(
+ config: AFCloudConfiguration,
+ enable_sync: bool,
+ mut device_id: String,
+ app_version: &str,
+ ) -> Self {
+ // The device id can't be empty, so we generate a new one if it is.
+ if device_id.is_empty() {
+ warn!("Device ID is empty, generating a new one");
+ device_id = Uuid::new_v4().to_string();
+ }
+
let api_client = AFCloudClient::new(
&config.base_url,
&config.ws_base_url,
&config.gotrue_url,
+ &device_id,
ClientConfiguration::default()
.with_compression_buffer_size(10240)
.with_compression_quality(8),
+ app_version,
);
let token_state_rx = api_client.subscribe_token_state();
let enable_sync = Arc::new(AtomicBool::new(enable_sync));
diff --git a/frontend/rust-lib/flowy-server/tests/af_cloud_test/util.rs b/frontend/rust-lib/flowy-server/tests/af_cloud_test/util.rs
index 96957f1656..8377eb3dd9 100644
--- a/frontend/rust-lib/flowy-server/tests/af_cloud_test/util.rs
+++ b/frontend/rust-lib/flowy-server/tests/af_cloud_test/util.rs
@@ -26,7 +26,12 @@ pub fn get_af_cloud_config() -> Option<AFCloudConfiguration> {
pub fn af_cloud_server(config: AFCloudConfiguration) -> Arc<AppFlowyCloudServer> {
let fake_device_id = uuid::Uuid::new_v4().to_string();
- Arc::new(AppFlowyCloudServer::new(config, true, fake_device_id))
+ Arc::new(AppFlowyCloudServer::new(
+ config,
+ true,
+ fake_device_id,
+ "flowy-server-test",
+ ))
}
pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguration) -> String {
@@ -34,7 +39,9 @@ pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguratio
&config.base_url,
&config.ws_base_url,
&config.gotrue_url,
+ "fake_device_id",
ClientConfiguration::default(),
+ "test",
);
let admin_email = std::env::var("GOTRUE_ADMIN_EMAIL").unwrap();
let admin_password = std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap();
@@ -42,7 +49,9 @@ pub async fn generate_sign_in_url(user_email: &str, config: &AFCloudConfiguratio
client.base_url(),
client.ws_addr(),
client.gotrue_url(),
+ "fake_device_id",
ClientConfiguration::default(),
+ &client.client_id,
);
admin_client
.sign_in_password(&admin_email, &admin_password)
diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rs
index 41d71f1efb..27cc2233f0 100644
--- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs
@@ -1,21 +1,18 @@
-use std::collections::HashMap;
-use std::fmt::{Display, Formatter};
-use std::str::FromStr;
-use std::sync::Arc;
-
use anyhow::Error;
use collab::core::collab::CollabDocState;
use collab_entity::{CollabObject, CollabType};
-use serde::{Deserialize, Serialize};
-use serde_json::Value;
-use tokio_stream::wrappers::WatchStream;
-use uuid::Uuid;
-
use flowy_error::{ErrorCode, FlowyError};
-
use lib_infra::box_any::BoxAny;
use lib_infra::conditional_send_sync_trait;
use lib_infra::future::FutureResult;
+use serde::{Deserialize, Serialize};
+use serde_json::Value;
+use std::collections::HashMap;
+use std::fmt::{Display, Formatter};
+use std::str::FromStr;
+use std::sync::Arc;
+use tokio_stream::wrappers::WatchStream;
+use uuid::Uuid;
use crate::entities::{
AuthResponse, Authenticator, Role, UpdateUserProfileParams, UserCredentials, UserProfile,
diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs
index c86d810a0a..40cba9c282 100644
--- a/frontend/rust-lib/flowy-user/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-user/src/event_handler.rs
@@ -122,8 +122,17 @@ pub async fn get_user_profile_handler(
#[tracing::instrument(level = "debug", skip(manager))]
pub async fn sign_out_handler(manager: AFPluginState<Weak<UserManager>>) -> Result<(), FlowyError> {
- let manager = upgrade_manager(manager)?;
- manager.sign_out().await?;
+ let (tx, rx) = tokio::sync::oneshot::channel();
+ tokio::spawn(async move {
+ let result = async {
+ let manager = upgrade_manager(manager)?;
+ manager.sign_out().await?;
+ Ok::<(), FlowyError>(())
+ }
+ .await;
+ let _ = tx.send(result);
+ });
+ rx.await??;
Ok(())
}
@@ -565,7 +574,7 @@ pub async fn reset_workspace_handler(
let reset_pb = data.into_inner();
if reset_pb.workspace_id.is_empty() {
return Err(FlowyError::new(
- ErrorCode::WorkspaceIdInvalid,
+ ErrorCode::WorkspaceInitializeError,
"The workspace id is empty",
));
}
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
index d22b6ab04b..a046237943 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
@@ -118,7 +118,7 @@ impl UserManager {
/// the function will set up the collaboration configuration and initialize the user's awareness. Upon successful
/// completion, a user status callback is invoked to signify that the initialization process is complete.
#[instrument(level = "debug", skip_all, err)]
- pub async fn init<C: UserStatusCallback + 'static, I: CollabInteract>(
+ pub async fn init_with_callback<C: UserStatusCallback + 'static, I: CollabInteract>(
&self,
user_status_callback: C,
collab_interact: I,
@@ -159,27 +159,43 @@ impl UserManager {
}
// Subscribe the token state
+ let weak_cloud_services = Arc::downgrade(&self.cloud_services);
+ let weak_authenticate_user = Arc::downgrade(&self.authenticate_user);
let weak_pool = Arc::downgrade(&self.db_pool(user.uid)?);
+ let cloned_session = session.clone();
if let Some(mut token_state_rx) = self.cloud_services.subscribe_token_state() {
event!(tracing::Level::DEBUG, "Listen token state change");
let user_uid = user.uid;
- let user_token = user.token.clone();
+ let local_token = user.token.clone();
af_spawn(async move {
while let Some(token_state) = token_state_rx.next().await {
debug!("Token state changed: {:?}", token_state);
match token_state {
- UserTokenState::Refresh { token } => {
+ UserTokenState::Refresh { token: new_token } => {
// Only save the token if the token is different from the current token
- if token != user_token {
+ if new_token != local_token {
if let Some(conn) = weak_pool.upgrade().and_then(|pool| pool.get().ok()) {
// Save the new token
- if let Err(err) = save_user_token(user_uid, conn, token) {
+ if let Err(err) = save_user_token(user_uid, conn, new_token) {
error!("Save user token failed: {}", err);
}
}
}
},
- UserTokenState::Invalid => {},
+ UserTokenState::Invalid => {
+ // Force user to sign out when the token is invalid
+ if let (Some(cloud_services), Some(authenticate_user), Some(conn)) = (
+ weak_cloud_services.upgrade(),
+ weak_authenticate_user.upgrade(),
+ weak_pool.upgrade().and_then(|pool| pool.get().ok()),
+ ) {
+ if let Err(err) =
+ sign_out(&cloud_services, &cloned_session, &authenticate_user, conn).await
+ {
+ error!("Sign out when token invalid failed: {:?}", err);
+ }
+ }
+ },
}
}
});
@@ -203,7 +219,12 @@ impl UserManager {
}
self.authenticate_user.vacuum_database_if_need();
let cloud_config = get_cloud_config(session.user_id, &self.store_preferences);
- if let Err(e) = user_status_callback
+ // Init the user awareness
+ self
+ .initialize_user_awareness(&session, UserAwarenessDataSource::Local)
+ .await;
+
+ user_status_callback
.did_init(
user.uid,
&user.authenticator,
@@ -211,14 +232,7 @@ impl UserManager {
&session.user_workspace,
&self.authenticate_user.user_config.device_id,
)
- .await
- {
- error!("Failed to call did_init callback: {:?}", e);
- }
- // Init the user awareness
- self
- .initialize_user_awareness(&session, UserAwarenessDataSource::Local)
- .await;
+ .await?;
}
Ok(())
}
@@ -282,7 +296,7 @@ impl UserManager {
.initialize_user_awareness(&session, UserAwarenessDataSource::Remote)
.await;
- if let Err(e) = self
+ self
.user_status_callback
.read()
.await
@@ -291,10 +305,7 @@ impl UserManager {
&latest_workspace,
&self.authenticate_user.user_config.device_id,
)
- .await
- {
- error!("Failed to call did_sign_in callback: {:?}", e);
- }
+ .await?;
send_auth_state_notification(AuthStateChangedPB {
state: AuthStatePB::AuthStateSignIn,
message: "Sign in success".to_string(),
@@ -423,14 +434,13 @@ impl UserManager {
#[tracing::instrument(level = "info", skip(self))]
pub async fn sign_out(&self) -> Result<(), FlowyError> {
if let Ok(session) = self.get_session() {
- let _ = remove_user_token(session.user_id, self.db_connection(session.user_id)?);
- self.authenticate_user.database.close(session.user_id)?;
- self.authenticate_user.set_session(None)?;
-
- let server = self.cloud_services.get_user_service()?;
- if let Err(err) = server.sign_out(None).await {
- event!(tracing::Level::ERROR, "{:?}", err);
- }
+ sign_out(
+ &self.cloud_services,
+ &session,
+ &self.authenticate_user,
+ self.db_connection(session.user_id)?,
+ )
+ .await?;
}
Ok(())
}
@@ -821,3 +831,21 @@ pub(crate) fn run_collab_data_migration(
Err(e) => error!("User data migration failed: {:?}", e),
}
}
+
+pub async fn sign_out(
+ cloud_services: &Arc<dyn UserCloudServiceProvider>,
+ session: &Session,
+ authenticate_user: &AuthenticateUser,
+ conn: DBConnection,
+) -> Result<(), FlowyError> {
+ let _ = remove_user_token(session.user_id, conn);
+ authenticate_user.database.close(session.user_id)?;
+ authenticate_user.set_session(None)?;
+
+ let server = cloud_services.get_user_service()?;
+ if let Err(err) = server.sign_out(None).await {
+ event!(tracing::Level::ERROR, "{:?}", err);
+ }
+
+ Ok(())
+}