feat: enhance push notification service worker for chore expirations and update related configurations
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m22s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m22s
This commit is contained in:
@@ -112,7 +112,6 @@ function handleChoreItemReady(itemId: string) {
|
||||
}
|
||||
|
||||
function handleTaskTriggered(event: Event) {
|
||||
console.log('Task triggered, refreshing rewards list -> ', childRewardListRef.value)
|
||||
const payload = event.payload as ChildTaskTriggeredEventPayload
|
||||
if (child.value && payload.child_id == child.value.id) {
|
||||
child.value.points = payload.points
|
||||
@@ -633,6 +632,33 @@ function applyHighlightPulse(itemId: string) {
|
||||
}, 200)
|
||||
}
|
||||
|
||||
// Handle digestToken appearing in route query (e.g. SW navigates to same route with new token)
|
||||
watch(
|
||||
() => route.query.digestToken,
|
||||
async (token) => {
|
||||
if (typeof token !== 'string' || !token) return
|
||||
try {
|
||||
const res = await fetch(`/api/digest-action/${token}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
})
|
||||
const data = await res.json().catch(() => ({}))
|
||||
console.log('[ParentView] digest-action POST status=', res.status, 'body=', data)
|
||||
} catch (e) {
|
||||
console.warn('[ParentView] Digest action request failed:', e)
|
||||
}
|
||||
// Refresh chore and reward lists to reflect the action result
|
||||
childChoreListRef.value?.refresh()
|
||||
childRewardListRef.value?.refresh()
|
||||
if (child.value?.id) {
|
||||
const updated = await fetchChildData(child.value.id)
|
||||
if (updated) {
|
||||
child.value = updated
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
eventBus.on('child_task_triggered', handleTaskTriggered)
|
||||
@@ -665,12 +691,8 @@ onMounted(async () => {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
})
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}))
|
||||
console.warn('Digest action failed:', data.error || res.status)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Digest action request failed:', e)
|
||||
console.warn('[ParentView] onMounted digest action request failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,6 +714,8 @@ onMounted(async () => {
|
||||
childRewardListRef.value?.scrollToItem(scrollToId)
|
||||
applyHighlightPulse(scrollToId)
|
||||
}
|
||||
const { scrollTo: _s, entityType: _e, ...remainingQuery } = route.query
|
||||
router.replace({ query: remainingQuery })
|
||||
}, 500)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user