fix: collab origin issue (#402)

* fix: collab origin issue

* chore: fix lint

* chore: upgrade collab

---------

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Lucas.Xu 2024-03-20 19:37:45 +07:00 committed by GitHub
parent f7008d4c91
commit ab9496c248
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 10 deletions

9
Cargo.lock generated
View File

@ -1388,7 +1388,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba46c5e9e39049c4fedd6f3d67410368874b324f#ba46c5e9e39049c4fedd6f3d67410368874b324f"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0970b2e1440134af7c83bb8fc80cac5d2dedebb7#0970b2e1440134af7c83bb8fc80cac5d2dedebb7"
dependencies = [
"anyhow",
"async-trait",
@ -1404,6 +1404,7 @@ dependencies = [
"tokio",
"tokio-stream",
"tracing",
"unicode-segmentation",
"web-sys",
"yrs",
]
@ -1411,7 +1412,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba46c5e9e39049c4fedd6f3d67410368874b324f#ba46c5e9e39049c4fedd6f3d67410368874b324f"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0970b2e1440134af7c83bb8fc80cac5d2dedebb7#0970b2e1440134af7c83bb8fc80cac5d2dedebb7"
dependencies = [
"anyhow",
"collab",
@ -1430,7 +1431,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba46c5e9e39049c4fedd6f3d67410368874b324f#ba46c5e9e39049c4fedd6f3d67410368874b324f"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0970b2e1440134af7c83bb8fc80cac5d2dedebb7#0970b2e1440134af7c83bb8fc80cac5d2dedebb7"
dependencies = [
"anyhow",
"bytes",
@ -1445,7 +1446,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ba46c5e9e39049c4fedd6f3d67410368874b324f#ba46c5e9e39049c4fedd6f3d67410368874b324f"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=0970b2e1440134af7c83bb8fc80cac5d2dedebb7#0970b2e1440134af7c83bb8fc80cac5d2dedebb7"
dependencies = [
"anyhow",
"chrono",

View File

@ -177,10 +177,10 @@ inherits = "release"
debug = true
[patch.crates-io]
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba46c5e9e39049c4fedd6f3d67410368874b324f" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba46c5e9e39049c4fedd6f3d67410368874b324f" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba46c5e9e39049c4fedd6f3d67410368874b324f" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ba46c5e9e39049c4fedd6f3d67410368874b324f" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0970b2e1440134af7c83bb8fc80cac5d2dedebb7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0970b2e1440134af7c83bb8fc80cac5d2dedebb7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0970b2e1440134af7c83bb8fc80cac5d2dedebb7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "0970b2e1440134af7c83bb8fc80cac5d2dedebb7" }
[features]
custom_env= []

View File

@ -337,8 +337,9 @@ where
let is_valid = sink.validate_response(&msg).await;
// If there's no payload or the payload is empty, return.
if is_valid && !msg.payload().is_empty() {
let msg_origin = msg.origin();
ObserveCollab::<Sink, Stream>::process_payload(
origin,
msg_origin,
msg.payload(),
&object.object_id,
collab,

View File

@ -397,7 +397,7 @@ pub struct UpdateSync {
/// ...
/// }
/// ```
///
///
pub payload: Bytes,
}
@ -866,6 +866,15 @@ impl ServerCollabMessage {
ServerCollabMessage::ServerBroadcast(msg) => msg.payload.len(),
}
}
pub fn origin(&self) -> &CollabOrigin {
match self {
ServerCollabMessage::ClientAck(value) => &value.origin,
ServerCollabMessage::ServerInitSync(value) => &value.origin,
ServerCollabMessage::AwarenessSync(value) => &value.origin,
ServerCollabMessage::ServerBroadcast(value) => &value.origin,
}
}
}
impl Display for ServerCollabMessage {

View File

@ -115,6 +115,7 @@ impl WorkspaceTemplateBuilder {
favorites: Default::default(),
recent: Default::default(),
trash: Default::default(),
private: Default::default(),
};
let collab = Arc::new(MutexCollab::new(