1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00

App update validation updates

This commit is contained in:
Dean 2023-06-29 16:51:32 +01:00
parent 8d98f6ac02
commit a5dae87fa9
4 changed files with 27 additions and 6 deletions

View file

@ -348,7 +348,7 @@
name: $store.name,
url: $store.url,
icon: $store.icon,
devId: $store.appId,
appId: $store.appId,
}}
onUpdateComplete={async () => {
await initialiseApp()

View file

@ -16,6 +16,9 @@
export let app
export let onUpdateComplete
$: appIdParts = app.appId ? app.appId?.split("_") : []
$: appId = appIdParts.slice(-1)[0]
const values = writable({
name: app.name,
url: app.url,
@ -35,8 +38,20 @@
const setupValidation = async () => {
const applications = svelteGet(apps)
appValidation.name(validation, { apps: applications, currentApp: app })
appValidation.url(validation, { apps: applications, currentApp: app })
appValidation.name(validation, {
apps: applications,
currentApp: {
...app,
appId,
},
})
appValidation.url(validation, {
apps: applications,
currentApp: {
...app,
appId,
},
})
// init validation
const { url } = $values
validation.check({
@ -47,7 +62,7 @@
async function updateApp() {
try {
await apps.update(app.devId, {
await apps.update(app.appId, {
name: $values.name?.trim(),
url: $values.url?.trim(),
icon: {

View file

@ -52,7 +52,13 @@ export const url = (validation, { apps, currentApp } = { apps: [] }) => {
}
return !apps
.map(app => app.url)
.some(appUrl => appUrl?.toLowerCase() === value.toLowerCase())
.some(appUrl => {
const url =
appUrl?.[0] === "/"
? appUrl.substring(1, appUrl.length)
: appUrl
return url?.toLowerCase() === value.toLowerCase()
})
}
)
.test("valid-url", "Not a valid URL", value => {

View file

@ -78,7 +78,7 @@
name: $store.name,
url: $store.url,
icon: $store.icon,
devId: $store.appId,
appId: $store.appId,
}}
onUpdateComplete={async () => {
await initialiseApp()