@rpcbase/client 0.436.0 → 0.438.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2255,6 +2255,20 @@ const markNotificationRead = async (notificationId) => {
2255
2255
  throw new Error(result?.error || "Failed to mark notification read");
2256
2256
  }
2257
2257
  };
2258
+ const markNotificationsReadByUrl = async (url) => {
2259
+ const normalizedUrl = url.trim();
2260
+ if (!normalizedUrl) throw new Error("url is required");
2261
+ const result = await apiClient.post("/api/rb/notifications/mark-read-by-url", {
2262
+ url: normalizedUrl
2263
+ });
2264
+ if (!result?.ok) {
2265
+ throw new Error(result?.error || "Failed to mark notifications read");
2266
+ }
2267
+ return {
2268
+ matchedCount: Number.isFinite(result.matchedCount) ? Math.max(0, Math.floor(result.matchedCount ?? 0)) : 0,
2269
+ modifiedCount: Number.isFinite(result.modifiedCount) ? Math.max(0, Math.floor(result.modifiedCount ?? 0)) : 0
2270
+ };
2271
+ };
2258
2272
  const archiveNotification = async (notificationId) => {
2259
2273
  const id = notificationId.trim();
2260
2274
  if (!id) throw new Error("notificationId is required");
@@ -2314,6 +2328,7 @@ const DELIVERY_KEY_PREFIX = "rb:notifications:delivery:";
2314
2328
  const DELIVERY_LOCK_PREFIX = "rb-notifications-delivery:";
2315
2329
  const FALLBACK_DELIVERY_LOCK_KEY_PREFIX = "rb:notifications:delivery-lock:";
2316
2330
  const NOTIFICATION_TAB_ID = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2331
+ const DEFAULT_NOTIFICATION_APP_NAME = "default";
2317
2332
  const NotificationsRealtimeContext = createContext(null);
2318
2333
  const toIso = (value) => {
2319
2334
  if (value instanceof Date) return value.toISOString();
@@ -2348,19 +2363,58 @@ const buildDisabledTopics = (settings) => {
2348
2363
  return pref.inApp === false ? topic : null;
2349
2364
  }).filter((topic) => Boolean(topic));
2350
2365
  };
