Skip to content

Commit 910ee88

Browse files
committed
chore: fix build
1 parent 50cdcb0 commit 910ee88

File tree

15 files changed

+98
-60
lines changed

15 files changed

+98
-60
lines changed

infrastructure/eid-wallet/src/lib/services/NotificationService.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { PUBLIC_PROVISIONER_URL } from "$env/static/public";
2+
import { addNotification } from "$lib/stores/notifications";
23
import {
34
isPermissionGranted,
45
registerForPushNotifications,
56
requestPermission,
67
sendNotification,
78
} from "@choochmeque/tauri-plugin-notifications-api";
89
import { invoke } from "@tauri-apps/api/core";
9-
import { addNotification } from "$lib/stores/notifications";
1010

1111
export interface DeviceRegistration {
1212
eName: string;
@@ -119,12 +119,19 @@ class NotificationService {
119119
*/
120120
async sendLocalNotification(payload: NotificationPayload): Promise<void> {
121121
try {
122-
// Store notification for the notification panel
123-
const data = payload.data as Record<string, string> | undefined;
122+
// Store notification for the notification panel — coerce to string values only
123+
const data = payload.data
124+
? Object.fromEntries(
125+
Object.entries(payload.data).filter(
126+
(entry): entry is [string, string] =>
127+
typeof entry[1] === "string",
128+
),
129+
)
130+
: undefined;
124131
addNotification({
125132
title: payload.title,
126133
body: payload.body,
127-
data,
134+
data: Object.keys(data ?? {}).length > 0 ? data : undefined,
128135
});
129136

130137
// Check permissions first
@@ -202,6 +209,8 @@ class NotificationService {
202209
async checkAndShowNotifications(): Promise<{
203210
globalMessageId?: string;
204211
globalChatId?: string;
212+
title?: string;
213+
body?: string;
205214
} | null> {
206215
try {
207216
console.log("🔍 Checking for notifications from provisioner...");
@@ -273,7 +282,8 @@ class NotificationService {
273282
`Found ${data.notifications.length} notification(s)`,
274283
);
275284

276-
// Show each notification locally
285+
// Show each notification locally — intentionally keep only the
286+
// most recent new_message so the caller navigates to it.
277287
let lastMessageNotif: {
278288
globalMessageId?: string;
279289
globalChatId?: string;
@@ -293,17 +303,15 @@ class NotificationService {
293303
}
294304
}
295305
return lastMessageNotif;
296-
} else {
297-
console.log("No new notifications");
298-
return null;
299306
}
300-
} else {
301-
console.log(
302-
"No notifications endpoint available or error:",
303-
response.status,
304-
);
307+
console.log("No new notifications");
305308
return null;
306309
}
310+
console.log(
311+
"No notifications endpoint available or error:",
312+
response.status,
313+
);
314+
return null;
307315
} catch (error) {
308316
console.error("Error checking notifications:", error);
309317
return null;
@@ -318,7 +326,7 @@ class NotificationService {
318326
await this.sendLocalNotification({
319327
title: "Test Notification",
320328
body: "This is a test notification from eid-wallet!",
321-
data: { test: true, timestamp: new Date().toISOString() },
329+
data: { test: "true", timestamp: new Date().toISOString() },
322330
});
323331
}
324332

infrastructure/eid-wallet/src/lib/stores/notifications.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ export interface StoredNotification {
77
}
88

99
const STORAGE_KEY = "eid_wallet_notifications";
10+
const MAX_NOTIFICATIONS = 200;
11+
12+
let cachedNotifications: StoredNotification[] | null = null;
1013

1114
function loadNotifications(): StoredNotification[] {
15+
if (cachedNotifications !== null) return cachedNotifications;
1216
try {
1317
const raw = localStorage.getItem(STORAGE_KEY);
14-
return raw ? JSON.parse(raw) : [];
18+
const parsed: StoredNotification[] = raw ? JSON.parse(raw) : [];
19+
cachedNotifications = parsed;
20+
return parsed;
1521
} catch {
16-
return [];
22+
cachedNotifications = [];
23+
return cachedNotifications;
1724
}
1825
}
1926

2027
function saveNotifications(notifications: StoredNotification[]): void {
28+
cachedNotifications = notifications;
2129
localStorage.setItem(STORAGE_KEY, JSON.stringify(notifications));
2230
}
2331

@@ -51,7 +59,7 @@ export function addNotification(
5159
id: crypto.randomUUID(),
5260
createdAt: new Date().toISOString(),
5361
});
54-
saveNotifications(notifications);
62+
saveNotifications(notifications.slice(0, MAX_NOTIFICATIONS));
5563
notify();
5664
}
5765

infrastructure/eid-wallet/src/routes/(app)/main/+page.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import {
77
} from "$env/static/public";
88
import { Hero, IdentityCard } from "$lib/fragments";
99
import type { GlobalState } from "$lib/global";
10+
import {
11+
getUnreadCount,
12+
subscribe as subscribeNotifications,
13+
} from "$lib/stores/notifications";
1014
import { BottomSheet, Toast } from "$lib/ui";
1115
import * as Button from "$lib/ui/Button";
1216
import { capitalize } from "$lib/utils";
@@ -20,10 +24,6 @@ import { HugeiconsIcon } from "@hugeicons/svelte";
2024
import axios from "axios";
2125
import { type Snippet, getContext, onMount } from "svelte";
2226
import { onDestroy } from "svelte";
23-
import {
24-
getUnreadCount,
25-
subscribe as subscribeNotifications,
26-
} from "$lib/stores/notifications";
2727
import { Shadow } from "svelte-loading-spinners";
2828
import QrCode from "svelte-qrcode";
2929
@@ -522,7 +522,7 @@ onDestroy(() => {
522522
</Hero>
523523

524524
<div class="flex items-center gap-2">
525-
<Button.Nav href="/notifications" class="relative">
525+
<Button.Nav href="/notifications" class="relative" aria-label={notificationCount > 0 ? `Notifications (${notificationCount} unread)` : "Notifications"}>
526526
<HugeiconsIcon
527527
size={28}
528528
strokeWidth={2}
@@ -537,7 +537,7 @@ onDestroy(() => {
537537
</span>
538538
{/if}
539539
</Button.Nav>
540-
<Button.Nav href="/settings">
540+
<Button.Nav href="/settings" aria-label="Settings">
541541
<HugeiconsIcon
542542
size={32}
543543
strokeWidth={2}

infrastructure/eid-wallet/src/routes/(app)/notifications/+page.svelte

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import { goto } from "$app/navigation";
33
import { AppNav } from "$lib/fragments";
44
import {
5-
getNotifications,
6-
clearNotificationsForChat,
5+
type StoredNotification,
76
clearAllNotifications,
7+
clearNotificationsForChat,
8+
getNotifications,
89
subscribe,
9-
type StoredNotification,
1010
} from "$lib/stores/notifications";
11-
import { onMount, onDestroy } from "svelte";
11+
import { onDestroy, onMount } from "svelte";
1212
1313
let notifications: StoredNotification[] = $state([]);
1414
let unsubscribe: (() => void) | undefined;
@@ -28,14 +28,17 @@ onDestroy(() => {
2828
2929
function handleNotificationClick(notification: StoredNotification) {
3030
const data = notification.data;
31-
if (data?.type === "new_message" && data.globalMessageId) {
31+
if (
32+
data?.type === "new_message" &&
33+
(data.globalMessageId || data.globalChatId)
34+
) {
35+
const messageId = data.globalMessageId || data.globalChatId || "";
36+
const chatId = data.globalChatId ?? messageId;
3237
// Clear all notifications from the same chat
33-
if (data.globalChatId) {
34-
clearNotificationsForChat(data.globalChatId);
35-
}
38+
clearNotificationsForChat(chatId);
3639
// Navigate to open-message page
3740
goto(
38-
`/open-message/${encodeURIComponent(data.globalMessageId)}?chatId=${encodeURIComponent(data.globalChatId || data.globalMessageId)}&title=${encodeURIComponent(notification.title)}&body=${encodeURIComponent(notification.body)}`,
41+
`/open-message/${encodeURIComponent(messageId)}?chatId=${encodeURIComponent(chatId)}&title=${encodeURIComponent(notification.title)}&body=${encodeURIComponent(notification.body)}`,
3942
);
4043
}
4144
}

infrastructure/eid-wallet/src/routes/(app)/settings/+page.svelte

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,12 @@ $effect(() => {
140140
label="Recovery Passphrase"
141141
href="/settings/passphrase"
142142
/>
143-
<!-- svelte-ignore a11y_no_static_element_interactions -->
144-
<div onclick={openPrivacy}>
145-
<SettingsNavigationBtn
146-
icon={Shield01Icon}
147-
label="Privacy"
148-
href="https://metastate.foundation/"
149-
/>
150-
</div>
143+
<SettingsNavigationBtn
144+
icon={Shield01Icon}
145+
label="Privacy"
146+
href="https://metastate.foundation/"
147+
onclick={openPrivacy}
148+
/>
151149
</div>
152150
<div>
153151
<ButtonAction class="mt-5 w-full" callback={showDeleteConfirmation}

infrastructure/eid-wallet/src/routes/(auth)/verify/steps/selfie.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async function captureImage() {
108108
<div
109109
class="relative mt-3 flex flex-col items-center justify-center"
110110
>
111-
<!-- svelte-ignore a11y-media-has-caption -->
111+
<!-- svelte-ignore a11y_media_has_caption -->
112112
<video
113113
bind:this={video}
114114
autoplay

infrastructure/eid-wallet/src/routes/(public)/open-message/[globalId]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
22
import { page } from "$app/state";
33
import {
4-
PUBLIC_PICTIQUE_BASE_URL,
54
PUBLIC_BLABSY_BASE_URL,
5+
PUBLIC_PICTIQUE_BASE_URL,
66
} from "$env/static/public";
77
88
const globalId = page.params.globalId;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const prerender = false;
2+
export const ssr = false;

infrastructure/eid-wallet/svelte.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
88
const config = {
99
preprocess: vitePreprocess(),
1010
kit: {
11-
adapter: adapter(),
11+
adapter: adapter({
12+
fallback: "200.html",
13+
}),
1214
env: {
1315
dir: "../../",
1416
},

infrastructure/evault-core/src/core/protocol/graphql-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,8 @@ export class GraphQLServer {
755755
this.deliverWebhooks(
756756
requestingPlatform,
757757
webhookPayload,
758-
).catch(() => {
759-
// Silenced webhook delivery logs
758+
).catch((err) => {
759+
console.error(`[WEBHOOK] Delivery failed for bulk-create envelope ${result.metaEnvelope.id}:`, err);
760760
});
761761
}
762762

0 commit comments

Comments
 (0)