mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
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:
parent
beb1c6ae64
commit
2d18378823
1 changed files with 14 additions and 4 deletions
|
@ -53,17 +53,27 @@ export function createPersistenceManager(editor: Editor, portfolio: PortfolioSta
|
||||||
graphiteStore,
|
graphiteStore,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await update<string[]>(
|
||||||
|
"documents_tab_order",
|
||||||
|
(old) => {
|
||||||
|
const order = old || [];
|
||||||
|
return order.filter((docId) => docId !== id);
|
||||||
|
},
|
||||||
|
graphiteStore,
|
||||||
|
);
|
||||||
|
|
||||||
const documentCount = getFromStore(portfolio).documents.length;
|
const documentCount = getFromStore(portfolio).documents.length;
|
||||||
if (documentCount > 0) {
|
if (documentCount > 0) {
|
||||||
const documentIndex = getFromStore(portfolio).activeDocumentIndex;
|
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 {
|
} else {
|
||||||
await del("current_document_id", graphiteStore);
|
await del("current_document_id", graphiteStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
await storeDocumentOrder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadFirstDocument() {
|
async function loadFirstDocument() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue