fix: wrong database loading progress display

This commit is contained in:
duskflower 2025-01-25 13:13:22 +01:00
parent a9dda69fef
commit fc9d42f48d
2 changed files with 5 additions and 4 deletions

View file

@ -9,8 +9,8 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
);
}
// polyfill umami track function for development
if (import.meta.env.DEV && !("umami" in window)) {
// polyfill umami track function for cases where it may not be able to get loaded and development
if (!("umami" in window)) {
// @ts-ignore
window.umami = {
// biome-ignore lint/suspicious/noEmptyBlockStatements: <explanation>

View file

@ -48,12 +48,13 @@ export const Home: Component<RouteSectionProps> = () => {
decryptBackup(currentBackupFile, currentPassphrase, setDecryptionProgress, async (statements) => {
const length = statements.length;
setTotalStatements((oldValue) => oldValue + length);
const prevExecutedStatements = executedStatements();
await loadDb(statements, (progress) => {
setExecutedStatements((oldValue) => Math.round(oldValue + (progress / 100) * length));
setExecutedStatements(Math.round(prevExecutedStatements + (progress / 100) * length));
});
setExecutedStatements((oldValue) => oldValue + length);
setExecutedStatements(prevExecutedStatements + length);
})
.then(() => {
umami.track("Decrypt backup");