mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add grid struct
This commit is contained in:
@ -225,7 +225,7 @@ impl RevisionObjectBuilder for BlockInfoBuilder {
|
||||
correct_delta(&mut delta);
|
||||
|
||||
Result::<BlockInfo, FlowyError>::Ok(BlockInfo {
|
||||
doc_id: object_id.to_owned(),
|
||||
block_id: object_id.to_owned(),
|
||||
text: delta.to_delta_json(),
|
||||
rev_id,
|
||||
base_rev_id,
|
||||
|
@ -11,7 +11,7 @@ pub mod errors {
|
||||
pub const DOCUMENT_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
|
||||
|
||||
use crate::errors::FlowyError;
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams};
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
pub trait BlockCloudService: Send + Sync {
|
||||
@ -19,5 +19,5 @@ pub trait BlockCloudService: Send + Sync {
|
||||
|
||||
fn read_block(&self, token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError>;
|
||||
|
||||
fn update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError>;
|
||||
fn update_block(&self, token: &str, params: ResetBlockParams) -> FutureResult<(), FlowyError>;
|
||||
}
|
||||
|
@ -162,8 +162,14 @@ impl RevisionCloudService for BlockRevisionCloudService {
|
||||
Some(doc) => {
|
||||
let delta_data = Bytes::from(doc.text.clone());
|
||||
let doc_md5 = md5(&delta_data);
|
||||
let revision =
|
||||
Revision::new(&doc.doc_id, doc.base_rev_id, doc.rev_id, delta_data, &user_id, doc_md5);
|
||||
let revision = Revision::new(
|
||||
&doc.block_id,
|
||||
doc.base_rev_id,
|
||||
doc.rev_id,
|
||||
delta_data,
|
||||
&user_id,
|
||||
doc_md5,
|
||||
);
|
||||
Ok(vec![revision])
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
configuration::*,
|
||||
request::{HttpRequestBuilder, ResponseMiddleware},
|
||||
};
|
||||
use flowy_block::BlockCloudService;
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams};
|
||||
use flowy_collaboration::entities::document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams};
|
||||
use flowy_document::BlockCloudService;
|
||||
use flowy_error::FlowyError;
|
||||
use http_flowy::response::FlowyResponse;
|
||||
use lazy_static::lazy_static;
|
||||
@ -33,7 +33,7 @@ impl BlockCloudService for BlockHttpCloudService {
|
||||
FutureResult::new(async move { read_document_request(&token, params, &url).await })
|
||||
}
|
||||
|
||||
fn update_block(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
fn update_block(&self, token: &str, params: ResetBlockParams) -> FutureResult<(), FlowyError> {
|
||||
let token = token.to_owned();
|
||||
let url = self.config.doc_url();
|
||||
FutureResult::new(async move { reset_doc_request(&token, params, &url).await })
|
||||
@ -61,7 +61,7 @@ pub async fn read_document_request(token: &str, params: BlockId, url: &str) -> R
|
||||
Ok(doc)
|
||||
}
|
||||
|
||||
pub async fn reset_doc_request(token: &str, params: ResetDocumentParams, url: &str) -> Result<(), FlowyError> {
|
||||
pub async fn reset_doc_request(token: &str, params: ResetBlockParams, url: &str) -> Result<(), FlowyError> {
|
||||
let _ = request_builder()
|
||||
.patch(&url.to_owned())
|
||||
.header(HEADER_TOKEN, token)
|
||||
|
@ -4,7 +4,7 @@ use bytes::Bytes;
|
||||
use flowy_collaboration::{
|
||||
client_document::default::initial_delta_string,
|
||||
entities::{
|
||||
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetDocumentParams},
|
||||
document_info::{BlockId, BlockInfo, CreateBlockParams, ResetBlockParams},
|
||||
ws_data::{ClientRevisionWSData, ClientRevisionWSDataType},
|
||||
},
|
||||
errors::CollaborateError,
|
||||
@ -416,7 +416,7 @@ impl BlockCloudService for LocalServer {
|
||||
|
||||
fn read_block(&self, _token: &str, params: BlockId) -> FutureResult<Option<BlockInfo>, FlowyError> {
|
||||
let doc = BlockInfo {
|
||||
doc_id: params.value,
|
||||
block_id: params.value,
|
||||
text: initial_delta_string(),
|
||||
rev_id: 0,
|
||||
base_rev_id: 0,
|
||||
@ -424,7 +424,7 @@ impl BlockCloudService for LocalServer {
|
||||
FutureResult::new(async { Ok(Some(doc)) })
|
||||
}
|
||||
|
||||
fn update_block(&self, _token: &str, _params: ResetDocumentParams) -> FutureResult<(), FlowyError> {
|
||||
fn update_block(&self, _token: &str, _params: ResetBlockParams) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async { Ok(()) })
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user