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.

solver conflicts

appflowya9eec5baeddc
diff --cc backend/src/services/document/router.rs
index d3fcbb9021,07ddf5ab5c..e83a391659
--- a/backend/src/services/document/router.rs
+++ b/backend/src/services/document/router.rs
@@@ -10,9 -10,11 +10,9 @@@ use actix_web::
use backend_service::{errors::ServerError, response::FlowyResponse};
use flowy_collaboration::{
protobuf::{
- CreateDocParams as CreateDocParamsPB,
- DocumentId as DocumentIdPB,
- ResetDocumentParams as ResetDocumentParamsPB,
+ CreateDocParams as CreateDocParamsPB, DocumentId as DocumentIdPB, ResetDocumentParams as ResetDocumentParamsPB,
},
- sync::ServerDocumentManager,
+ server_document::ServerDocumentManager,
};
use std::sync::Arc;
diff --cc backend/src/services/web_socket/entities/message.rs
index 89ea01aafb,639eaa638f..82f9cc1155
--- a/backend/src/services/web_socket/entities/message.rs
+++ b/backend/src/services/web_socket/entities/message.rs
@@@ -11,32 -11,15 +11,17 @@@ pub struct WebSocketMessage(pub Bytes)
impl std::ops::Deref for WebSocketMessage {
type Target = Bytes;
- fn deref(&self) -> &Self::Target { &self.0 }
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
}
- impl std::convert::From<DocumentClientWSData> for WebSocketMessage {
- fn from(data: DocumentClientWSData) -> Self {
- let bytes: Bytes = data.try_into().unwrap();
- let msg = WebSocketRawMessage {
- module: WSModule::Doc,
- data: bytes.to_vec(),
- };
-
- let bytes: Bytes = msg.try_into().unwrap();
- WebSocketMessage(bytes)
- }
- }
-
- impl std::convert::From<DocumentServerWSData> for WebSocketMessage {
- fn from(data: DocumentServerWSData) -> Self {
- let bytes: Bytes = data.try_into().unwrap();
- let msg = WebSocketRawMessage {
- module: WSModule::Doc,
- data: bytes.to_vec(),
- };
- let bytes: Bytes = msg.try_into().unwrap();
- WebSocketMessage(bytes)
- }
+ pub fn revision_data_to_ws_message(data: ServerRevisionWSData, channel: WSChannel) -> WebSocketMessage {
+ let bytes: Bytes = data.try_into().unwrap();
+ let msg = WebSocketRawMessage {
+ channel,
+ data: bytes.to_vec(),
+ };
+ let bytes: Bytes = msg.try_into().unwrap();
+ WebSocketMessage(bytes)
}
diff --cc backend/tests/util/helper.rs
index c3970def27,48d759b858..9990bf0bf6
--- a/backend/tests/util/helper.rs
+++ b/backend/tests/util/helper.rs
@@@ -342,12 -339,10 +345,12 @@@ impl BackendWorkspaceTest
Self { server, workspace }
}
- pub async fn create_app(&self) -> App { create_test_app(&self.server, &self.workspace.id).await }
+ pub async fn create_app(&self) -> App {
+ create_test_app(&self.server, &self.workspace.id).await
+ }
}
- pub struct AppTest {
+ pub struct BackendAppTest {
pub server: TestUserServer,
pub workspace: Workspace,
pub app: App,
diff --cc frontend/rust-lib/flowy-core/src/dart_notification.rs
index 97e807362a,e10a685b11..8bdc4ba782
--- a/frontend/rust-lib/flowy-core/src/dart_notification.rs
+++ b/frontend/rust-lib/flowy-core/src/dart_notification.rs
@@@ -2,23 -2,21 +2,21 @@@ use dart_notify::DartNotifyBuilder
use flowy_derive::ProtoBuf_Enum;
const OBSERVABLE_CATEGORY: &str = "Workspace";
- // Opti: Using the Rust macro to generate the serde code automatically that can
- // be use directly in flutter
#[derive(ProtoBuf_Enum, Debug)]
pub(crate) enum WorkspaceNotification {
- Unknown = 0,
- UserCreateWorkspace = 10,
- UserDeleteWorkspace = 11,
- WorkspaceUpdated = 12,
+ Unknown = 0,
+ UserCreateWorkspace = 10,
+ UserDeleteWorkspace = 11,
+ WorkspaceUpdated = 12,
WorkspaceListUpdated = 13,
WorkspaceAppsChanged = 14,
- AppUpdated = 21,
- AppViewsChanged = 24,
- ViewUpdated = 31,
- ViewDeleted = 32,
- ViewRestored = 33,
- UserUnauthorized = 100,
- TrashUpdated = 1000,
+ AppUpdated = 21,
+ AppViewsChanged = 24,
+ ViewUpdated = 31,
+ ViewDeleted = 32,
+ ViewRestored = 33,
+ UserUnauthorized = 100,
+ TrashUpdated = 1000,
}
impl std::default::Default for WorkspaceNotification {
@@@ -28,12 -24,10 +26,12 @@@
}
impl std::convert::From<WorkspaceNotification> for i32 {
- fn from(notification: WorkspaceNotification) -> Self { notification as i32 }
+ fn from(notification: WorkspaceNotification) -> Self {
+ notification as i32
+ }
}
- #[tracing::instrument(level = "debug")]
+ #[tracing::instrument(level = "trace")]
pub(crate) fn send_dart_notification(id: &str, ty: WorkspaceNotification) -> DartNotifyBuilder {
DartNotifyBuilder::new(id, ty, OBSERVABLE_CATEGORY)
}
diff --cc frontend/rust-lib/flowy-core/src/services/persistence/version_1/app_sql.rs
index cc2fce439c,f808d0342c..b098b5f461
--- a/frontend/rust-lib/flowy-core/src/services/persistence/version_1/app_sql.rs
+++ b/frontend/rust-lib/flowy-core/src/services/persistence/version_1/app_sql.rs
@@@ -24,9 -21,9 +21,9 @@@ impl AppTableSql
match diesel_record_count!(app_table, &app_table.id, conn) {
0 => diesel_insert_table!(app_table, &app_table, conn),
_ => {
- let changeset = AppTableChangeset::from_table(app_table);
+ let changeset = AppChangeset::from_table(app_table);
diesel_update_table!(app_table, changeset, conn)
- },
+ }
}
Ok(())
}
diff --cc frontend/rust-lib/flowy-core/src/services/persistence/version_1/trash_sql.rs
index 5caedb486e,7511b998f9..3c67084cdb
--- a/frontend/rust-lib/flowy-core/src/services/persistence/version_1/trash_sql.rs
+++ b/frontend/rust-lib/flowy-core/src/services/persistence/version_1/trash_sql.rs
@@@ -18,9 -17,9 +17,9 @@@ impl TrashTableSql
match diesel_record_count!(trash_table, &trash_table.id, conn) {
0 => diesel_insert_table!(trash_table, &trash_table, conn),
_ => {
- let changeset = TrashTableChangeset::from(trash_table);
+ let changeset = TrashChangeset::from(trash_table);
diesel_update_table!(trash_table, changeset, conn)
- },
+ }
}
}
diff --cc frontend/rust-lib/flowy-core/src/services/persistence/version_1/view_sql.rs
index 08f9cfef9e,badddf724b..705ab136a8
--- a/frontend/rust-lib/flowy-core/src/services/persistence/version_1/view_sql.rs
+++ b/frontend/rust-lib/flowy-core/src/services/persistence/version_1/view_sql.rs
@@@ -21,9 -21,9 +21,9 @@@ impl ViewTableSql
match diesel_record_count!(view_table, &view_table.id, conn) {
0 => diesel_insert_table!(view_table, &view_table, conn),
_ => {
- let changeset = ViewTableChangeset::from_table(view_table);
+ let changeset = ViewChangeset::from_table(view_table);
diesel_update_table!(view_table, changeset, conn)
- },
+ }
}
Ok(())
}
diff --cc frontend/rust-lib/flowy-core/src/services/persistence/version_1/workspace_sql.rs
index 283c398e50,20a64f3427..74ff142a85
--- a/frontend/rust-lib/flowy-core/src/services/persistence/version_1/workspace_sql.rs
+++ b/frontend/rust-lib/flowy-core/src/services/persistence/version_1/workspace_sql.rs
@@@ -17,9 -21,9 +21,9 @@@ impl WorkspaceTableSql
match diesel_record_count!(workspace_table, &table.id, conn) {
0 => diesel_insert_table!(workspace_table, &table, conn),
_ => {
- let changeset = WorkspaceTableChangeset::from_table(table);
+ let changeset = WorkspaceChangeset::from_table(table);
diesel_update_table!(workspace_table, changeset, conn);
- },
+ }
}
Ok(())
}
diff --cc frontend/rust-lib/flowy-document/tests/document/edit_script.rs
index 083d34f522,a56c2b136e..2af5f4058a
--- a/frontend/rust-lib/flowy-document/tests/document/edit_script.rs
+++ b/frontend/rust-lib/flowy-document/tests/document/edit_script.rs
@@@ -77,8 -77,8 +77,8 @@@ impl EditorTest
eprintln!("❌ receive: {}", delta.to_json());
}
assert_eq!(expected_delta, delta);
- },
+ }
}
- sleep(Duration::from_millis(SYNC_INTERVAL_IN_MILLIS)).await;
+ sleep(Duration::from_millis(DOCUMENT_SYNC_INTERVAL_IN_MILLIS)).await;
}
}
diff --cc frontend/rust-lib/flowy-sdk/src/lib.rs
index 529c7a22c3,e8f21a1213..18cff4fff0
--- a/frontend/rust-lib/flowy-sdk/src/lib.rs
+++ b/frontend/rust-lib/flowy-sdk/src/lib.rs
@@@ -122,12 -140,10 +140,12 @@@ impl FlowySDK
}
}
- pub fn dispatcher(&self) -> Arc<EventDispatcher> { self.dispatcher.clone() }
+ pub fn dispatcher(&self) -> Arc<EventDispatcher> {
+ self.dispatcher.clone()
+ }
}
- fn _init(
+ fn _start_listening(
dispatch: &EventDispatcher,
ws_conn: &Arc<FlowyWebSocketConnect>,
user_session: &Arc<UserSession>,
@@@ -161,22 -191,28 +193,28 @@@ async fn _listen_user_status
let result = || async {
match status {
UserStatus::Login { token, user_id } => {
- let _ = core.user_did_sign_in(&token).await?;
+ tracing::trace!("User did login");
+ let _ = folder_manager.initialize(&user_id, &token).await?;
let _ = ws_conn.start(token, user_id).await?;
- },
+ }
UserStatus::Logout { .. } => {
- core.user_did_logout().await;
+ tracing::trace!("User did logout");
+ folder_manager.clear().await;
let _ = ws_conn.stop().await;
- },
+ }
UserStatus::Expired { .. } => {
- core.user_session_expired().await;
+ tracing::trace!("User session has been expired");
+ folder_manager.clear().await;
let _ = ws_conn.stop().await;
- },
+ }
UserStatus::SignUp { profile, ret } => {
- let _ = core.user_did_sign_up(&profile.token).await?;
+ tracing::trace!("User did sign up");
+ let _ = folder_manager
+ .initialize_with_new_user(&profile.id, &profile.token)
+ .await?;
let _ = ws_conn.start(profile.token.clone(), profile.id.clone()).await?;
let _ = ret.send(());
- },
+ }
}
Ok::<(), FlowyError>(())
};
diff --cc frontend/rust-lib/flowy-user/src/services/user_session.rs
index a0b33265ce,e26fc3967a..89d621bfc4
--- a/frontend/rust-lib/flowy-user/src/services/user_session.rs
+++ b/frontend/rust-lib/flowy-user/src/services/user_session.rs
@@@ -8,21 -11,23 +11,21 @@@ use flowy_database::
kv::KV,
query_dsl::*,
schema::{user_table, user_table::dsl},
- DBConnection,
- ExpressionMethods,
- UserDatabaseConnection,
+ DBConnection, ExpressionMethods, UserDatabaseConnection,
};
- use flowy_user_data_model::entities::{SignInResponse, SignUpResponse};
- use lib_sqlite::ConnectionPool;
-
- use crate::{
- entities::{SignInParams, SignUpParams, UpdateUserParams, UserProfile},
- errors::{ErrorCode, FlowyError},
- notify::*,
- services::{
- server::{construct_user_server, Server},
- user::{database::UserDB, notifier::UserNotifier},
- },
- sql_tables::{UserTable, UserTableChangeset},
+ use flowy_user_data_model::entities::{
+ SignInParams,
+ SignInResponse,
+ SignUpParams,
+ SignUpResponse,
+ UpdateUserParams,
+ UserProfile,
};
+ use lib_sqlite::ConnectionPool;
+ use parking_lot::RwLock;
+ use serde::{Deserialize, Serialize};
+ use std::sync::Arc;
+ use tokio::sync::mpsc;
pub struct UserSessionConfig {
root_dir: String,
diff --cc frontend/rust-lib/lib-dispatch/tests/api/module.rs
index c04c523828,ddf0e68335..33b5e315f0
--- a/frontend/rust-lib/lib-dispatch/tests/api/module.rs
+++ b/frontend/rust-lib/lib-dispatch/tests/api/module.rs
@@@ -1,9 -1,7 +1,9 @@@
- use lib_dispatch::prelude::*;
+ use lib_dispatch::{prelude::*, util::tokio_default_runtime};
use std::sync::Arc;
-pub async fn hello() -> String { "say hello".to_string() }
+pub async fn hello() -> String {
+ "say hello".to_string()
+}
#[tokio::test]
async fn test() {
diff --cc shared-lib/flowy-collaboration/src/util.rs
index ffa3e9cccd,2082a9f428..f60cd53f35
--- a/shared-lib/flowy-collaboration/src/util.rs
+++ b/shared-lib/flowy-collaboration/src/util.rs
@@@ -49,19 -49,18 +59,22 @@@ impl RevIdCounter
let _ = self.0.fetch_add(1, SeqCst);
self.value()
}
- pub fn value(&self) -> i64 { self.0.load(SeqCst) }
+ pub fn value(&self) -> i64 {
+ self.0.load(SeqCst)
+ }
- pub fn set(&self, n: i64) { let _ = self.0.fetch_update(SeqCst, SeqCst, |_| Some(n)); }
+ pub fn set(&self, n: i64) {
+ let _ = self.0.fetch_update(SeqCst, SeqCst, |_| Some(n));
+ }
}
- pub fn make_delta_from_revisions(revisions: Vec<Revision>) -> CollaborateResult<RichTextDelta> {
- let mut delta = RichTextDelta::new();
+ pub fn make_delta_from_revisions<T>(revisions: Vec<Revision>) -> CollaborateResult<Delta<T>>
+ where
+ T: Attributes + DeserializeOwned,
+ {
+ let mut delta = Delta::<T>::new();
for revision in revisions {
- let revision_delta = RichTextDelta::from_bytes(revision.delta_data).map_err(|e| {
+ let revision_delta = Delta::<T>::from_bytes(revision.delta_data).map_err(|e| {
let err_msg = format!("Deserialize remote revision failed: {:?}", e);
CollaborateError::internal().context(err_msg)
})?;
diff --cc shared-lib/flowy-core-data-model/src/entities/trash.rs
index 054e715837,487a51c020..86d98cb0a7
--- a/shared-lib/flowy-core-data-model/src/entities/trash.rs
+++ b/shared-lib/flowy-core-data-model/src/entities/trash.rs
@@@ -1,12 -1,51 +1,51 @@@
- use crate::impl_def_and_def_mut;
+ use crate::{entities::app::App, impl_def_and_def_mut};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
+ use serde::{Deserialize, Serialize};
use std::fmt::Formatter;
- #[derive(PartialEq, Debug, ProtoBuf_Enum, Clone)]
+ #[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone, Serialize, Deserialize)]
+ pub struct Trash {
+ #[pb(index = 1)]
+ pub id: String,
+
+ #[pb(index = 2)]
+ pub name: String,
+
+ #[pb(index = 3)]
+ pub modified_time: i64,
+
+ #[pb(index = 4)]
+ pub create_time: i64,
+
+ #[pb(index = 5)]
+ pub ty: TrashType,
+ }
+
+ #[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
+ pub struct RepeatedTrash {
+ #[pb(index = 1)]
+ pub items: Vec<Trash>,
+ }
+
+ impl_def_and_def_mut!(RepeatedTrash, Trash);
+
+ impl std::convert::From<App> for Trash {
+ fn from(app: App) -> Self {
+ Trash {
+ id: app.id,
+ name: app.name,
+ modified_time: app.modified_time,
+ create_time: app.create_time,
+ ty: TrashType::App,
+ }
+ }
+ }
+
+ #[derive(Eq, PartialEq, Debug, ProtoBuf_Enum, Clone, Serialize, Deserialize)]
pub enum TrashType {
Unknown = 0,
- View = 1,
- App = 2,
+ View = 1,
+ App = 2,
}
impl std::convert::TryFrom<i32> for TrashType {
@@@ -97,33 -134,5 +136,7 @@@ impl std::convert::From<&Trash> for Tra
}
impl std::fmt::Display for TrashId {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.write_str(&format!("{:?}:{}", self.ty, self.id)) }
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ f.write_str(&format!("{:?}:{}", self.ty, self.id))
+ }
}
-
- #[derive(PartialEq, ProtoBuf, Default, Debug, Clone)]
- pub struct Trash {
- #[pb(index = 1)]
- pub id: String,
-
- #[pb(index = 2)]
- pub name: String,
-
- #[pb(index = 3)]
- pub modified_time: i64,
-
- #[pb(index = 4)]
- pub create_time: i64,
-
- #[pb(index = 5)]
- pub ty: TrashType,
- }
-
- #[derive(PartialEq, Debug, Default, ProtoBuf, Clone)]
- pub struct RepeatedTrash {
- #[pb(index = 1)]
- pub items: Vec<Trash>,
- }
-
- impl_def_and_def_mut!(RepeatedTrash, Trash);
diff --cc shared-lib/lib-ot/src/core/delta/delta.rs
index 05631d915b,98e5d02ba5..609320996a
--- a/shared-lib/lib-ot/src/core/delta/delta.rs
+++ b/shared-lib/lib-ot/src/core/delta/delta.rs
@@@ -454,10 -448,10 +456,10 @@@ fn invert_from_other<T: Attributes>
tracing::trace!("invert op: {} [{}:{}]", operation, start, end);
let other_ops = DeltaIter::from_interval(other, Interval::new(start, end)).ops();
other_ops.into_iter().for_each(|other_op| match operation {
- Operation::Delete(n) => {
- tracing::trace!("invert delete: {} by add {}", n, other_op);
+ Operation::Delete(_n) => {
+ // tracing::trace!("invert delete: {} by add {}", n, other_op);
base.add(other_op);
- },
+ }
Operation::Retain(_retain) => {
tracing::trace!(
"invert attributes: {:?}, {:?}",
diff --cc shared-lib/lib-ot/src/rich_text/attributes.rs
index f2eb5d80e3,43589835b5..7aa9cfeb34
--- a/shared-lib/lib-ot/src/rich_text/attributes.rs
+++ b/shared-lib/lib-ot/src/rich_text/attributes.rs
@@@ -1,9 -1,11 +1,9 @@@
#![allow(non_snake_case)]
use crate::{
block_attribute,
- core::{Attributes, OperationTransformable, RichTextOperation},
+ core::{Attributes, Operation, OperationTransformable},
errors::OTError,
- ignore_attribute,
- inline_attribute,
- list_attribute,
+ ignore_attribute, inline_attribute, list_attribute,
};
use lazy_static::lazy_static;
use std::{