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
70 changed files with 312 additions and 282 deletions
+10 -10
View File
@@ -81,12 +81,12 @@
const onKeyboardPress = (event: KeyboardEvent) => handleKeyboardPress(event);
onMount(() => {
onMount(async () => {
document.addEventListener('keydown', onKeyboardPress);
const getSearchedPeople = $page.url.searchParams.get(QueryParameter.SEARCHED_PEOPLE);
if (getSearchedPeople) {
searchName = getSearchedPeople;
handleSearchPeople(true);
await handleSearchPeople(true);
}
});
@@ -108,10 +108,10 @@
}
};
const handleSearch = (force: boolean) => {
const handleSearch = async (force: boolean) => {
$page.url.searchParams.set(QueryParameter.SEARCHED_PEOPLE, searchName);
goto($page.url);
handleSearchPeople(force);
await goto($page.url);
await handleSearchPeople(force);
};
const handleCloseClick = () => {
@@ -293,8 +293,8 @@
}
};
const handleMergePeople = (detail: PersonResponseDto) => {
goto(
const handleMergePeople = async (detail: PersonResponseDto) => {
await goto(
`${AppRoute.PEOPLE}/${detail.id}?${QueryParameter.ACTION}=${ActionQueryParameterValue.MERGE}&${QueryParameter.PREVIOUS_ROUTE}=${AppRoute.PEOPLE}`,
);
};
@@ -303,7 +303,7 @@
if (searchName === '') {
if ($page.url.searchParams.has(QueryParameter.SEARCHED_PEOPLE)) {
$page.url.searchParams.delete(QueryParameter.SEARCHED_PEOPLE);
goto($page.url);
await goto($page.url);
}
return;
}
@@ -331,7 +331,7 @@
return;
}
if (personName === '') {
changeName();
await changeName();
return;
}
const data = await searchPerson({ name: personName, withHidden: true });
@@ -359,7 +359,7 @@
.slice(0, 3);
return;
}
changeName();
await changeName();
};
const submitBirthDateChange = async (value: string) => {
@@ -185,7 +185,7 @@
}
};
const handleEscape = () => {
const handleEscape = async () => {
if ($showAssetViewer || viewMode === ViewMode.SUGGEST_MERGE) {
return;
}
@@ -193,7 +193,7 @@
assetInteractionStore.clearMultiselect();
return;
} else {
goto(previousRoute);
await goto(previousRoute);
return;
}
};
@@ -235,7 +235,7 @@
type: NotificationType.Info,
});
goto(previousRoute, { replaceState: true });
await goto(previousRoute, { replaceState: true });
} catch (error) {
handleError(error, 'Unable to hide person');
}
@@ -244,7 +244,7 @@
const handleMerge = async (person: PersonResponseDto) => {
const { assets } = await getPersonStatistics({ id: person.id });
numberOfAssets = assets;
handleGoBack();
await handleGoBack();
data.person = person;
@@ -292,7 +292,7 @@
refreshAssetGrid = !refreshAssetGrid;
return;
}
goto(`${AppRoute.PEOPLE}/${personToBeMergedIn.id}`, { replaceState: true });
await goto(`${AppRoute.PEOPLE}/${personToBeMergedIn.id}`, { replaceState: true });
} catch (error) {
handleError(error, 'Unable to save name');
}
@@ -341,7 +341,7 @@
return;
}
if (name === '') {
changeName();
await changeName();
return;
}
@@ -366,7 +366,7 @@
viewMode = ViewMode.SUGGEST_MERGE;
return;
}
changeName();
await changeName();
};
const handleSetBirthDate = async (birthDate: string) => {
@@ -392,11 +392,11 @@
}
};
const handleGoBack = () => {
const handleGoBack = async () => {
viewMode = ViewMode.VIEW_ASSETS;
if ($page.url.searchParams.has(QueryParameter.ACTION)) {
$page.url.searchParams.delete(QueryParameter.ACTION);
goto($page.url);
await goto($page.url);
}
};
</script>
@@ -2,6 +2,6 @@ import { AppRoute } from '$lib/constants';
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
export const load = (async ({ params }) => {
export const load = (({ params }) => {
redirect(302, `${AppRoute.PEOPLE}/${params.personId}`);
}) satisfies PageLoad;