Skip to content

Commit

Permalink
feat: split file creation and operations push
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Jul 2, 2024
1 parent 61b5c5d commit ce1ede8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/hooks/useDocumentDriveServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,29 @@ export function useDocumentDriveServer(
throw new Error('User is not allowed to create files');
}
const document = await loadFile(file, getDocumentModel);
return addDocument(

// first create the file with the initial state of document
const initialDocument: Document = {
...document.initialState,
initialState: document.initialState,
operations: {
global: [],
local: [],
},
clipboard: [],
};
const fileNode = await addDocument(
drive,
name || (typeof file === 'string' ? document.name : file.name),
document.documentType,
parentFolder,
document,
initialDocument,
);

// then add all the operations
for (const operations of Object.values(document.operations)) {
await addOperations(drive, fileNode.id, operations);
}
}

async function updateFile(
Expand Down

0 comments on commit ce1ede8

Please sign in to comment.