mirror of
https://github.com/Tony0410/nextstep.git
synced 2026-05-24 13:21:39 +08:00
Add timezone support and auto-sync push subscriptions
- Install tzdata in Docker for proper Australia/Perth timezone handling - Update VAPID email to standard placeholder - Auto-sync browser push subscriptions to server on page load Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,8 @@ RUN npm run build
|
|||||||
FROM node:20-slim AS runner
|
FROM node:20-slim AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y tzdata && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
ENV TZ=Australia/Perth
|
ENV TZ=Australia/Perth
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ services:
|
|||||||
# Push notification VAPID keys
|
# Push notification VAPID keys
|
||||||
- NEXT_PUBLIC_VAPID_PUBLIC_KEY=BEFs_VtoxY7SpNnd-ubz1ioliESlRI4sY6ny7Qp3rm7V1cm0gqyZX8TAHp4AaQ81yKC4LfWtJFQz_aHc25G-Tww
|
- NEXT_PUBLIC_VAPID_PUBLIC_KEY=BEFs_VtoxY7SpNnd-ubz1ioliESlRI4sY6ny7Qp3rm7V1cm0gqyZX8TAHp4AaQ81yKC4LfWtJFQz_aHc25G-Tww
|
||||||
- VAPID_PRIVATE_KEY=KgVQVO7XhfCklrJ3o9wowzK90AxI6Exg9pXPq76Qx4A
|
- VAPID_PRIVATE_KEY=KgVQVO7XhfCklrJ3o9wowzK90AxI6Exg9pXPq76Qx4A
|
||||||
- VAPID_EMAIL=mailto:admin@nextstep.local
|
- VAPID_EMAIL=mailto:admin@example.com
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ export function NotificationPermission({ workspaceId }: NotificationPermissionPr
|
|||||||
if (registration.pushManager) {
|
if (registration.pushManager) {
|
||||||
const subscription = await registration.pushManager.getSubscription()
|
const subscription = await registration.pushManager.getSubscription()
|
||||||
setIsSubscribed(!!subscription)
|
setIsSubscribed(!!subscription)
|
||||||
|
|
||||||
|
// Auto-sync subscription to server to ensure it exists
|
||||||
|
if (subscription) {
|
||||||
|
fetch('/api/notifications/subscribe', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
subscription: subscription.toJSON(),
|
||||||
|
workspaceId,
|
||||||
|
}),
|
||||||
|
}).catch(console.error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to check subscription:', err)
|
console.error('Failed to check subscription:', err)
|
||||||
|
|||||||
Reference in New Issue
Block a user