Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make document auto-saving include the active tab index instead of just restoring the last tab #2194

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mTvare6
Copy link
Contributor

@mTvare6 mTvare6 commented Jan 12, 2025

if (!previouslySavedDocuments || !documentOrder) return;

const orderedSavedDocuments = documentOrder.flatMap((id) => (previouslySavedDocuments[id] ? [previouslySavedDocuments[id]] : []));

orderedSavedDocuments?.forEach(async (doc: TriggerIndexedDbWriteDocument) => {
editor.handle.openAutoSavedDocument(BigInt(doc.details.id), doc.details.name, doc.details.isSaved, doc.document);
});
if (!!currentDocumentId){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The !! is redundant here. Please also watch your formatting with there being no space between the ) and {. Your editor must be not set up to format on autosave, so you might want to get cd frontend && npm run lint-fix to run in your post-commit hook or format on save.

@Keavon
Copy link
Member

Keavon commented Jan 12, 2025

!build

Copy link

📦 Build Complete for 23a5ec0
https://96358b95.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented Jan 12, 2025

Only autosaved documents get serialized to the browser storage, which can get the indexes out of sync. Reproduction:

  1. Create an empty document and draw something
  2. Create an empty document and do nothing to it
  3. Staying on that second tab, reload the editor

@Keavon Keavon marked this pull request as draft January 12, 2025 22:24
@Keavon Keavon changed the title Fixes last tab being opened instead of last active tab Make document auto-saving include the active tab index instead of just restoring the last tab Jan 12, 2025
@mTvare6 mTvare6 force-pushed the reload-last-active-tab branch from 23a5ec0 to addf7e8 Compare January 13, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants