mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: rename structs
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
use crate::{entities::NetworkState, ws::connection::FlowyWebSocketConnect};
|
||||
use flowy_error::FlowyError;
|
||||
use lib_dispatch::prelude::{Data, Unit};
|
||||
use lib_dispatch::prelude::{AppData, Data};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tracing::instrument(skip(data, ws_manager))]
|
||||
pub async fn update_network_ty(
|
||||
data: Data<NetworkState>,
|
||||
ws_manager: Unit<Arc<FlowyWebSocketConnect>>,
|
||||
ws_manager: AppData<Arc<FlowyWebSocketConnect>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let network_state = data.into_inner();
|
||||
ws_manager.update_network_type(&network_state.ty);
|
||||
|
@ -2,45 +2,45 @@ use crate::{
|
||||
configuration::*,
|
||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||
};
|
||||
use flowy_collaboration::entities::document_info::{CreateDocParams, DocumentId, DocumentInfo, ResetDocumentParams};
|
||||
use flowy_document::DocumentCloudService;
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams};
|
||||
use flowy_document::BlockCloudService;
|
||||
use flowy_error::FlowyError;
|
||||
use http_flowy::response::FlowyResponse;
|
||||
use lazy_static::lazy_static;
|
||||
use lib_infra::future::FutureResult;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct DocumentHttpCloudService {
|
||||
pub struct BlockHttpCloudService {
|
||||
config: ClientServerConfiguration,
|
||||
}
|
||||
|
||||
impl DocumentHttpCloudService {
|
||||
impl BlockHttpCloudService {
|
||||
pub fn new(config: ClientServerConfiguration) -> Self {
|
||||
Self { config }
|
||||
}
|
||||
}
|
||||
|
||||
impl DocumentCloudService for DocumentHttpCloudService {
|
||||
fn create_document(&self, token: &str, params: CreateDocParams) -> FutureResult<(), FlowyError> {
|
||||
impl BlockCloudService for BlockHttpCloudService {
|
||||
fn create_block(&self, token: &str, params: CreateBlockParams) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.doc_url();
|
||||
FutureResult::new(async move { create_document_request(&token, params, &url).await })
|
||||
}
|
||||
|
||||
fn read_document(&self, token: &str, params: DocumentId) -> FutureResult<Option<DocumentInfo>, FlowyError> {
|
||||
fn read_block(&self, token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.doc_url();
|
||||
FutureResult::new(async move { read_document_request(&token, params, &url).await })
|
||||
}
|
||||
|
||||
fn update_document(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
fn update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.doc_url();
|
||||
FutureResult::new(async move { reset_doc_request(&token, params, &url).await })
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn create_document_request(token: &str, params: CreateDocParams, url: &str) -> Result<(), FlowyError> {
|
||||
pub async fn create_document_request(token: &str, params: CreateBlockParams, url: &str) -> Result<(), FlowyError> {
|
||||
let _ = request_builder()
|
||||
.post(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
@ -50,11 +50,7 @@ pub async fn create_document_request(token: &str, params: CreateDocParams, url:
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn read_document_request(
|
||||
token: &str,
|
||||
params: DocumentId,
|
||||
url: &str,
|
||||
) -> Result<Option<DocumentInfo>, FlowyError> {
|
||||
pub async fn read_document_request(token: &str, params: BlockId, url: &str) -> Result<Option<BlockInfo>, FlowyError> {
|
||||
let doc = request_builder()
|
||||
.get(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
|
@ -1,5 +1,5 @@
|
||||
use flowy_collaboration::{
|
||||
entities::{document_info::DocumentInfo, folder_info::FolderInfo},
|
||||
entities::{document_info::BlockInfo, folder_info::FolderInfo},
|
||||
errors::CollaborateError,
|
||||
protobuf::{RepeatedRevision as RepeatedRevisionPB, Revision as RevisionPB},
|
||||
server_document::*,
|
||||
@ -111,7 +111,7 @@ impl FolderCloudPersistence for LocalDocumentCloudPersistence {
|
||||
}
|
||||
|
||||
impl DocumentCloudPersistence for LocalDocumentCloudPersistence {
|
||||
fn read_document(&self, doc_id: &str) -> BoxResultFuture<DocumentInfo, CollaborateError> {
|
||||
fn read_document(&self, doc_id: &str) -> BoxResultFuture<BlockInfo, CollaborateError> {
|
||||
let storage = self.storage.clone();
|
||||
let doc_id = doc_id.to_owned();
|
||||
Box::pin(async move {
|
||||
@ -127,7 +127,7 @@ impl DocumentCloudPersistence for LocalDocumentCloudPersistence {
|
||||
&self,
|
||||
doc_id: &str,
|
||||
repeated_revision: RepeatedRevisionPB,
|
||||
) -> BoxResultFuture<Option<DocumentInfo>, CollaborateError> {
|
||||
) -> BoxResultFuture<Option<BlockInfo>, CollaborateError> {
|
||||
let doc_id = doc_id.to_owned();
|
||||
let storage = self.storage.clone();
|
||||
Box::pin(async move {
|
||||
|
@ -4,7 +4,7 @@ use bytes::Bytes;
|
||||
use flowy_collaboration::{
|
||||
client_document::default::initial_delta_string,
|
||||
entities::{
|
||||
document_info::{CreateDocParams, DocumentId, DocumentInfo, ResetDocumentParams},
|
||||
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams},
|
||||
ws_data::{ClientRevisionWSData, ClientRevisionWSDataType},
|
||||
},
|
||||
errors::CollaborateError,
|
||||
@ -248,7 +248,7 @@ impl RevisionUser for LocalRevisionUser {
|
||||
}
|
||||
}
|
||||
|
||||
use flowy_document::DocumentCloudService;
|
||||
use flowy_document::BlockCloudService;
|
||||
use flowy_folder_data_model::entities::{
|
||||
app::{App, AppId, CreateAppParams, RepeatedApp, UpdateAppParams},
|
||||
trash::{RepeatedTrash, RepeatedTrashId},
|
||||
@ -406,13 +406,13 @@ impl UserCloudService for LocalServer {
|
||||
}
|
||||
}
|
||||
|
||||
impl DocumentCloudService for LocalServer {
|
||||
fn create_document(&self, _token: &str, _params: CreateDocParams) -> FutureResult<(), FlowyError> {
|
||||
impl BlockCloudService for LocalServer {
|
||||
fn create_block(&self, _token: &str, _params: CreateBlockParams) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
|
||||
fn read_document(&self, _token: &str, params: DocumentId) -> FutureResult<Option<DocumentInfo>, FlowyError> {
|
||||
let doc = DocumentInfo {
|
||||
fn read_block(&self, _token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> {
|
||||
let doc = BlockInfo {
|
||||
doc_id: params.value,
|
||||
text: initial_delta_string(),
|
||||
rev_id: 0,
|
||||
@ -421,7 +421,7 @@ impl DocumentCloudService for LocalServer {
|
||||
FutureResult::new(async { Ok(Some(doc)) })
|
||||
}
|
||||
|
||||
fn update_document(&self, _token: &str, _params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
fn update_block(&self, _token: &str, _params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user