Refactor/crate directory (#1621)

* chore: fix wanrings

* chore: remove protobuf ref in flowy-error-code

* chore: remove protobuf ref in lib-ws

* refactor: remove protobuf trait in flowy http model

* refactor: remove flowy-error-code crate

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Nathan.fooo
2022-12-30 11:16:47 +08:00
committed by GitHub
parent aae8259f63
commit aa5f052ecf
167 changed files with 655 additions and 923 deletions

View File

@ -7,9 +7,9 @@ edition = "2018"
[dependencies]
folder-rev-model = { path = "../../../shared-lib/folder-rev-model" }
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
flowy-sync = { path = "../flowy-sync"}
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
flowy-derive = { path = "../flowy-derive" }
lib-ot = { path = "../../../shared-lib/lib-ot" }
lib-infra = { path = "../../../shared-lib/lib-infra" }
@ -35,14 +35,14 @@ serde = { version = "1.0", features = ["derive"] }
tracing = { version = "0.1", features = ["log"] }
bytes = { version = "1.0" }
unicode-segmentation = "1.8"
serde_json = "1.0"
[dev-dependencies]
serde_json = "1.0"
flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
flowy-test = { path = "../flowy-test" }
[build-dependencies]
flowy-codegen= { path = "../../../shared-lib/flowy-codegen"}
flowy-codegen = { path = "../flowy-codegen"}
[features]

View File

@ -26,7 +26,8 @@ use crate::services::clear_current_workspace;
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
use flowy_http_model::ws_data::ServerRevisionWSData;
use flowy_sync::client_folder::FolderPad;
use std::{collections::HashMap, convert::TryInto, fmt::Formatter, sync::Arc};
use std::convert::TryFrom;
use std::{collections::HashMap, fmt::Formatter, sync::Arc};
use tokio::sync::RwLock as TokioRwLock;
lazy_static! {
static ref INIT_FOLDER_FLAG: TokioRwLock<HashMap<String, bool>> = TokioRwLock::new(HashMap::new());
@ -139,7 +140,7 @@ impl FolderManager {
// }
pub async fn did_receive_ws_data(&self, data: Bytes) {
let result: Result<ServerRevisionWSData, protobuf::ProtobufError> = data.try_into();
let result = ServerRevisionWSData::try_from(data);
match result {
Ok(data) => match self.folder_editor.read().await.clone() {
None => {}

View File

@ -124,7 +124,7 @@ impl FolderRevisionSql {
fn update(changeset: RevisionChangeset, conn: &SqliteConnection) -> Result<(), FlowyError> {
let state: TextRevisionState = changeset.state.clone().into();
let filter = dsl::rev_table
.filter(dsl::rev_id.eq(changeset.rev_id.as_ref()))
.filter(dsl::rev_id.eq(changeset.rev_id))
.filter(dsl::doc_id.eq(changeset.object_id));
let _ = update(filter).set(dsl::state.eq(state)).execute(conn)?;
tracing::debug!(

View File

@ -16,7 +16,7 @@ use crate::{
};
use bytes::Bytes;
use flowy_database::kv::KV;
use flowy_http_model::document::DocumentIdPB;
use flowy_http_model::document::DocumentId;
use folder_rev_model::{gen_view_id, ViewRevision};
use futures::{FutureExt, StreamExt};
use std::{collections::HashSet, sync::Arc};
@ -201,7 +201,7 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self,params), fields(doc_id = %params.value), err)]
pub(crate) async fn move_view_to_trash(&self, params: DocumentIdPB) -> Result<(), FlowyError> {
pub(crate) async fn move_view_to_trash(&self, params: DocumentId) -> Result<(), FlowyError> {
let view_id = params.value;
if let Some(latest_view_id) = KV::get_str(LATEST_VIEW_ID) {
if latest_view_id == view_id {

View File

@ -3,7 +3,7 @@ use bytes::Bytes;
use flowy_database::ConnectionPool;
use flowy_error::{FlowyError, FlowyResult};
use flowy_http_model::revision::{Revision, RevisionRange};
use flowy_http_model::ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSDataType};
use flowy_http_model::ws_data::{ClientRevisionWSData, NewDocumentUser};
use flowy_revision::*;
use flowy_sync::client_folder::FolderPad;
use flowy_sync::server_folder::FolderOperations;
@ -130,14 +130,14 @@ impl FolderRevisionWSDataStream {
}
impl RevisionWSDataStream for FolderRevisionWSDataStream {
fn receive_push_revision(&self, bytes: Bytes) -> BoxResultFuture<(), FlowyError> {
fn receive_push_revision(&self, revisions: Vec<Revision>) -> BoxResultFuture<(), FlowyError> {
let resolver = self.conflict_controller.clone();
Box::pin(async move { resolver.receive_bytes(bytes).await })
Box::pin(async move { resolver.receive_revisions(revisions).await })
}
fn receive_ack(&self, id: String, ty: ServerRevisionWSDataType) -> BoxResultFuture<(), FlowyError> {
fn receive_ack(&self, rev_id: i64) -> BoxResultFuture<(), FlowyError> {
let resolver = self.conflict_controller.clone();
Box::pin(async move { resolver.ack_revision(id, ty).await })
Box::pin(async move { resolver.ack_revision(rev_id).await })
}
fn receive_new_user_connect(&self, _new_user: NewDocumentUser) -> BoxResultFuture<(), FlowyError> {

View File

@ -15,8 +15,6 @@ use flowy_folder::entities::{
};
use flowy_folder::event_map::FolderEvent::*;
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
use flowy_http_model::document::DocumentPayloadPB;
use flowy_revision::disk::RevisionState;
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
use flowy_test::{event_builder::*, FlowySDKTest};
@ -413,17 +411,6 @@ pub async fn delete_view(sdk: &FlowySDKTest, view_ids: Vec<String>) {
.await;
}
#[allow(dead_code)]
pub async fn set_latest_view(sdk: &FlowySDKTest, view_id: &str) -> DocumentPayloadPB {
let view_id: ViewIdPB = view_id.into();
FolderEventBuilder::new(sdk.clone())
.event(SetLatestView)
.payload(view_id)
.async_send()
.await
.parse::<DocumentPayloadPB>()
}
pub async fn read_trash(sdk: &FlowySDKTest) -> RepeatedTrashPB {
FolderEventBuilder::new(sdk.clone())
.event(ReadTrash)