mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix warnings
This commit is contained in:
@ -4,7 +4,7 @@ use chrono::Utc;
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use flowy_collaboration::{core::document::default::initial_read_me, entities::doc::DocDelta};
|
||||
use flowy_collaboration::{core::document::default::initial_read_me, entities::doc::DocumentDelta};
|
||||
use flowy_core_data_model::user_default;
|
||||
use flowy_net::entities::NetworkType;
|
||||
|
||||
@ -92,9 +92,9 @@ impl CoreContext {
|
||||
for (index, view) in views.into_iter().enumerate() {
|
||||
if index == 0 {
|
||||
let delta = initial_read_me();
|
||||
let doc_delta = DocDelta {
|
||||
let doc_delta = DocumentDelta {
|
||||
doc_id: view.id.clone(),
|
||||
data: delta.to_json(),
|
||||
text: delta.to_json(),
|
||||
};
|
||||
let _ = self.view_controller.apply_doc_delta(doc_delta).await?;
|
||||
self.view_controller.set_latest_view(&view);
|
||||
|
@ -52,7 +52,7 @@ pub enum WorkspaceEvent {
|
||||
#[event()]
|
||||
CopyLink = 206,
|
||||
|
||||
#[event(input = "QueryViewRequest", output = "DocDelta")]
|
||||
#[event(input = "QueryViewRequest", output = "DocumentDelta")]
|
||||
OpenView = 207,
|
||||
|
||||
#[event(input = "QueryViewRequest")]
|
||||
@ -73,7 +73,7 @@ pub enum WorkspaceEvent {
|
||||
#[event()]
|
||||
DeleteAll = 304,
|
||||
|
||||
#[event(input = "DocDelta", output = "DocDelta")]
|
||||
#[event(input = "DocumentDelta", output = "DocumentDelta")]
|
||||
ApplyDocDelta = 400,
|
||||
|
||||
#[event(input = "ExportRequest", output = "ExportData")]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use flowy_collaboration::entities::doc::{DocDelta, DocIdentifier};
|
||||
use flowy_collaboration::entities::doc::{DocIdentifier, DocumentDelta};
|
||||
use flowy_database::SqliteConnection;
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
@ -110,7 +110,7 @@ impl ViewController {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, params), fields(doc_id = %params.doc_id), err)]
|
||||
pub(crate) async fn open_view(&self, params: DocIdentifier) -> Result<DocDelta, FlowyError> {
|
||||
pub(crate) async fn open_view(&self, params: DocIdentifier) -> Result<DocumentDelta, FlowyError> {
|
||||
let doc_id = params.doc_id.clone();
|
||||
let edit_context = self.document.open(params).await?;
|
||||
|
||||
@ -164,7 +164,7 @@ impl ViewController {
|
||||
.await?;
|
||||
|
||||
Ok(ExportData {
|
||||
data: doc.data,
|
||||
data: doc.text,
|
||||
export_type: params.export_type,
|
||||
})
|
||||
}
|
||||
@ -200,7 +200,7 @@ impl ViewController {
|
||||
Ok(updated_view)
|
||||
}
|
||||
|
||||
pub(crate) async fn apply_doc_delta(&self, params: DocDelta) -> Result<DocDelta, FlowyError> {
|
||||
pub(crate) async fn apply_doc_delta(&self, params: DocumentDelta) -> Result<DocumentDelta, FlowyError> {
|
||||
let doc = self.document.apply_doc_delta(params).await?;
|
||||
Ok(doc)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use crate::{
|
||||
errors::FlowyError,
|
||||
services::{TrashController, ViewController},
|
||||
};
|
||||
use flowy_collaboration::entities::doc::DocDelta;
|
||||
use flowy_collaboration::entities::doc::DocumentDelta;
|
||||
use flowy_core_data_model::entities::share::{ExportData, ExportParams, ExportRequest};
|
||||
use lib_dispatch::prelude::{data_result, Data, DataResult, Unit};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
@ -52,10 +52,10 @@ pub(crate) async fn update_view_handler(
|
||||
}
|
||||
|
||||
pub(crate) async fn apply_doc_delta_handler(
|
||||
data: Data<DocDelta>,
|
||||
data: Data<DocumentDelta>,
|
||||
controller: Unit<Arc<ViewController>>,
|
||||
) -> DataResult<DocDelta, FlowyError> {
|
||||
// let params: DocDelta = data.into_inner().try_into()?;
|
||||
) -> DataResult<DocumentDelta, FlowyError> {
|
||||
// let params: DocumentDelta = data.into_inner().try_into()?;
|
||||
let doc = controller.apply_doc_delta(data.into_inner()).await?;
|
||||
data_result(doc)
|
||||
}
|
||||
@ -83,7 +83,7 @@ pub(crate) async fn delete_view_handler(
|
||||
pub(crate) async fn open_view_handler(
|
||||
data: Data<QueryViewRequest>,
|
||||
controller: Unit<Arc<ViewController>>,
|
||||
) -> DataResult<DocDelta, FlowyError> {
|
||||
) -> DataResult<DocumentDelta, FlowyError> {
|
||||
let params: ViewIdentifier = data.into_inner().try_into()?;
|
||||
let doc = controller.open_view(params.into()).await?;
|
||||
data_result(doc)
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use backend_service::configuration::ClientServerConfiguration;
|
||||
use flowy_collaboration::entities::doc::{DocDelta, DocIdentifier};
|
||||
use flowy_collaboration::entities::doc::{DocIdentifier, DocumentDelta};
|
||||
use flowy_database::ConnectionPool;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -58,13 +58,13 @@ impl FlowyDocument {
|
||||
&self,
|
||||
params: DocIdentifier,
|
||||
pool: Arc<ConnectionPool>,
|
||||
) -> Result<DocDelta, FlowyError> {
|
||||
) -> Result<DocumentDelta, FlowyError> {
|
||||
let edit_context = self.doc_ctrl.open(params, pool).await?;
|
||||
let delta = edit_context.delta().await?;
|
||||
Ok(delta)
|
||||
}
|
||||
|
||||
pub async fn apply_doc_delta(&self, params: DocDelta) -> Result<DocDelta, FlowyError> {
|
||||
pub async fn apply_doc_delta(&self, params: DocumentDelta) -> Result<DocumentDelta, FlowyError> {
|
||||
// workaround: compare the rust's delta with flutter's delta. Will be removed
|
||||
// very soon
|
||||
let doc = self
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use dashmap::DashMap;
|
||||
use flowy_collaboration::entities::doc::{Doc, DocDelta, DocIdentifier};
|
||||
use flowy_collaboration::entities::doc::{DocIdentifier, DocumentDelta, DocumentInfo};
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::FlowyResult;
|
||||
use lib_infra::future::FutureResult;
|
||||
@ -77,16 +77,16 @@ impl DocController {
|
||||
#[tracing::instrument(level = "debug", skip(self, delta, db_pool), fields(doc_id = %delta.doc_id), err)]
|
||||
pub(crate) async fn apply_local_delta(
|
||||
&self,
|
||||
delta: DocDelta,
|
||||
delta: DocumentDelta,
|
||||
db_pool: Arc<ConnectionPool>,
|
||||
) -> Result<DocDelta, FlowyError> {
|
||||
) -> Result<DocumentDelta, FlowyError> {
|
||||
if !self.open_cache.contains(&delta.doc_id) {
|
||||
let doc_identifier: DocIdentifier = delta.doc_id.clone().into();
|
||||
let _ = self.open(doc_identifier, db_pool).await?;
|
||||
}
|
||||
|
||||
let edit_doc_ctx = self.open_cache.get(&delta.doc_id)?;
|
||||
let _ = edit_doc_ctx.composing_local_delta(Bytes::from(delta.data)).await?;
|
||||
let _ = edit_doc_ctx.composing_local_delta(Bytes::from(delta.text)).await?;
|
||||
Ok(edit_doc_ctx.delta().await?)
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ struct RevisionServerImpl {
|
||||
|
||||
impl RevisionServer for RevisionServerImpl {
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
fn fetch_document(&self, doc_id: &str) -> FutureResult<Doc, FlowyError> {
|
||||
fn fetch_document(&self, doc_id: &str) -> FutureResult<DocumentInfo, FlowyError> {
|
||||
let params = DocIdentifier {
|
||||
doc_id: doc_id.to_string(),
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ use bytes::Bytes;
|
||||
use flowy_collaboration::{
|
||||
core::document::history::UndoResult,
|
||||
entities::{
|
||||
doc::DocDelta,
|
||||
doc::DocumentDelta,
|
||||
revision::{RevId, RevType, Revision},
|
||||
},
|
||||
errors::CollaborateResult,
|
||||
@ -144,15 +144,15 @@ impl ClientDocEditor {
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
pub async fn delta(&self) -> FlowyResult<DocDelta> {
|
||||
pub async fn delta(&self) -> FlowyResult<DocumentDelta> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<DocumentMD5>>();
|
||||
let msg = EditorCommand::ReadDoc { ret };
|
||||
let _ = self.editor_cmd_sender.send(msg);
|
||||
let data = rx.await.map_err(internal_error)??;
|
||||
|
||||
Ok(DocDelta {
|
||||
Ok(DocumentDelta {
|
||||
doc_id: self.doc_id.clone(),
|
||||
data,
|
||||
text: data,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ use crate::{errors::FlowyError, services::doc::revision::RevisionCache};
|
||||
use bytes::Bytes;
|
||||
use flowy_collaboration::{
|
||||
entities::{
|
||||
doc::Doc,
|
||||
doc::DocumentInfo,
|
||||
revision::{RevState, RevType, Revision, RevisionRange},
|
||||
},
|
||||
util::{md5, RevIdCounter},
|
||||
@ -16,7 +16,7 @@ use lib_ot::{
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait RevisionServer: Send + Sync {
|
||||
fn fetch_document(&self, doc_id: &str) -> FutureResult<Doc, FlowyError>;
|
||||
fn fetch_document(&self, doc_id: &str) -> FutureResult<DocumentInfo, FlowyError>;
|
||||
}
|
||||
|
||||
pub struct RevisionManager {
|
||||
@ -158,7 +158,7 @@ impl RevisionLoader {
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_doc_from_revisions(doc_id: &str, revisions: Vec<Revision>) -> FlowyResult<Doc> {
|
||||
fn mk_doc_from_revisions(doc_id: &str, revisions: Vec<Revision>) -> FlowyResult<DocumentInfo> {
|
||||
let (base_rev_id, rev_id) = revisions.last().unwrap().pair_rev_id();
|
||||
let mut delta = RichTextDelta::new();
|
||||
for (_, revision) in revisions.into_iter().enumerate() {
|
||||
@ -173,7 +173,7 @@ fn mk_doc_from_revisions(doc_id: &str, revisions: Vec<Revision>) -> FlowyResult<
|
||||
}
|
||||
correct_delta_if_need(&mut delta);
|
||||
|
||||
Result::<Doc, FlowyError>::Ok(Doc {
|
||||
Result::<DocumentInfo, FlowyError>::Ok(DocumentInfo {
|
||||
id: doc_id.to_owned(),
|
||||
text: delta.to_json(),
|
||||
rev_id,
|
||||
|
@ -6,7 +6,7 @@ pub use server_api::*;
|
||||
// TODO: ignore mock files in production
|
||||
use crate::errors::FlowyError;
|
||||
use backend_service::configuration::ClientServerConfiguration;
|
||||
use flowy_collaboration::entities::doc::{CreateDocParams, Doc, DocIdentifier, ResetDocumentParams};
|
||||
use flowy_collaboration::entities::doc::{CreateDocParams, DocIdentifier, DocumentInfo, ResetDocumentParams};
|
||||
use lib_infra::future::FutureResult;
|
||||
pub use server_api_mock::*;
|
||||
use std::sync::Arc;
|
||||
@ -15,7 +15,7 @@ pub(crate) type Server = Arc<dyn DocumentServerAPI + Send + Sync>;
|
||||
pub trait DocumentServerAPI {
|
||||
fn create_doc(&self, token: &str, params: CreateDocParams) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn read_doc(&self, token: &str, params: DocIdentifier) -> FutureResult<Option<Doc>, FlowyError>;
|
||||
fn read_doc(&self, token: &str, params: DocIdentifier) -> FutureResult<Option<DocumentInfo>, FlowyError>;
|
||||
|
||||
fn update_doc(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError>;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{errors::FlowyError, services::server::DocumentServerAPI};
|
||||
use backend_service::{configuration::*, request::HttpRequestBuilder};
|
||||
use flowy_collaboration::entities::doc::{CreateDocParams, Doc, DocIdentifier, ResetDocumentParams};
|
||||
use flowy_collaboration::entities::doc::{CreateDocParams, DocIdentifier, DocumentInfo, ResetDocumentParams};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
pub struct DocServer {
|
||||
@ -18,7 +18,7 @@ impl DocumentServerAPI for DocServer {
|
||||
FutureResult::new(async move { create_doc_request(&token, params, &url).await })
|
||||
}
|
||||
|
||||
fn read_doc(&self, token: &str, params: DocIdentifier) -> FutureResult<Option<Doc>, FlowyError> {
|
||||
fn read_doc(&self, token: &str, params: DocIdentifier) -> FutureResult<Option<DocumentInfo>, FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.doc_url();
|
||||
FutureResult::new(async move { read_doc_request(&token, params, &url).await })
|
||||
@ -45,7 +45,11 @@ pub async fn create_doc_request(token: &str, params: CreateDocParams, url: &str)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn read_doc_request(token: &str, params: DocIdentifier, url: &str) -> Result<Option<Doc>, FlowyError> {
|
||||
pub async fn read_doc_request(
|
||||
token: &str,
|
||||
params: DocIdentifier,
|
||||
url: &str,
|
||||
) -> Result<Option<DocumentInfo>, FlowyError> {
|
||||
let doc = request_builder()
|
||||
.get(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
|
@ -1,6 +1,6 @@
|
||||
use flowy_collaboration::{
|
||||
core::document::default::initial_delta_string,
|
||||
entities::doc::{CreateDocParams, Doc, DocIdentifier, ResetDocumentParams},
|
||||
entities::doc::{CreateDocParams, DocIdentifier, DocumentInfo, ResetDocumentParams},
|
||||
};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
@ -13,8 +13,8 @@ impl DocumentServerAPI for DocServerMock {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn read_doc(&self, _token: &str, params: DocIdentifier) -> FutureResult<Option<Doc>, FlowyError> {
|
||||
let doc = Doc {
|
||||
fn read_doc(&self, _token: &str, params: DocIdentifier) -> FutureResult<Option<DocumentInfo>, FlowyError> {
|
||||
let doc = DocumentInfo {
|
||||
id: params.doc_id,
|
||||
text: initial_delta_string(),
|
||||
rev_id: 0,
|
||||
|
@ -4,7 +4,7 @@ use dashmap::DashMap;
|
||||
use flowy_collaboration::{
|
||||
core::sync::{DocumentPersistence, RevisionUser, ServerDocumentManager, SyncResponse},
|
||||
entities::{
|
||||
doc::Doc,
|
||||
doc::DocumentInfo,
|
||||
revision::Revision,
|
||||
ws::{DocumentWSData, DocumentWSDataBuilder, DocumentWSDataType, NewDocumentUser},
|
||||
},
|
||||
@ -148,7 +148,7 @@ impl MockDocServer {
|
||||
}
|
||||
|
||||
struct MockDocServerPersistence {
|
||||
inner: Arc<DashMap<String, Doc>>,
|
||||
inner: Arc<DashMap<String, DocumentInfo>>,
|
||||
}
|
||||
|
||||
impl std::default::Default for MockDocServerPersistence {
|
||||
@ -160,11 +160,7 @@ impl std::default::Default for MockDocServerPersistence {
|
||||
}
|
||||
|
||||
impl DocumentPersistence for MockDocServerPersistence {
|
||||
// fn update_doc(&self, _doc_id: &str, _rev_id: i64, _delta: RichTextDelta) ->
|
||||
// FutureResultSend<(), CollaborateError> { unimplemented!()
|
||||
// }
|
||||
|
||||
fn read_doc(&self, doc_id: &str) -> FutureResultSend<Doc, CollaborateError> {
|
||||
fn read_doc(&self, doc_id: &str) -> FutureResultSend<DocumentInfo, CollaborateError> {
|
||||
let inner = self.inner.clone();
|
||||
let doc_id = doc_id.to_owned();
|
||||
FutureResultSend::new(async move {
|
||||
@ -181,10 +177,10 @@ impl DocumentPersistence for MockDocServerPersistence {
|
||||
})
|
||||
}
|
||||
|
||||
fn create_doc(&self, revision: Revision) -> FutureResultSend<Doc, CollaborateError> {
|
||||
fn create_doc(&self, revision: Revision) -> FutureResultSend<DocumentInfo, CollaborateError> {
|
||||
FutureResultSend::new(async move {
|
||||
let doc: Doc = revision.try_into().unwrap();
|
||||
Ok(doc)
|
||||
let document_info: DocumentInfo = revision.try_into().unwrap();
|
||||
Ok(document_info)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{fs, path::PathBuf, sync::Arc};
|
||||
|
||||
use flowy_collaboration::entities::doc::Doc;
|
||||
use flowy_collaboration::entities::doc::DocumentInfo;
|
||||
use flowy_core::{
|
||||
entities::{
|
||||
app::*,
|
||||
@ -269,13 +269,13 @@ pub async fn putback_trash(sdk: &FlowySDKTest, id: TrashIdentifier) {
|
||||
.await;
|
||||
}
|
||||
|
||||
pub async fn open_view(sdk: &FlowySDKTest, request: QueryViewRequest) -> Doc {
|
||||
pub async fn open_view(sdk: &FlowySDKTest, request: QueryViewRequest) -> DocumentInfo {
|
||||
CoreModuleEventBuilder::new(sdk.clone())
|
||||
.event(OpenView)
|
||||
.request(request)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<Doc>()
|
||||
.parse::<DocumentInfo>()
|
||||
}
|
||||
|
||||
pub fn root_dir() -> String {
|
||||
|
Reference in New Issue
Block a user