Fix chrome document scanning
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { Page } from '$lib/types';
|
||||
import { onMount } from 'svelte';
|
||||
import TextBoxes from './TextBoxes.svelte';
|
||||
|
||||
export let page: Page;
|
||||
export let src: File;
|
||||
|
||||
$: url = `url(${URL.createObjectURL(src)})`;
|
||||
$: url = src ? `url(${URL.createObjectURL(src)})` : '';
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
import { AccordionItem, Button } from 'flowbite-svelte';
|
||||
import { db } from '$lib/catalog/db';
|
||||
import { promptConfirmation } from '$lib/util';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
function onClear() {
|
||||
promptConfirmation('Are you sure you want to clear your catalog?', () => db.catalog.clear());
|
||||
goto('/');
|
||||
}
|
||||
</script>
|
||||
|
||||
<AccordionItem>
|
||||
<span slot="header">Catalog settings</span>
|
||||
<div class="flex flex-col">
|
||||
<Button on:click={onClear} outline color="red">Clear catalog</Button>
|
||||
</div>
|
||||
</AccordionItem>
|
||||
|
||||
@@ -64,7 +64,9 @@ export async function scanFiles(item: FileSystemEntry, files: Promise<File | und
|
||||
if (item.isDirectory) {
|
||||
const directoryReader = (item as FileSystemDirectoryEntry).createReader();
|
||||
await new Promise<void>((resolve) => {
|
||||
function readEntries() {
|
||||
directoryReader.readEntries(async (entries) => {
|
||||
if (entries.length > 0) {
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile) {
|
||||
files.push(getFile(entry as FileSystemFileEntry));
|
||||
@@ -72,8 +74,14 @@ export async function scanFiles(item: FileSystemEntry, files: Promise<File | und
|
||||
await scanFiles(entry, files);
|
||||
}
|
||||
}
|
||||
readEntries()
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
readEntries()
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -187,5 +195,7 @@ export async function processFiles(files: File[]) {
|
||||
|
||||
showSnackbar('Catalog updated successfully');
|
||||
}
|
||||
} else {
|
||||
showSnackbar('Missing .mokuro file');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user