Use common return value pattern in AppstoreModel

This commit is contained in:
Johannes Zellner
2025-04-09 18:24:24 +02:00
parent b391f4bc12
commit 0e944f7d8a
2 changed files with 28 additions and 19 deletions

View File

@@ -53,8 +53,25 @@ function onInstall(app) {
appInstallDialog.value.open(app);
}
async function getAppList() {
const [error, result] = await appstoreModel.list();
if (error) return console.error(error);
apps.value = result;
}
async function getApp(id, version = '') {
const [error, result] = await appstoreModel.get(id, version);
if (error) {
console.error(error);
return null;
}
return result;
}
onMounted(async () => {
apps.value = await appstoreModel.list();
await getAppList();
ready.value = true;
const query = window.location.hash.slice('#/appstore/'.length);
@@ -62,7 +79,7 @@ onMounted(async () => {
const appId = query.split('?')[0];
const version = query.slice(query.indexOf('version=')+'version='.length);
const app = await appstoreModel.get(appId, version);
const app = await getApp(appId, version);
if (app) {
appInstallDialog.value.open(app);
} else {
@@ -72,7 +89,7 @@ onMounted(async () => {
searchInput.value.$el.focus();
}
proxyApp.value = await appstoreModel.get(PROXY_APP_ID);
proxyApp.value = await getApp(PROXY_APP_ID);
});
</script>