Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(cloud): address review feedback on toast feedback and site address

Timothy Yine44c0f08b974
diff --git a/apps/cloud/app/components/CloudSitePublication.vue b/apps/cloud/app/components/CloudSitePublication.vue
index 5dcc8aec..e513dc40 100644
--- a/apps/cloud/app/components/CloudSitePublication.vue
+++ b/apps/cloud/app/components/CloudSitePublication.vue
@@ -9,7 +9,7 @@ const context = shallowRef(activeContext.value)
watch(activeContext, (next) => {
if (next?.scope === context.value?.scope) context.value = next
})
-const { admin, busy, failed, message, publish } = useCloudSiteMedia()
+const { admin, busy, publish } = useCloudSiteMedia()
const { data, status, error, refresh } = useFetch<{
site: {
slug: string | null
@@ -23,6 +23,7 @@ const {
refresh: refreshDomains,
} = useFetch<DomainOverview>(`/api/sites/${context.value?.siteId}/domains`)
const customHost = computed(() => {
+ if (!domainOverview.value?.enabled) return undefined
const eligible =
domainOverview.value?.domains.filter(
(d) => d.status === 'active' && !d.holdReason && !d.cleanupPending,
@@ -59,20 +60,22 @@ async function copyAddress() {
})
}
}
-watch(domainError, (err) => {
- if (err)
- toast.add({
- title: t('cloud.domains.loadFailed'),
- color: 'error',
- actions: [
- { label: t('cloud.messages.retry'), onClick: () => refreshDomains() },
- ],
- })
-})
+watch(
+ domainError,
+ (err) => {
+ if (err)
+ toast.add({
+ title: t('cloud.domains.loadFailed'),
+ color: 'error',
+ actions: [
+ { label: t('cloud.messages.retry'), onClick: () => refreshDomains() },
+ ],
+ })
+ },
+ { immediate: true },
+)
async function unpublish() {
await publish(false)
- if (failed.value)
- toast.add({ title: message.value, color: 'error' })
if (!context.value?.published) unpublishOpen.value = false
}
</script>
diff --git a/apps/cloud/app/components/CloudSiteWorkspace.vue b/apps/cloud/app/components/CloudSiteWorkspace.vue
index 5239e8eb..da70c76a 100644
--- a/apps/cloud/app/components/CloudSiteWorkspace.vue
+++ b/apps/cloud/app/components/CloudSiteWorkspace.vue
@@ -22,10 +22,14 @@ const { photos, loading, message, failed, reload, loadError, refreshMedia } =
media
const status = computed(() => (loading.value ? 'pending' : 'success'))
const toast = useToast()
-watch(message, (text) => {
- if (text && text !== loadError.value)
- toast.add({ title: text, color: failed.value ? 'error' : 'success' })
-})
+watch(
+ message,
+ (text) => {
+ if (text && text !== loadError.value)
+ toast.add({ title: text, color: failed.value ? 'error' : 'success' })
+ },
+ { flush: 'sync' },
+)
</script>
<template>
<PhotosProvider
diff --git a/apps/cloud/app/composables/useCloudSiteMedia.ts b/apps/cloud/app/composables/useCloudSiteMedia.ts
index 48dd4e8e..02896c4b 100644
--- a/apps/cloud/app/composables/useCloudSiteMedia.ts
+++ b/apps/cloud/app/composables/useCloudSiteMedia.ts
@@ -301,6 +301,7 @@ export function useCloudMediaWorkspace(props: {
} catch {
if (editPhoto.id !== id || generation !== photoLoadGeneration) return
failed.value = true
+ message.value = ''
message.value = t(
'cloud.messages.couldNotLoadPhotographSettingsSelectItAgainTo',
)
@@ -366,6 +367,7 @@ export function useCloudMediaWorkspace(props: {
)
) {
failed.value = true
+ message.value = ''
message.value = t(
'cloud.messages.eachPhotographAndItsMatchingLivePhotoMovMust',
)
diff --git a/apps/cloud/app/pages/sites/[siteId]/domains.vue b/apps/cloud/app/pages/sites/[siteId]/domains.vue
index dd41ea33..307cb59c 100644
--- a/apps/cloud/app/pages/sites/[siteId]/domains.vue
+++ b/apps/cloud/app/pages/sites/[siteId]/domains.vue
@@ -169,6 +169,7 @@ async function rename() {
})
}
async function copy(value: string) {
+ notice.value = ''
try {
await navigator.clipboard.writeText(value)
failure.value = false
diff --git a/tests/cloud-map-save.test.ts b/tests/cloud-map-save.test.ts
index b5881b94..d83adf1e 100644
--- a/tests/cloud-map-save.test.ts
+++ b/tests/cloud-map-save.test.ts
@@ -28,11 +28,15 @@ test('successful map PUT updates revision, role and the live map without a follo
target: ts.ScriptTarget.ES2022,
},
}).outputText
+ const toasts: { title: string; color: string }[] = []
const form = (await vm.runInNewContext(
- `(async()=>{${code};return {save,own,draft,busy,message,failed}})()`,
+ `(async()=>{${code};return {save,own,draft,busy}})()`,
{
ref,
defineProps: () => ({ siteId: 1 }),
+ useToast: () => ({
+ add: (t: { title: string; color: string }) => toasts.push(t),
+ }),
useI18n: () => ({ locale: ref('en') }),
useSettingsStore: () => store,
useEntryContext: () => ref({ siteId: 1 }),
@@ -61,8 +65,6 @@ test('successful map PUT updates revision, role and the live map without a follo
own: { value: boolean }
draft: { value: Record<string, string> }
busy: { value: boolean }
- message: { value: string }
- failed: { value: boolean }
}
form.own.value = true
form.draft.value['maplibre.token'] = 'new_public_browser_key'
@@ -73,6 +75,7 @@ test('successful map PUT updates revision, role and the live map without a follo
assert.equal(data.value.role, 'admin')
assert.equal(store.data.map['maplibre.token'], 'new_public_browser_key')
assert.equal(form.busy.value, false)
- assert.equal(form.failed.value, false)
- assert.equal(form.message.value, 'Map settings saved.')
+ assert.deepEqual(JSON.parse(JSON.stringify(toasts)), [
+ { title: 'Map settings saved.', color: 'success' },
+ ])
})