Handle case when app limit is exceeded
This commit is contained in:
@@ -4,14 +4,16 @@ import { useI18n } from 'vue-i18n';
|
||||
const i18n = useI18n();
|
||||
const t = i18n.t;
|
||||
|
||||
import { ref, computed, useTemplateRef, onMounted } from 'vue';
|
||||
import { ref, computed, useTemplateRef, onMounted, inject } from 'vue';
|
||||
import { Button, TextInput, Spinner, InputDialog } from 'pankow';
|
||||
import AppsModel from '../models/AppsModel.js';
|
||||
import AppstoreModel from '../models/AppstoreModel.js';
|
||||
import AppInstallDialog from '../components/AppInstallDialog.vue';
|
||||
import ApplinkDialog from '../components/ApplinkDialog.vue';
|
||||
import AppStoreItem from '../components/AppStoreItem.vue';
|
||||
import { PROXY_APP_ID } from '../constants.js';
|
||||
|
||||
const appsModel = AppsModel.create();
|
||||
const appstoreModel = AppstoreModel.create();
|
||||
|
||||
const ready = ref(false);
|
||||
@@ -40,6 +42,8 @@ const appInstallDialog = useTemplateRef('appInstallDialog');
|
||||
const searchInput = useTemplateRef('searchInput');
|
||||
const applinkDialog = useTemplateRef('applinkDialog');
|
||||
const inputDialog = useTemplateRef('inputDialog');
|
||||
const features = inject('features');
|
||||
const installedApps = ref([]);
|
||||
|
||||
function onAppInstallDialogClose() {
|
||||
window.location.href = '#/appstore';
|
||||
@@ -55,7 +59,7 @@ function onApplinkDialogSuccess() {
|
||||
|
||||
function onInstall(app) {
|
||||
window.location.href = `#/appstore/${app.manifest.id}?version=${app.manifest.version}`;
|
||||
appInstallDialog.value.open(app);
|
||||
appInstallDialog.value.open(app, installedApps.value.length >= features.value.appMaxCount);
|
||||
}
|
||||
|
||||
async function getAppList() {
|
||||
@@ -75,7 +79,15 @@ async function getApp(id, version = '') {
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getInstalledApps() {
|
||||
const [error, result] = await appsModel.list();
|
||||
if (error) return console.error(error);
|
||||
|
||||
installedApps.value = result;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getInstalledApps();
|
||||
await getAppList();
|
||||
ready.value = true;
|
||||
|
||||
@@ -87,7 +99,7 @@ onMounted(async () => {
|
||||
|
||||
const app = await getApp(appId, version);
|
||||
if (app) {
|
||||
appInstallDialog.value.open(app);
|
||||
appInstallDialog.value.open(app, installedApps.value.length >= features.value.appMaxCount);
|
||||
} else {
|
||||
inputDialog.value.info({
|
||||
title: t('appstore.appNotFoundDialog.title'),
|
||||
|
||||
Reference in New Issue
Block a user