2351
- const getWebpushLink = (item) => {
2366
+ const getNotificationLink = (item) => {
2367
+ const dataLink = item.data?.link?.trim();
2368
+ if (dataLink) return dataLink;
2352
2369
  const platformWebpush = item.platform?.webpush;
2353
2370
  if (!platformWebpush || typeof platformWebpush !== "object" || Array.isArray(platformWebpush)) return "";
2354
2371
  const fcmOptions = platformWebpush.fcmOptions;
2355
2372
  if (!fcmOptions || typeof fcmOptions !== "object" || Array.isArray(fcmOptions)) return "";
2356
- return typeof fcmOptions.link === "string" ? fcmOptions.link : "";
2357
- };
2358
- const getScopedUserKey = (userId) => encodeURIComponent(userId);
2359
- const getTabStateKey = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:${NOTIFICATION_TAB_ID}`;
2360
- const getTabStateKeyPrefix = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:`;
2361
- const getDeliveryKey = (userId, notificationId) => `${DELIVERY_KEY_PREFIX}${getScopedUserKey(userId)}:${encodeURIComponent(notificationId)}`;
2362
- const getDeliveryLockName = (userId) => `${DELIVERY_LOCK_PREFIX}${getScopedUserKey(userId)}`;
2363
- const getFallbackDeliveryLockKey = (userId) => `${FALLBACK_DELIVERY_LOCK_KEY_PREFIX}${getScopedUserKey(userId)}`;
2373
+ const link = fcmOptions.link;
2374
+ return typeof link === "string" ? link.trim() : "";
2375
+ };
2376
+ const getNotificationActionMode = (item) => {
2377
+ return item.data?.linkMode === "merge_current_search" ? "merge_current_search" : "navigate";
2378
+ };
2379
+ const getNotificationAction = (item) => {
2380
+ const link = getNotificationLink(item);
2381
+ if (!link) return null;
2382
+ return {
2383
+ link,
2384
+ mode: getNotificationActionMode(item)
2385
+ };
2386
+ };
2387
+ const pushUrlWithoutReload = (url) => {
2388
+ window.history.pushState(window.history.state, "", url);
2389
+ window.dispatchEvent(new PopStateEvent("popstate", {
2390
+ state: window.history.state
2391
+ }));
2392
+ };
2393
+ const applyNotificationAction = (action) => {
2394
+ if (action.mode === "merge_current_search") {
2395
+ const currentUrl = new URL(window.location.href);
2396
+ const actionUrl = new URL(action.link, currentUrl);
2397
+ actionUrl.searchParams.forEach((value, key) => {
2398
+ currentUrl.searchParams.set(key, value);
2399
+ });
2400
+ if (actionUrl.hash) {
2401
+ currentUrl.hash = actionUrl.hash;
2402
+ }
2403
+ pushUrlWithoutReload(`${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`);
2404
+ return;
2405
+ }
2406
+ window.location.href = action.link;
2407
+ };
2408
+ const getNormalizedNotificationAppName = (appName) => {
2409
+ const normalized = typeof appName === "string" ? appName.trim() : "";
2410
+ return normalized || DEFAULT_NOTIFICATION_APP_NAME;
2411
+ };
2412
+ const getScopedNotificationKey = (userId, appName) => `${encodeURIComponent(appName)}:${encodeURIComponent(userId)}`;
2413
+ const getTabStateKey = (userId, appName) => `${TAB_STATE_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:${NOTIFICATION_TAB_ID}`;
2414
+ const getTabStateKeyPrefix = (userId, appName) => `${TAB_STATE_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:`;
2415
+ const getDeliveryKey = (userId, appName, notificationId) => `${DELIVERY_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:${encodeURIComponent(notificationId)}`;
2416
+ const getDeliveryLockName = (userId, appName) => `${DELIVERY_LOCK_PREFIX}${getScopedNotificationKey(userId, appName)}`;
2417
+ const getFallbackDeliveryLockKey = (userId, appName) => `${FALLBACK_DELIVERY_LOCK_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}`;
2364
2418
  const getLocalStorage = () => {
2365
2419
  if (typeof window === "undefined") return null;
2366
2420
  try {
@@ -2388,7 +2442,7 @@ const isDocumentActive = () => {
2388
2442
  if (typeof document === "undefined") return false;
2389
2443
  return document.visibilityState === "visible" && document.hasFocus();
2390
2444
  };
2391
- const writeNotificationTabState = (userId) => {
2445
+ const writeNotificationTabState = (userId, appName) => {
2392
2446
  const storage = getLocalStorage();
2393
2447
  if (!storage) return;
2394
2448
  const state = {
@@ -2397,24 +2451,24 @@ const writeNotificationTabState = (userId) => {
2397
2451
  updatedAt: Date.now()
2398
2452
  };
2399
2453
  try {
2400
- storage.setItem(getTabStateKey(userId), JSON.stringify(state));
2454
+ storage.setItem(getTabStateKey(userId, appName), JSON.stringify(state));
2401
2455
  } catch {
2402
2456
  return;
2403
2457
  }
2404
2458
  };
2405
- const removeNotificationTabState = (userId) => {
2459
+ const removeNotificationTabState = (userId, appName) => {
2406
2460
  const storage = getLocalStorage();
2407
2461
  if (!storage) return;
2408
2462
  try {
2409
- storage.removeItem(getTabStateKey(userId));
2463
+ storage.removeItem(getTabStateKey(userId, appName));
2410
2464
  } catch {
2411
2465
  return;
2412
2466
  }
2413
2467
  };
2414
- const hasActiveNotificationTab = (userId) => {
2468
+ const hasActiveNotificationTab = (userId, appName) => {
2415
2469
  const storage = getLocalStorage();
2416
2470
  if (!storage) return false;
2417
- const prefix = getTabStateKeyPrefix(userId);
2471
+ const prefix = getTabStateKeyPrefix(userId, appName);
2418
2472
  const now = Date.now();
2419
2473
  try {
2420
2474
  for (let index = storage.length - 1; index >= 0; index -= 1) {
@@ -2433,13 +2487,13 @@ const hasActiveNotificationTab = (userId) => {
2433
2487
  }
2434
2488
  return false;
2435
2489
  };
2436
- const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2490
+ const claimNotificationDeliveriesFromStorage = (items, userId, appName, mode) => {
2437
2491
  const storage = getLocalStorage();
2438
2492
  if (!storage) return items;
2439
2493
  const now = Date.now();
2440
2494
  const claimed = [];
2441
2495
  for (const item of items) {
2442
- const key = getDeliveryKey(userId, item.id);
2496
+ const key = getDeliveryKey(userId, appName, item.id);
2443
2497
  const current = parseJsonRecord(storage.getItem(key));
2444
2498
  const deliveredAt = typeof current?.deliveredAt === "number" ? current.deliveredAt : 0;
2445
2499
  if (deliveredAt && now - deliveredAt < DELIVERY_TTL_MS) continue;
@@ -2460,7 +2514,7 @@ const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2460
2514
  }
2461
2515
  return claimed;
2462
2516
  };
2463
- const acquireFallbackDeliveryLock = (userId) => {
2517
+ const acquireFallbackDeliveryLock = (userId, appName) => {
2464
2518
  const storage = getLocalStorage();
2465
2519
  if (!storage) {
2466
2520
  return {
@@ -2468,7 +2522,7 @@ const acquireFallbackDeliveryLock = (userId) => {
2468
2522
  expiresAt: Date.now() + FALLBACK_DELIVERY_LOCK_TTL_MS
2469
2523
  };
2470
2524
  }
2471
- const key = getFallbackDeliveryLockKey(userId);
2525
+ const key = getFallbackDeliveryLockKey(userId, appName);
2472
2526
  const now = Date.now();
2473
2527
  try {
2474
2528
  const current = parseJsonRecord(storage.getItem(key));
@@ -2488,10 +2542,10 @@ const acquireFallbackDeliveryLock = (userId) => {
2488
2542
  };
2489
2543
  }
2490
2544
  };
2491
- const releaseFallbackDeliveryLock = (userId, marker) => {
2545
+ const releaseFallbackDeliveryLock = (userId, appName, marker) => {
2492
2546
  const storage = getLocalStorage();
2493
2547
  if (!storage) return;
2494
- const key = getFallbackDeliveryLockKey(userId);
2548
+ const key = getFallbackDeliveryLockKey(userId, appName);
2495
2549
  try {
2496
2550
  const stored = parseJsonRecord(storage.getItem(key));
2497
2551
  if (stored?.token === marker.token) {
@@ -2501,25 +2555,25 @@ const releaseFallbackDeliveryLock = (userId, marker) => {
2501
2555
  return;
2502
2556
  }
2503
2557
  };
2504
- const withFallbackDeliveryLock = (userId, callback, fallback) => {
2505
- const marker = acquireFallbackDeliveryLock(userId);
2558
+ const withFallbackDeliveryLock = (userId, appName, callback, fallback) => {
2559
+ const marker = acquireFallbackDeliveryLock(userId, appName);
2506
2560
  if (!marker) return fallback;
2507
2561
  try {
2508
2562
  return callback();
2509
2563
  } finally {
2510
- releaseFallbackDeliveryLock(userId, marker);
2564
+ releaseFallbackDeliveryLock(userId, appName, marker);
2511
2565
  }
2512
2566
  };
2513
- const claimNotificationDeliveries = async (items, userId, mode) => {
2567
+ const claimNotificationDeliveries = async (items, userId, appName, mode) => {
2514
2568
  if (items.length === 0) return [];
2515
2569
  const claim = () => {
2516
- if (mode === "native" && hasActiveNotificationTab(userId)) return [];
2517
- return claimNotificationDeliveriesFromStorage(items, userId, mode);
2570
+ if (mode === "native" && hasActiveNotificationTab(userId, appName)) return [];
2571
+ return claimNotificationDeliveriesFromStorage(items, userId, appName, mode);
2518
2572
  };
2519
2573
  const locks = getLockManager();
2520
- if (!locks) return withFallbackDeliveryLock(userId, claim, []);
2574
+ if (!locks) return withFallbackDeliveryLock(userId, appName, claim, []);
2521
2575
  try {
2522
- const claimed = await locks.request(getDeliveryLockName(userId), {
2576
+ const claimed = await locks.request(getDeliveryLockName(userId, appName), {
2523
2577
  mode: "exclusive",
2524
2578
  ifAvailable: true
2525
2579
  }, (lock) => {
@@ -2549,16 +2603,16 @@ const canShowNativeNotification = () => {
2549
2603
  if (!("Notification" in window)) return false;
2550
2604
  return window.Notification.permission === "granted";
2551
2605
  };
2552
- const focusNotificationLink = (link) => {
2606
+ const focusNotificationAction = (action) => {
2553
2607
  window.focus();
2554
- if (link) {
2555
- window.location.href = link;
2608
+ if (action) {
2609
+ applyNotificationAction(action);
2556
2610
  }
2557
2611
  };
2558
2612
  const showNativeNotification = (item) => {
2559
2613
  if (!canShowNativeNotification()) return;
2560
2614
  try {
2561
- const link = getWebpushLink(item);
2615
+ const action = getNotificationAction(item);
2562
2616
  const browserNotification = new window.Notification(item.title, {
2563
2617
  body: item.body,
2564
2618
  icon: item.image,
@@ -2566,10 +2620,11 @@ const showNativeNotification = (item) => {
2566
2620
  data: {
2567
2621
  ...item.data,
2568
2622
  notificationId: item.id,
2569
- link
2623
+ link: action?.link ?? "",
2624
+ linkMode: action?.mode ?? "navigate"
2570
2625
  }
2571
2626
  });
2572
- browserNotification.onclick = () => focusNotificationLink(link);
2627
+ browserNotification.onclick = () => focusNotificationAction(action);
2573
2628
  } catch {
2574
2629
  return;
2575
2630
  }
@@ -2582,7 +2637,7 @@ const showNativeNotifications = (items) => {
2582
2637
  body: "Open the notifications drawer to view them.",
2583
2638
  tag: `${NATIVE_NOTIFICATION_TAG_PREFIX}:summary`
2584
2639
  });
2585
- browserNotification.onclick = () => focusNotificationLink("");
2640
+ browserNotification.onclick = () => focusNotificationAction(null);
2586
2641
  } catch {
2587
2642
  return;
2588
2643
  }
@@ -2592,25 +2647,26 @@ const showNativeNotifications = (items) => {
2592
2647
  showNativeNotification(item);
2593
2648
  }
2594
2649
  };
2595
- const showNotificationsForCurrentFocusState = async (items, userId) => {
2596
- writeNotificationTabState(userId);
2650
+ const showNotificationsForCurrentFocusState = async (items, userId, appName) => {
2651
+ writeNotificationTabState(userId, appName);
2597
2652
  if (isDocumentActive()) {
2598
- const claimed2 = await claimNotificationDeliveries(items, userId, "in-app");
2653
+ const claimed2 = await claimNotificationDeliveries(items, userId, appName, "in-app");
2599
2654
  if (claimed2.length > 0) {
2600
2655
  showInAppNotifications(claimed2);
2601
2656
  }
2602
2657
  return;
2603
2658
  }
2604
2659
  if (!canShowNativeNotification()) return;
2605
- const claimed = await claimNotificationDeliveries(items, userId, "native");
2660
+ const claimed = await claimNotificationDeliveries(items, userId, appName, "native");
2606
2661
  if (claimed.length > 0) {
2607
2662
  showNativeNotifications(claimed);
2608
2663
  }
2609
2664
  };
2610
2665
  function NotificationsRealtimeProvider(t0) {
2611
- const $ = c(52);
2666
+ const $ = c(57);
2612
2667
  const {
2613
2668
  userId,
2669
+ appName,
2614
2670
  limit: t1,
2615
2671
  toastOnNew: t2,
2616
2672
  children
@@ -2626,207 +2682,217 @@ function NotificationsRealtimeProvider(t0) {
2626
2682
  t3 = $[1];
2627
2683
  }
2628
2684
  const trimmedUserId = t3;
2629
- const canUseRts = Boolean(trimmedUserId);
2630
2685
  let t4;
2631
- if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2632
- t4 = canUseRts ? {
2633
- userId: trimmedUserId
2634
- } : {};
2635
- $[2] = canUseRts;
2636
- $[3] = trimmedUserId;
2637
- $[4] = t4;
2686
+ if ($[2] !== appName) {
2687
+ t4 = getNormalizedNotificationAppName(appName);
2688
+ $[2] = appName;
2689
+ $[3] = t4;
2638
2690
  } else {
2639
- t4 = $[4];
2691
+ t4 = $[3];
2640
2692
  }
2693
+ const normalizedAppName = t4;
2694
+ const canUseRts = Boolean(trimmedUserId);
2641
2695
  let t5;
2642
- if ($[5] !== canUseRts) {
2643
- t5 = {
2644
- key: "rb.notifications.settings",
2645
- limit: 1,
2646
- enabled: canUseRts
2647
- };
2648
- $[5] = canUseRts;
2696
+ if ($[4] !== canUseRts || $[5] !== trimmedUserId) {
2697
+ t5 = canUseRts ? {
2698
+ userId: trimmedUserId
2699
+ } : {};
2700
+ $[4] = canUseRts;
2701
+ $[5] = trimmedUserId;
2649
2702
  $[6] = t5;
2650
2703
  } else {
2651
2704
  t5 = $[6];
2652
2705
  }
2653
- const settingsQuery = useQuery("RBNotificationSettings", t4, t5);
2654
- const settings = settingsQuery.data?.[0] ?? null;
2655
2706
  let t6;
2656
- if ($[7] !== settings) {
2657
- t6 = buildDisabledTopics(settings);
2658
- $[7] = settings;
2707
+ if ($[7] !== canUseRts) {
2708
+ t6 = {
2709
+ key: "rb.notifications.settings",
2710
+ limit: 1,
2711
+ enabled: canUseRts
2712
+ };
2713
+ $[7] = canUseRts;
2659
2714
  $[8] = t6;
2660
2715
  } else {
2661
2716
  t6 = $[8];
2662
2717
  }
2663
- const disabledTopics = t6;
2718
+ const settingsQuery = useQuery("RBNotificationSettings", t5, t6);
2719
+ const settings = settingsQuery.data?.[0] ?? null;
2664
2720
  let t7;
2721
+ if ($[9] !== settings) {
2722
+ t7 = buildDisabledTopics(settings);
2723
+ $[9] = settings;
2724
+ $[10] = t7;
2725
+ } else {
2726
+ t7 = $[10];
2727
+ }
2728
+ const disabledTopics = t7;
2729
+ let t8;
2665
2730
  bb0: {
2666
2731
  if (!canUseRts) {
2667
- let t83;
2668
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2669
- t83 = {};
2670
- $[9] = t83;
2732
+ let t93;
2733
+ if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2734
+ t93 = {};
2735
+ $[11] = t93;
2671
2736
  } else {
2672
- t83 = $[9];
2737
+ t93 = $[11];
2673
2738
  }
2674
- t7 = t83;
2739
+ t8 = t93;
2675
2740
  break bb0;
2676
2741
  }
2677
- let t82;
2678
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2679
- t82 = {
2742
+ let t92;
2743
+ if ($[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2744
+ t92 = {
2680
2745
  $exists: false
2681
2746
  };
2682
- $[10] = t82;
2747
+ $[12] = t92;
2683
2748
  } else {
2684
- t82 = $[10];
2749
+ t92 = $[12];
2685
2750
  }
2686
2751
  let base;
2687
- if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2752
+ if ($[13] !== disabledTopics || $[14] !== trimmedUserId) {
2688
2753
  base = {
2689
2754
  userId: trimmedUserId,
2690
- archivedAt: t82
2755
+ archivedAt: t92
2691
2756
  };
2692
2757
  if (disabledTopics.length > 0) {
2693
- let t92;
2694
- if ($[14] !== disabledTopics) {
2695
- t92 = {
2758
+ let t102;
2759
+ if ($[16] !== disabledTopics) {
2760
+ t102 = {
2696
2761
  $nin: disabledTopics
2697
2762
  };
2698
- $[14] = disabledTopics;
2699
- $[15] = t92;
2763
+ $[16] = disabledTopics;
2764
+ $[17] = t102;
2700
2765
  } else {
2701
- t92 = $[15];
2766
+ t102 = $[17];
2702
2767
  }
2703
- base.topic = t92;
2768
+ base.topic = t102;
2704
2769
  }
2705
- $[11] = disabledTopics;
2706
- $[12] = trimmedUserId;
2707
- $[13] = base;
2770
+ $[13] = disabledTopics;
2771
+ $[14] = trimmedUserId;
2772
+ $[15] = base;
2708
2773
  } else {
2709
- base = $[13];
2774
+ base = $[15];
2710
2775
  }
2711
- t7 = base;
2776
+ t8 = base;
2712
2777
  }
2713
- const query = t7;
2714
- let t8;
2715
- if ($[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2716
- t8 = {
2778
+ const query = t8;
2779
+ let t9;
2780
+ if ($[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2781
+ t9 = {
2717
2782
  createdAt: -1
2718
2783
  };
2719
- $[16] = t8;
2784
+ $[18] = t9;
2720
2785
  } else {
2721
- t8 = $[16];
2786
+ t9 = $[18];
2722
2787
  }
2723
- let t9;
2724
- if ($[17] !== canUseRts || $[18] !== limit) {
2725
- t9 = {
2788
+ let t10;
2789
+ if ($[19] !== canUseRts || $[20] !== limit) {
2790
+ t10 = {
2726
2791
  key: "rb.notifications",
2727
- sort: t8,
2792
+ sort: t9,
2728
2793
  limit,
2729
2794
  enabled: canUseRts
2730
2795
  };
2731
- $[17] = canUseRts;
2732
- $[18] = limit;
2733
- $[19] = t9;
2796
+ $[19] = canUseRts;
2797
+ $[20] = limit;
2798
+ $[21] = t10;
2734
2799
  } else {
2735
- t9 = $[19];
2800
+ t10 = $[21];
2736
2801
  }
2737
- const notificationsQuery = useQuery("RBNotification", query, t9);
2738
- let t10;
2802
+ const notificationsQuery = useQuery("RBNotification", query, t10);
2803
+ let t11;
2739
2804
  bb1: {
2740
2805
  const raw = notificationsQuery.data;
2741
2806
  if (!Array.isArray(raw)) {
2742
- let t113;
2743
- if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2744
- t113 = [];
2745
- $[20] = t113;
2807
+ let t123;
2808
+ if ($[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2809
+ t123 = [];
2810
+ $[22] = t123;
2746
2811
  } else {
2747
- t113 = $[20];
2812
+ t123 = $[22];
2748
2813
  }
2749
- t10 = t113;
2814
+ t11 = t123;
2750
2815
  break bb1;
2751
2816
  }
2752
- let t112;
2753
- if ($[21] !== raw) {
2754
- t112 = raw.map(_temp).filter(_temp2);
2755
- $[21] = raw;
2756
- $[22] = t112;
2817
+ let t122;
2818
+ if ($[23] !== raw) {
2819
+ t122 = raw.map(_temp).filter(_temp2);
2820
+ $[23] = raw;
2821
+ $[24] = t122;
2757
2822
  } else {
2758
- t112 = $[22];
2823
+ t122 = $[24];
2759
2824
  }
2760
- t10 = t112;
2761
- }
2762
- const notifications = t10;
2763
- let t11;
2764
- if ($[23] !== notifications) {
2765
- t11 = notifications.reduce(_temp3, 0);
2766
- $[23] = notifications;
2767
- $[24] = t11;
2768
- } else {
2769
- t11 = $[24];
2825
+ t11 = t122;
2770
2826
  }
2771
- const unreadCount = t11;
2827
+ const notifications = t11;
2772
2828
  let t12;
2773
2829
  if ($[25] !== notifications) {
2774
- t12 = notifications.reduce(_temp4, 0);
2830
+ t12 = notifications.reduce(_temp3, 0);
2775
2831
  $[25] = notifications;
2776
2832
  $[26] = t12;
2777
2833
  } else {
2778
2834
  t12 = $[26];
2779
2835
  }
2780
- const unseenCount = t12;
2836
+ const unreadCount = t12;
2781
2837
  let t13;
2782
- if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2783
- t13 = /* @__PURE__ */ new Set();
2784
- $[27] = t13;
2838
+ if ($[27] !== notifications) {
2839
+ t13 = notifications.reduce(_temp4, 0);
2840
+ $[27] = notifications;
2841
+ $[28] = t13;
2785
2842
  } else {
2786
- t13 = $[27];
2843
+ t13 = $[28];
2787
2844
  }
2788
- const lastToastIds = useRef(t13);
2789
- const hasSeededToastIds = useRef(false);
2845
+ const unseenCount = t13;
2790
2846
  let t14;
2791
- if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2792
- t14 = Date.now();
2793
- $[28] = t14;
2847
+ if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2848
+ t14 = /* @__PURE__ */ new Set();
2849
+ $[29] = t14;
2794
2850
  } else {
2795
- t14 = $[28];
2851
+ t14 = $[29];
2796
2852
  }
2797
- const toastStartMs = useRef(t14);
2853
+ const lastToastIds = useRef(t14);
2854
+ const hasSeededToastIds = useRef(false);
2798
2855
  let t15;
2799
- if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2800
- t15 = () => {
2856
+ if ($[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2857
+ t15 = Date.now();
2858
+ $[30] = t15;
2859
+ } else {
2860
+ t15 = $[30];
2861
+ }
2862
+ const toastStartMs = useRef(t15);
2863
+ let t16;
2864
+ if ($[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2865
+ t16 = () => {
2801
2866
  hasSeededToastIds.current = false;
2802
2867
  lastToastIds.current = /* @__PURE__ */ new Set();
2803
2868
  toastStartMs.current = Date.now();
2804
2869
  };
2805
- $[29] = t15;
2806
- } else {
2807
- t15 = $[29];
2808
- }
2809
- let t16;
2810
- if ($[30] !== trimmedUserId) {
2811
- t16 = [trimmedUserId];
2812
- $[30] = trimmedUserId;
2813
2870
  $[31] = t16;
2814
2871
  } else {
2815
2872
  t16 = $[31];
2816
2873
  }
2817
- useEffect(t15, t16);
2818
2874
  let t17;
2875
+ if ($[32] !== normalizedAppName || $[33] !== trimmedUserId) {
2876
+ t17 = [normalizedAppName, trimmedUserId];
2877
+ $[32] = normalizedAppName;
2878
+ $[33] = trimmedUserId;
2879
+ $[34] = t17;
2880
+ } else {
2881
+ t17 = $[34];
2882
+ }
2883
+ useEffect(t16, t17);
2819
2884
  let t18;
2820
- if ($[32] !== canUseRts || $[33] !== trimmedUserId) {
2821
- t17 = () => {
2885
+ let t19;
2886
+ if ($[35] !== canUseRts || $[36] !== normalizedAppName || $[37] !== trimmedUserId) {
2887
+ t18 = () => {
2822
2888
  if (!canUseRts) {
2823
2889
  return;
2824
2890
  }
2825
2891
  if (typeof window === "undefined" || typeof document === "undefined") {
2826
2892
  return;
2827
2893
  }
2828
- const writeState = () => writeNotificationTabState(trimmedUserId);
2829
- const removeState = () => removeNotificationTabState(trimmedUserId);
2894
+ const writeState = () => writeNotificationTabState(trimmedUserId, normalizedAppName);
2895
+ const removeState = () => removeNotificationTabState(trimmedUserId, normalizedAppName);
2830
2896
  writeState();
2831
2897
  const intervalId = window.setInterval(writeState, ACTIVE_TAB_HEARTBEAT_MS);
2832
2898
  window.addEventListener("focus", writeState);
@@ -2844,20 +2910,21 @@ function NotificationsRealtimeProvider(t0) {
2844
2910
  removeState();
2845
2911
  };
2846
2912
  };
2847
- t18 = [canUseRts, trimmedUserId];
2848
- $[32] = canUseRts;
2849
- $[33] = trimmedUserId;
2850
- $[34] = t17;
2851
- $[35] = t18;
2913
+ t19 = [canUseRts, normalizedAppName, trimmedUserId];
2914
+ $[35] = canUseRts;
2915
+ $[36] = normalizedAppName;
2916
+ $[37] = trimmedUserId;
2917
+ $[38] = t18;
2918
+ $[39] = t19;
2852
2919
  } else {
2853
- t17 = $[34];
2854
- t18 = $[35];
2920
+ t18 = $[38];
2921
+ t19 = $[39];
2855
2922
  }
2856
- useEffect(t17, t18);
2857
- let t19;
2923
+ useEffect(t18, t19);
2858
2924
  let t20;
2859
- if ($[36] !== canUseRts || $[37] !== notifications || $[38] !== notificationsQuery.loading || $[39] !== toastOnNew || $[40] !== trimmedUserId) {
2860
- t19 = () => {
2925
+ let t21;
2926
+ if ($[40] !== canUseRts || $[41] !== normalizedAppName || $[42] !== notifications || $[43] !== notificationsQuery.loading || $[44] !== toastOnNew || $[45] !== trimmedUserId) {
2927
+ t20 = () => {
2861
2928
  if (!toastOnNew) {
2862
2929
  return;
2863
2930
  }
@@ -2878,7 +2945,7 @@ function NotificationsRealtimeProvider(t0) {
2878
2945
  return createdAtMs >= toastStartMs.current - NEW_NOTIFICATION_START_TOLERANCE_MS;
2879
2946
  });
2880
2947
  if (eligible.length) {
2881
- showNotificationsForCurrentFocusState(eligible, trimmedUserId);
2948
+ showNotificationsForCurrentFocusState(eligible, trimmedUserId, normalizedAppName);
2882
2949
  }
2883
2950
  return;
2884
2951
  }
@@ -2899,51 +2966,52 @@ function NotificationsRealtimeProvider(t0) {
2899
2966
  if (!eligible_0.length) {
2900
2967
  return;
2901
2968
  }
2902
- showNotificationsForCurrentFocusState(eligible_0, trimmedUserId);
2969
+ showNotificationsForCurrentFocusState(eligible_0, trimmedUserId, normalizedAppName);
2903
2970
  };
2904
- t20 = [canUseRts, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
2905
- $[36] = canUseRts;
2906
- $[37] = notifications;
2907
- $[38] = notificationsQuery.loading;
2908
- $[39] = toastOnNew;
2909
- $[40] = trimmedUserId;
2910
- $[41] = t19;
2911
- $[42] = t20;
2971
+ t21 = [canUseRts, normalizedAppName, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
2972
+ $[40] = canUseRts;
2973
+ $[41] = normalizedAppName;
2974
+ $[42] = notifications;
2975
+ $[43] = notificationsQuery.loading;
2976
+ $[44] = toastOnNew;
2977
+ $[45] = trimmedUserId;
2978
+ $[46] = t20;
2979
+ $[47] = t21;
2912
2980
  } else {
2913
- t19 = $[41];
2914
- t20 = $[42];
2981
+ t20 = $[46];
2982
+ t21 = $[47];
2915
2983
  }
2916
- useEffect(t19, t20);
2917
- let t21;
2918
- if ($[43] !== notifications || $[44] !== notificationsQuery.error || $[45] !== notificationsQuery.loading || $[46] !== unreadCount || $[47] !== unseenCount) {
2919
- t21 = {
2984
+ useEffect(t20, t21);
2985
+ let t22;
2986
+ if ($[48] !== notifications || $[49] !== notificationsQuery.error || $[50] !== notificationsQuery.loading || $[51] !== unreadCount || $[52] !== unseenCount) {
2987
+ t22 = {
2920
2988
  notifications,
2921
2989
  unreadCount,
2922
2990
  unseenCount,
2923
2991
  loading: notificationsQuery.loading,
2924
2992
  error: notificationsQuery.error
2925
2993
  };
2926
- $[43] = notifications;
2927
- $[44] = notificationsQuery.error;
2928
- $[45] = notificationsQuery.loading;
2929
- $[46] = unreadCount;
2930
- $[47] = unseenCount;
2931
- $[48] = t21;
2994
+ $[48] = notifications;
2995
+ $[49] = notificationsQuery.error;
2996
+ $[50] = notificationsQuery.loading;
2997
+ $[51] = unreadCount;
2998
+ $[52] = unseenCount;
2999
+ $[53] = t22;
2932
3000
  } else {
2933
- t21 = $[48];
2934
- }
2935
- const value = t21;
2936
- const t22 = canUseRts ? value : null;
2937
- let t23;
2938
- if ($[49] !== children || $[50] !== t22) {
2939
- t23 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t22, children });
2940
- $[49] = children;
2941
- $[50] = t22;
2942
- $[51] = t23;
3001
+ t22 = $[53];
3002
+ }
3003
+ const value = t22;
3004
+ const t23 = canUseRts ? value : null;
3005
+ let t24;
3006
+ if ($[54] !== children || $[55] !== t23) {
3007
+ t24 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t23, children });
3008
+ $[54] = children;
3009
+ $[55] = t23;
3010
+ $[56] = t24;
2943
3011
  } else {
2944
- t23 = $[51];
3012
+ t24 = $[56];
2945
3013
  }
2946
- return t23;
3014
+ return t24;
2947
3015
  }
2948
3016
  function _temp5(n_2) {
2949
3017
  return n_2.id;
@@ -2985,6 +3053,7 @@ export {
2985
3053
  listNotifications,
2986
3054
  markAllNotificationsRead,
2987
3055
  markNotificationRead,
3056
+ markNotificationsReadByUrl,
2988
3057
  peekClientSsrErrorState,
2989
3058
  p as peekHydratedRtsCount,
2990
3059
  b as peekHydratedRtsQueryData,