Fix autosaved document ID being incorrectly added to browser storage at the wrong time without its document data (#2426)

* Remove deleted document instead of fetching documents in portfolio

* npm run lint-fix

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mTvare 2025-03-13 06:24:52 +05:30 committed by GitHub
parent beb1c6ae64
commit 2d18378823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,17 +53,27 @@ export function createPersistenceManager(editor: Editor, portfolio: PortfolioSta
graphiteStore,
);
await update<string[]>(
"documents_tab_order",
(old) => {
const order = old || [];
return order.filter((docId) => docId !== id);
},
graphiteStore,
);
const documentCount = getFromStore(portfolio).documents.length;
if (documentCount > 0) {
const documentIndex = getFromStore(portfolio).activeDocumentIndex;
const documentId = getFromStore(portfolio).documents[documentIndex].id;
const documentId = String(getFromStore(portfolio).documents[documentIndex].id);
await storeCurrentDocumentId(String(documentId));
const tabOrder = (await get<string[]>("documents_tab_order", graphiteStore)) || [];
if (tabOrder.includes(documentId)) {
await storeCurrentDocumentId(documentId);
}
} else {
await del("current_document_id", graphiteStore);
}
await storeDocumentOrder();
}
async function loadFirstDocument() {