chore(web): cleanup promise handling (#7382)

* no-misused-promises

* no-floating-promises

* format

* revert for now

* remove load function

* require-await

* revert a few no-floating-promises changes that would cause no-misused-promises failures

* format

* fix a few more

* fix most remaining errors

* executor-queue

* executor-queue.spec

* remove duplicate comments by grouping rules

* upgrade sveltekit and enforce rules

* oops. move await

* try this

* just ignore for now since it's only a test

* run in parallel

* Update web/src/routes/admin/jobs-status/+page.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* remove Promise.resolve call

* rename function

* remove unnecessary warning silencing

* make handleError sync

* fix new errors from recently merged PR to main

* extract method

* use handlePromiseError

---------

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Ben McCann 2024-02-27 08:37:37 -08:00 committed by GitHub
parent 57f25855d3
commit 907a95a746
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
70 changed files with 312 additions and 282 deletions

View file

@ -56,8 +56,8 @@
let selectedLibraryIndex = 0;
let selectedLibrary: LibraryResponseDto | null = null;
onMount(() => {
readLibraryList();
onMount(async () => {
await readLibraryList();
});
const closeAll = () => {
@ -234,11 +234,11 @@
updateLibraryIndex = selectedLibraryIndex;
};
const onScanNewLibraryClicked = () => {
const onScanNewLibraryClicked = async () => {
closeAll();
if (selectedLibrary) {
handleScan(selectedLibrary.id);
await handleScan(selectedLibrary.id);
}
};
@ -248,38 +248,38 @@
updateLibraryIndex = selectedLibraryIndex;
};
const onScanAllLibraryFilesClicked = () => {
const onScanAllLibraryFilesClicked = async () => {
closeAll();
if (selectedLibrary) {
handleScanChanges(selectedLibrary.id);
await handleScanChanges(selectedLibrary.id);
}
};
const onForceScanAllLibraryFilesClicked = () => {
const onForceScanAllLibraryFilesClicked = async () => {
closeAll();
if (selectedLibrary) {
handleForceScan(selectedLibrary.id);
await handleForceScan(selectedLibrary.id);
}
};
const onRemoveOfflineFilesClicked = () => {
const onRemoveOfflineFilesClicked = async () => {
closeAll();
if (selectedLibrary) {
handleRemoveOffline(selectedLibrary.id);
await handleRemoveOffline(selectedLibrary.id);
}
};
const onDeleteLibraryClicked = () => {
const onDeleteLibraryClicked = async () => {
closeAll();
if (selectedLibrary && confirm(`Are you sure you want to delete ${selectedLibrary.name} library?`) == true) {
refreshStats(selectedLibraryIndex);
await refreshStats(selectedLibraryIndex);
if (totalCount[selectedLibraryIndex] > 0) {
deleteAssetCount = totalCount[selectedLibraryIndex];
confirmDeleteLibrary = selectedLibrary;
} else {
deletedLibrary = selectedLibrary;
handleDelete();
await handleDelete();
}
}
};
@ -348,27 +348,27 @@
{#if showContextMenu}
<Portal target="body">
<ContextMenu {...contextMenuPosition} on:outclick={() => onMenuExit()}>
<MenuOption on:click={() => onRenameClicked()} text={`Rename`} />
<ContextMenu {...contextMenuPosition} on:outclick={onMenuExit}>
<MenuOption on:click={onRenameClicked} text={`Rename`} />
{#if selectedLibrary && selectedLibrary.type === LibraryType.External}
<MenuOption on:click={() => onEditImportPathClicked()} text="Edit Import Paths" />
<MenuOption on:click={() => onScanSettingClicked()} text="Scan Settings" />
<MenuOption on:click={onEditImportPathClicked} text="Edit Import Paths" />
<MenuOption on:click={onScanSettingClicked} text="Scan Settings" />
<hr />
<MenuOption on:click={() => onScanNewLibraryClicked()} text="Scan New Library Files" />
<MenuOption on:click={onScanNewLibraryClicked} text="Scan New Library Files" />
<MenuOption
on:click={() => onScanAllLibraryFilesClicked()}
on:click={onScanAllLibraryFilesClicked}
text="Re-scan All Library Files"
subtitle={'Only refreshes modified files'}
/>
<MenuOption
on:click={() => onForceScanAllLibraryFilesClicked()}
on:click={onForceScanAllLibraryFilesClicked}
text="Force Re-scan All Library Files"
subtitle={'Refreshes every file'}
/>
<hr />
<MenuOption on:click={() => onRemoveOfflineFilesClicked()} text="Remove Offline Files" />
<MenuOption on:click={() => onDeleteLibraryClicked()}>
<MenuOption on:click={onRemoveOfflineFilesClicked} text="Remove Offline Files" />
<MenuOption on:click={onDeleteLibraryClicked}>
<p class="text-red-600">Delete library</p>
</MenuOption>
{/if}

View file

@ -28,7 +28,7 @@
} catch (error) {
handleError(error, 'Unable to link OAuth account');
} finally {
goto('?open=oauth');
await goto('?open=oauth');
}
}

View file

@ -31,8 +31,8 @@
let removePartnerDto: PartnerResponseDto | null = null;
let partners: Array<PartnerSharing> = [];
onMount(() => {
refreshPartners();
onMount(async () => {
await refreshPartners();
});
const refreshPartners = async () => {