fix: create doc with Delta requirement to fix Document load error

This commit is contained in:
appflowy 2021-07-24 15:20:18 +08:00
parent 64b8f37470
commit 0ec02c1ac0
3 changed files with 6 additions and 4 deletions

View File

@ -32,7 +32,8 @@ class IAppImpl extends IApp {
switch (view.viewType) {
case ViewType.Doc:
final docRepo = DocRepository(docId: view.id);
final result = await docRepo.createDoc(name: view.name, desc: "");
final result = await docRepo.createDoc(
name: view.name, desc: "", text: "[{\"insert\":\"\\n\"}]");
return result.fold((l) => left(view), (r) {
return right(
WorkspaceError(code: WorkspaceErrorCode.Unknown, msg: r.msg));

View File

@ -12,8 +12,9 @@ class DocRepository {
});
Future<Either<DocInfo, EditorError>> createDoc(
{required String name, String? desc}) {
final request = CreateDocRequest(id: docId, name: name, desc: desc);
{required String name, String? desc, String? text}) {
final request =
CreateDocRequest(id: docId, name: name, desc: desc, text: text);
return EditorEventCreateDoc(request).send();
}

View File

@ -14,7 +14,7 @@ pub async fn create_doc(
manager: Unit<RwLock<FileManager>>,
) -> ResponseResult<DocInfo, EditorError> {
let params: CreateDocParams = data.into_inner().try_into()?;
let dir = manager.read().await.user.user_doc_dir()?;
let dir = manager.read().await.user.user_doc_dir()?;CreateDocRequest
let path = manager
.write()
.await