feat: auto-subscribe push on login, better push logging

- Auto-subscribe to push on login, register, and session restore
- Guard against nil db in SendChannelNotification
- Log push send count per channel message
- Bump SW cache to v5
This commit is contained in:
2026-07-02 14:34:02 -04:00
parent 6b7dc2addd
commit a593f04d7f
3 changed files with 22 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
// Dumpster PWA Service Worker
// Bump CACHE_VERSION on each deploy to force re-cache of hashed assets.
const CACHE_VERSION = 'dumpster-v4';
const CACHE_VERSION = 'dumpster-v5';
const OFFLINE_URL = '/offline.html';
// Assets to pre-cache on install (shell files)
+13
View File
@@ -71,6 +71,16 @@ interface AuthState {
clearError: () => void;
}
// ponytail: auto-subscribe to push notifications on auth
function autoSubscribePush() {
import("../stores/push.ts").then(({ usePushStore }) => {
const ps = usePushStore.getState();
if (ps.isSupported && Notification.permission !== 'denied' && !ps.isSubscribed) {
ps.subscribe();
}
});
}
export const useAuthStore = create<AuthState>((set) => ({
user: null,
isAuthenticated: false,
@@ -86,6 +96,7 @@ export const useAuthStore = create<AuthState>((set) => ({
});
const user = await api.get<User>("/auth/me");
set({ user, isAuthenticated: true, isLoading: false });
autoSubscribePush();
} catch (error) {
set({
isLoading: false,
@@ -106,6 +117,7 @@ export const useAuthStore = create<AuthState>((set) => ({
});
const user = await api.get<User>("/auth/me");
set({ user, isAuthenticated: true, isLoading: false });
autoSubscribePush();
} catch (error) {
set({
isLoading: false,
@@ -135,6 +147,7 @@ export const useAuthStore = create<AuthState>((set) => ({
try {
const user = await api.get<User>(`/auth/me?t=${Date.now()}`);
set({ user, isAuthenticated: true, isLoading: false });
autoSubscribePush();
} catch (error) {
set({
user: null,