Skip to content

Commit

Permalink
fix: collab origin issue (AppFlowy-IO#402)
Browse files Browse the repository at this point in the history
* fix: collab origin issue

* chore: fix lint

* chore: upgrade collab

---------

Co-authored-by: nathan <nathan@appflowy.io>
  • Loading branch information
LucasXu0 and appflowy authored Mar 20, 2024
1 parent f7008d4 commit ab9496c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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= []
Expand Down
3 changes: 2 additions & 1 deletion libs/client-api/src/collab_sync/sync_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion libs/realtime-entity/src/collab_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ pub struct UpdateSync {
/// ...
/// }
/// ```
///
///
pub payload: Bytes,
}

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions libs/workspace-template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl WorkspaceTemplateBuilder {
favorites: Default::default(),
recent: Default::default(),
trash: Default::default(),
private: Default::default(),
};

let collab = Arc::new(MutexCollab::new(
Expand Down

0 comments on commit ab9496c

Please sign in to comment.