refactor: the kept versions are offered at a failed load, not in the menu
A list of timestamps in both file menus paid for itself only on the day something went wrong, and it was in the way on every other. The entries are gone; loadDocument now offers the versions where the browser copy has actually failed the reader — newest first, one question each, and the one taken up starts under the boot flag like any other document. The store loses its reactive singleton with them.
This commit is contained in:
1 parent
ea327174e8
commit
6abc7f7704
11 files changed
+109
-104
No files matched your search
@@ -46,7 +46,6 @@
|
||||
import { loadLineNumbering, saveLineNumbering, DEFAULT_LINE_NUMBERING, type LineNumbering } from './lib/storage/lineNumbering';
|
||||
import { loadFoldMarks, saveFoldMarks } from './lib/storage/foldMarks';
|
||||
import { printMarkup } from './lib/storage/printMarkup.svelte';
|
||||
import { snapshots, loadSnapshots, readSnapshot } from './lib/storage/snapshots.svelte';
|
||||
import { commentsInPane, changesInPane, markupAttrs, setShowChanges, setShowComments } from './lib/storage/markup.svelte';
|
||||
import { loadDocumentLanguage, saveDocumentLanguage, odfFromLanguage, type DocumentLanguage } from './lib/storage/documentLanguage';
|
||||
import { setTableLanguage } from './lib/storage/tableOptions.svelte';
|
||||
@@ -1071,29 +1070,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The versions the autosave keeps aside, and the reader's label for one.
|
||||
void loadSnapshots();
|
||||
function snapshotLabel(at: number): string {
|
||||
return new Date(at).toLocaleString(locale(), { dateStyle: 'short', timeStyle: 'short' });
|
||||
}
|
||||
|
||||
// Put an earlier version's text back. The page setup, the styles and the zones
|
||||
// belong to the open document, so only the text is replaced.
|
||||
async function handleRestoreSnapshot(at: number) {
|
||||
exportMenuOpen = false;
|
||||
if (!editor || !confirm(t().dialogs.confirmRestore(snapshotLabel(at)))) return;
|
||||
const json = await readSnapshot(at);
|
||||
if (!json) {
|
||||
alert(t().dialogs.snapshotGone);
|
||||
void loadSnapshots();
|
||||
return;
|
||||
}
|
||||
loadContent(json as Content);
|
||||
documentEpoch++;
|
||||
resetHistory();
|
||||
editor.commands.focus();
|
||||
}
|
||||
|
||||
function handleForgetRecent() {
|
||||
forgetRecentFiles();
|
||||
recentFiles = [];
|
||||
@@ -1371,8 +1347,6 @@
|
||||
recentFiles={recentFiles}
|
||||
onOpenRecent={(id) => { const f = recentFiles.find((r) => r.id === id); if (f) void handleOpenRecent(f); }}
|
||||
onForgetRecent={handleForgetRecent}
|
||||
snapshots={snapshots().map((at) => ({ at, label: snapshotLabel(at) }))}
|
||||
onRestoreSnapshot={(at) => void handleRestoreSnapshot(at)}
|
||||
onExportPdf={handleExportPdf}
|
||||
onPrintPdf={handlePrintPdf}
|
||||
onPrint={handlePrint}
|
||||
@@ -1510,14 +1484,6 @@
|
||||
<span class="theme-option-hint">{t().app.clearRecentFiles}</span>
|
||||
</button>
|
||||
{/if}
|
||||
{#if snapshots().length}
|
||||
<div class="theme-heading">{t().app.versions}</div>
|
||||
{#each snapshots() as at (at)}
|
||||
<button class="theme-option" onclick={() => handleRestoreSnapshot(at)} role="menuitem">
|
||||
<span class="recent-name">{snapshotLabel(at)}</span>
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
<button class="theme-option" onclick={() => { exportMenuOpen = false; passwordSetOpen = true; }} role="menuitem">
|
||||
<span>{t().password.menu}</span>
|
||||
{#if docProtected}<span class="theme-option-hint">{t().password.menuOn}</span>{/if}
|
||||
|
||||
Reference in new issue
Block a user