@rpcbase/client 0.437.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
@@ -2328,6 +2328,7 @@ const DELIVERY_KEY_PREFIX = "rb:notifications:delivery:";
2328
2328
  const DELIVERY_LOCK_PREFIX = "rb-notifications-delivery:";
2329
2329
  const FALLBACK_DELIVERY_LOCK_KEY_PREFIX = "rb:notifications:delivery-lock:";
2330
2330
  const NOTIFICATION_TAB_ID = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2331
+ const DEFAULT_NOTIFICATION_APP_NAME = "default";
2331
2332
  const NotificationsRealtimeContext = createContext(null);
2332
2333
  const toIso = (value) => {
2333
2334
  if (value instanceof Date) return value.toISOString();
@@ -2362,19 +2363,58 @@ const buildDisabledTopics = (settings) => {
2362
2363
  return pref.inApp === false ? topic : null;
2363
2364
  }).filter((topic) => Boolean(topic));
2364
2365
  };
2365
- const getWebpushLink = (item) => {
2366
+ const getNotificationLink = (item) => {
2367
+ const dataLink = item.data?.link?.trim();
2368
+ if (dataLink) return dataLink;
2366
2369
  const platformWebpush = item.platform?.webpush;
2367
2370
  if (!platformWebpush || typeof platformWebpush !== "object" || Array.isArray(platformWebpush)) return "";
2368
2371
  const fcmOptions = platformWebpush.fcmOptions;
2369
2372
  if (!fcmOptions || typeof fcmOptions !== "object" || Array.isArray(fcmOptions)) return "";
2370
- return typeof fcmOptions.link === "string" ? fcmOptions.link : "";
2371
- };
2372
- const getScopedUserKey = (userId) => encodeURIComponent(userId);
2373
- const getTabStateKey = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:${NOTIFICATION_TAB_ID}`;
2374
- const getTabStateKeyPrefix = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:`;
2375
- const getDeliveryKey = (userId, notificationId) => `${DELIVERY_KEY_PREFIX}${getScopedUserKey(userId)}:${encodeURIComponent(notificationId)}`;
2376
- const getDeliveryLockName = (userId) => `${DELIVERY_LOCK_PREFIX}${getScopedUserKey(userId)}`;
2377
- 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)}`;
2378
2418
  const getLocalStorage = () => {
2379
2419
  if (typeof window === "undefined") return null;
2380
2420
  try {
@@ -2402,7 +2442,7 @@ const isDocumentActive = () => {
2402
2442
  if (typeof document === "undefined") return false;
2403
2443
  return document.visibilityState === "visible" && document.hasFocus();
2404
2444
  };
2405
- const writeNotificationTabState = (userId) => {
2445
+ const writeNotificationTabState = (userId, appName) => {
2406
2446
  const storage = getLocalStorage();
2407
2447
  if (!storage) return;
2408
2448
  const state = {
@@ -2411,24 +2451,24 @@ const writeNotificationTabState = (userId) => {
2411
2451
  updatedAt: Date.now()
2412
2452
  };
2413
2453
  try {
2414
- storage.setItem(getTabStateKey(userId), JSON.stringify(state));
2454
+ storage.setItem(getTabStateKey(userId, appName), JSON.stringify(state));
2415
2455
  } catch {
2416
2456
  return;
2417
2457
  }
2418
2458
  };
2419
- const removeNotificationTabState = (userId) => {
2459
+ const removeNotificationTabState = (userId, appName) => {
2420
2460
  const storage = getLocalStorage();
2421
2461
  if (!storage) return;
2422
2462
  try {
2423
- storage.removeItem(getTabStateKey(userId));
2463
+ storage.removeItem(getTabStateKey(userId, appName));
2424
2464
  } catch {
2425
2465
  return;
2426
2466
  }
2427
2467
  };
2428
- const hasActiveNotificationTab = (userId) => {
2468
+ const hasActiveNotificationTab = (userId, appName) => {
2429
2469
  const storage = getLocalStorage();
2430
2470
  if (!storage) return false;
2431
- const prefix = getTabStateKeyPrefix(userId);
2471
+ const prefix = getTabStateKeyPrefix(userId, appName);
2432
2472
  const now = Date.now();
2433
2473
  try {
2434
2474
  for (let index = storage.length - 1; index >= 0; index -= 1) {
@@ -2447,13 +2487,13 @@ const hasActiveNotificationTab = (userId) => {
2447
2487
  }
2448
2488
  return false;
2449
2489
  };
2450
- const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2490
+ const claimNotificationDeliveriesFromStorage = (items, userId, appName, mode) => {
2451
2491
  const storage = getLocalStorage();
2452
2492
  if (!storage) return items;
2453
2493
  const now = Date.now();
2454
2494
  const claimed = [];
2455
2495
  for (const item of items) {
2456
- const key = getDeliveryKey(userId, item.id);
2496
+ const key = getDeliveryKey(userId, appName, item.id);
2457
2497
  const current = parseJsonRecord(storage.getItem(key));
2458
2498
  const deliveredAt = typeof current?.deliveredAt === "number" ? current.deliveredAt : 0;
2459
2499
  if (deliveredAt && now - deliveredAt < DELIVERY_TTL_MS) continue;
@@ -2474,7 +2514,7 @@ const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2474
2514
  }
2475
2515
  return claimed;
2476
2516
  };
2477
- const acquireFallbackDeliveryLock = (userId) => {
2517
+ const acquireFallbackDeliveryLock = (userId, appName) => {
2478
2518
  const storage = getLocalStorage();
2479
2519
  if (!storage) {
2480
2520
  return {
@@ -2482,7 +2522,7 @@ const acquireFallbackDeliveryLock = (userId) => {
2482
2522
  expiresAt: Date.now() + FALLBACK_DELIVERY_LOCK_TTL_MS
2483
2523
  };
2484
2524
  }
2485
- const key = getFallbackDeliveryLockKey(userId);
2525
+ const key = getFallbackDeliveryLockKey(userId, appName);
2486
2526
  const now = Date.now();
2487
2527
  try {
2488
2528
  const current = parseJsonRecord(storage.getItem(key));
@@ -2502,10 +2542,10 @@ const acquireFallbackDeliveryLock = (userId) => {
2502
2542
  };
2503
2543
  }
2504
2544
  };
2505
- const releaseFallbackDeliveryLock = (userId, marker) => {
2545
+ const releaseFallbackDeliveryLock = (userId, appName, marker) => {
2506
2546
  const storage = getLocalStorage();
2507
2547
  if (!storage) return;
2508
- const key = getFallbackDeliveryLockKey(userId);
2548
+ const key = getFallbackDeliveryLockKey(userId, appName);
2509
2549
  try {
2510
2550
  const stored = parseJsonRecord(storage.getItem(key));
2511
2551
  if (stored?.token === marker.token) {
@@ -2515,25 +2555,25 @@ const releaseFallbackDeliveryLock = (userId, marker) => {
2515
2555
  return;
2516
2556
  }
2517
2557
  };
2518
- const withFallbackDeliveryLock = (userId, callback, fallback) => {
2519
- const marker = acquireFallbackDeliveryLock(userId);
2558
+ const withFallbackDeliveryLock = (userId, appName, callback, fallback) => {
2559
+ const marker = acquireFallbackDeliveryLock(userId, appName);
2520
2560
  if (!marker) return fallback;
2521
2561
  try {
2522
2562
  return callback();
2523
2563
  } finally {
2524
- releaseFallbackDeliveryLock(userId, marker);
2564
+ releaseFallbackDeliveryLock(userId, appName, marker);
2525
2565
  }
2526
2566
  };
2527
- const claimNotificationDeliveries = async (items, userId, mode) => {
2567
+ const claimNotificationDeliveries = async (items, userId, appName, mode) => {
2528
2568
  if (items.length === 0) return [];
2529
2569
  const claim = () => {
2530
- if (mode === "native" && hasActiveNotificationTab(userId)) return [];
2531
- return claimNotificationDeliveriesFromStorage(items, userId, mode);
2570
+ if (mode === "native" && hasActiveNotificationTab(userId, appName)) return [];
2571
+ return claimNotificationDeliveriesFromStorage(items, userId, appName, mode);
2532
2572
  };
2533
2573
  const locks = getLockManager();
2534
- if (!locks) return withFallbackDeliveryLock(userId, claim, []);
2574
+ if (!locks) return withFallbackDeliveryLock(userId, appName, claim, []);
2535
2575
  try {
2536
- const claimed = await locks.request(getDeliveryLockName(userId), {
2576
+ const claimed = await locks.request(getDeliveryLockName(userId, appName), {
2537
2577
  mode: "exclusive",
2538
2578
  ifAvailable: true
2539
2579
  }, (lock) => {
@@ -2563,16 +2603,16 @@ const canShowNativeNotification = () => {
2563
2603
  if (!("Notification" in window)) return false;
2564
2604
  return window.Notification.permission === "granted";
2565
2605
  };
2566
- const focusNotificationLink = (link) => {
2606
+ const focusNotificationAction = (action) => {
2567
2607
  window.focus();
2568
- if (link) {
2569
- window.location.href = link;
2608
+ if (action) {
2609
+ applyNotificationAction(action);
2570
2610
  }
2571
2611
  };
2572
2612
  const showNativeNotification = (item) => {
2573
2613
  if (!canShowNativeNotification()) return;
2574
2614
  try {
2575
- const link = getWebpushLink(item);
2615
+ const action = getNotificationAction(item);
2576
2616
  const browserNotification = new window.Notification(item.title, {
2577
2617
  body: item.body,
2578
2618
  icon: item.image,
@@ -2580,10 +2620,11 @@ const showNativeNotification = (item) => {
2580
2620
  data: {
2581
2621
  ...item.data,
2582
2622
  notificationId: item.id,
2583
- link
2623
+ link: action?.link ?? "",
2624
+ linkMode: action?.mode ?? "navigate"
2584
2625
  }
2585
2626
  });
2586
- browserNotification.onclick = () => focusNotificationLink(link);
2627
+ browserNotification.onclick = () => focusNotificationAction(action);
2587
2628
  } catch {
2588
2629
  return;
2589
2630
  }
@@ -2596,7 +2637,7 @@ const showNativeNotifications = (items) => {
2596
2637
  body: "Open the notifications drawer to view them.",
2597
2638
  tag: `${NATIVE_NOTIFICATION_TAG_PREFIX}:summary`
2598
2639
  });
2599
- browserNotification.onclick = () => focusNotificationLink("");
2640
+ browserNotification.onclick = () => focusNotificationAction(null);
2600
2641
  } catch {
2601
2642
  return;
2602
2643
  }
@@ -2606,25 +2647,26 @@ const showNativeNotifications = (items) => {
2606
2647
  showNativeNotification(item);
2607
2648
  }
2608
2649
  };
2609
- const showNotificationsForCurrentFocusState = async (items, userId) => {
2610
- writeNotificationTabState(userId);
2650
+ const showNotificationsForCurrentFocusState = async (items, userId, appName) => {
2651
+ writeNotificationTabState(userId, appName);
2611
2652
  if (isDocumentActive()) {
2612
- const claimed2 = await claimNotificationDeliveries(items, userId, "in-app");
2653
+ const claimed2 = await claimNotificationDeliveries(items, userId, appName, "in-app");
2613
2654
  if (claimed2.length > 0) {
2614
2655
  showInAppNotifications(claimed2);
2615
2656
  }
2616
2657
  return;
2617
2658
  }
2618
2659
  if (!canShowNativeNotification()) return;
2619
- const claimed = await claimNotificationDeliveries(items, userId, "native");
2660
+ const claimed = await claimNotificationDeliveries(items, userId, appName, "native");
2620
2661
  if (claimed.length > 0) {
2621
2662
  showNativeNotifications(claimed);
2622
2663
  }
2623
2664
  };
2624
2665
  function NotificationsRealtimeProvider(t0) {
2625
- const $ = c(52);
2666
+ const $ = c(57);
2626
2667
  const {
2627
2668
  userId,
2669
+ appName,
2628
2670
  limit: t1,
2629
2671
  toastOnNew: t2,
2630
2672
  children
@@ -2640,207 +2682,217 @@ function NotificationsRealtimeProvider(t0) {
2640
2682
  t3 = $[1];
2641
2683
  }
2642
2684
  const trimmedUserId = t3;
2643
- const canUseRts = Boolean(trimmedUserId);
2644
2685
  let t4;
2645
- if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2646
- t4 = canUseRts ? {
2647
- userId: trimmedUserId
2648
- } : {};
2649
- $[2] = canUseRts;
2650
- $[3] = trimmedUserId;
2651
- $[4] = t4;
2686
+ if ($[2] !== appName) {
2687
+ t4 = getNormalizedNotificationAppName(appName);
2688
+ $[2] = appName;
2689
+ $[3] = t4;
2652
2690
  } else {
2653
- t4 = $[4];
2691
+ t4 = $[3];
2654
2692
  }
2693
+ const normalizedAppName = t4;
2694
+ const canUseRts = Boolean(trimmedUserId);
2655
2695
  let t5;
2656
- if ($[5] !== canUseRts) {
2657
- t5 = {
2658
- key: "rb.notifications.settings",
2659
- limit: 1,
2660
- enabled: canUseRts
2661
- };
2662
- $[5] = canUseRts;
2696
+ if ($[4] !== canUseRts || $[5] !== trimmedUserId) {
2697
+ t5 = canUseRts ? {
2698
+ userId: trimmedUserId
2699
+ } : {};
2700
+ $[4] = canUseRts;
2701
+ $[5] = trimmedUserId;
2663
2702
  $[6] = t5;
2664
2703
  } else {
2665
2704
  t5 = $[6];
2666
2705
  }
2667
- const settingsQuery = useQuery("RBNotificationSettings", t4, t5);
2668
- const settings = settingsQuery.data?.[0] ?? null;
2669
2706
  let t6;
2670
- if ($[7] !== settings) {
2671
- t6 = buildDisabledTopics(settings);
2672
- $[7] = settings;
2707
+ if ($[7] !== canUseRts) {
2708
+ t6 = {
2709
+ key: "rb.notifications.settings",
2710
+ limit: 1,
2711
+ enabled: canUseRts
2712
+ };
2713
+ $[7] = canUseRts;
2673
2714
  $[8] = t6;
2674
2715
  } else {
2675
2716
  t6 = $[8];
2676
2717
  }
2677
- const disabledTopics = t6;
2718
+ const settingsQuery = useQuery("RBNotificationSettings", t5, t6);
2719
+ const settings = settingsQuery.data?.[0] ?? null;
2678
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;
2679
2730
  bb0: {
2680
2731
  if (!canUseRts) {
2681
- let t83;
2682
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2683
- t83 = {};
2684
- $[9] = t83;
2732
+ let t93;
2733
+ if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2734
+ t93 = {};
2735
+ $[11] = t93;
2685
2736
  } else {
2686
- t83 = $[9];
2737
+ t93 = $[11];
2687
2738
  }
2688
- t7 = t83;
2739
+ t8 = t93;
2689
2740
  break bb0;
2690
2741
  }
2691
- let t82;
2692
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2693
- t82 = {
2742
+ let t92;
2743
+ if ($[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2744
+ t92 = {
2694
2745
  $exists: false
2695
2746
  };
2696
- $[10] = t82;
2747
+ $[12] = t92;
2697
2748
  } else {
2698
- t82 = $[10];
2749
+ t92 = $[12];
2699
2750
  }
2700
2751
  let base;
2701
- if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2752
+ if ($[13] !== disabledTopics || $[14] !== trimmedUserId) {
2702
2753
  base = {
2703
2754
  userId: trimmedUserId,
2704
- archivedAt: t82
2755
+ archivedAt: t92
2705
2756
  };
2706
2757
  if (disabledTopics.length > 0) {
2707
- let t92;
2708
- if ($[14] !== disabledTopics) {
2709
- t92 = {
2758
+ let t102;
2759
+ if ($[16] !== disabledTopics) {
2760
+ t102 = {
2710
2761
  $nin: disabledTopics
2711
2762
  };
2712
- $[14] = disabledTopics;
2713
- $[15] = t92;
2763
+ $[16] = disabledTopics;
2764
+ $[17] = t102;
2714
2765
  } else {
2715
- t92 = $[15];
2766
+ t102 = $[17];
2716
2767
  }
2717
- base.topic = t92;
2768
+ base.topic = t102;
2718
2769
  }
2719
- $[11] = disabledTopics;
2720
- $[12] = trimmedUserId;
2721
- $[13] = base;
2770
+ $[13] = disabledTopics;
2771
+ $[14] = trimmedUserId;
2772
+ $[15] = base;
2722
2773
  } else {
2723
- base = $[13];
2774
+ base = $[15];
2724
2775
  }
2725
- t7 = base;
2776
+ t8 = base;
2726
2777
  }
2727
- const query = t7;
2728
- let t8;
2729
- if ($[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2730
- t8 = {
2778
+ const query = t8;
2779
+ let t9;
2780
+ if ($[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2781
+ t9 = {
2731
2782
  createdAt: -1
2732
2783
  };
2733
- $[16] = t8;
2784
+ $[18] = t9;
2734
2785
  } else {
2735
- t8 = $[16];
2786
+ t9 = $[18];
2736
2787
  }
2737
- let t9;
2738
- if ($[17] !== canUseRts || $[18] !== limit) {
2739
- t9 = {
2788
+ let t10;
2789
+ if ($[19] !== canUseRts || $[20] !== limit) {
2790
+ t10 = {
2740
2791
  key: "rb.notifications",
2741
- sort: t8,
2792
+ sort: t9,
2742
2793
  limit,
2743
2794
  enabled: canUseRts
2744
2795
  };
2745
- $[17] = canUseRts;
2746
- $[18] = limit;
2747
- $[19] = t9;
2796
+ $[19] = canUseRts;
2797
+ $[20] = limit;
2798
+ $[21] = t10;
2748
2799
  } else {
2749
- t9 = $[19];
2800
+ t10 = $[21];
2750
2801
  }
2751
- const notificationsQuery = useQuery("RBNotification", query, t9);
2752
- let t10;
2802
+ const notificationsQuery = useQuery("RBNotification", query, t10);
2803
+ let t11;
2753
2804
  bb1: {
2754
2805
  const raw = notificationsQuery.data;
2755
2806
  if (!Array.isArray(raw)) {
2756
- let t113;
2757
- if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2758
- t113 = [];
2759
- $[20] = t113;
2807
+ let t123;
2808
+ if ($[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2809
+ t123 = [];
2810
+ $[22] = t123;
2760
2811
  } else {
2761
- t113 = $[20];
2812
+ t123 = $[22];
2762
2813
  }
2763
- t10 = t113;
2814
+ t11 = t123;
2764
2815
  break bb1;
2765
2816
  }
2766
- let t112;
2767
- if ($[21] !== raw) {
2768
- t112 = raw.map(_temp).filter(_temp2);
2769
- $[21] = raw;
2770
- $[22] = t112;
2817
+ let t122;
2818
+ if ($[23] !== raw) {
2819
+ t122 = raw.map(_temp).filter(_temp2);
2820
+ $[23] = raw;
2821
+ $[24] = t122;
2771
2822
  } else {
2772
- t112 = $[22];
2823
+ t122 = $[24];
2773
2824
  }
2774
- t10 = t112;
2825
+ t11 = t122;
2775
2826
  }
2776
- const notifications = t10;
2777
- let t11;
2778
- if ($[23] !== notifications) {
2779
- t11 = notifications.reduce(_temp3, 0);
2780
- $[23] = notifications;
2781
- $[24] = t11;
2782
- } else {
2783
- t11 = $[24];
2784
- }
2785
- const unreadCount = t11;
2827
+ const notifications = t11;
2786
2828
  let t12;
2787
2829
  if ($[25] !== notifications) {
2788
- t12 = notifications.reduce(_temp4, 0);
2830
+ t12 = notifications.reduce(_temp3, 0);
2789
2831
  $[25] = notifications;
2790
2832
  $[26] = t12;
2791
2833
  } else {
2792
2834
  t12 = $[26];
2793
2835
  }
2794
- const unseenCount = t12;
2836
+ const unreadCount = t12;
2795
2837
  let t13;
2796
- if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2797
- t13 = /* @__PURE__ */ new Set();
2798
- $[27] = t13;
2838
+ if ($[27] !== notifications) {
2839
+ t13 = notifications.reduce(_temp4, 0);
2840
+ $[27] = notifications;
2841
+ $[28] = t13;
2799
2842
  } else {
2800
- t13 = $[27];
2843
+ t13 = $[28];
2801
2844
  }
2802
- const lastToastIds = useRef(t13);
2803
- const hasSeededToastIds = useRef(false);
2845
+ const unseenCount = t13;
2804
2846
  let t14;
2805
- if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2806
- t14 = Date.now();
2807
- $[28] = t14;
2847
+ if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2848
+ t14 = /* @__PURE__ */ new Set();
2849
+ $[29] = t14;
2808
2850
  } else {
2809
- t14 = $[28];
2851
+ t14 = $[29];
2810
2852
  }
2811
- const toastStartMs = useRef(t14);
2853
+ const lastToastIds = useRef(t14);
2854
+ const hasSeededToastIds = useRef(false);
2812
2855
  let t15;
2813
- if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2814
- 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 = () => {
2815
2866
  hasSeededToastIds.current = false;
2816
2867
  lastToastIds.current = /* @__PURE__ */ new Set();
2817
2868
  toastStartMs.current = Date.now();
2818
2869
  };
2819
- $[29] = t15;
2820
- } else {
2821
- t15 = $[29];
2822
- }
2823
- let t16;
2824
- if ($[30] !== trimmedUserId) {
2825
- t16 = [trimmedUserId];
2826
- $[30] = trimmedUserId;
2827
2870
  $[31] = t16;
2828
2871
  } else {
2829
2872
  t16 = $[31];
2830
2873
  }
2831
- useEffect(t15, t16);
2832
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);
2833
2884
  let t18;
2834
- if ($[32] !== canUseRts || $[33] !== trimmedUserId) {
2835
- t17 = () => {
2885
+ let t19;
2886
+ if ($[35] !== canUseRts || $[36] !== normalizedAppName || $[37] !== trimmedUserId) {
2887
+ t18 = () => {
2836
2888
  if (!canUseRts) {
2837
2889
  return;
2838
2890
  }
2839
2891
  if (typeof window === "undefined" || typeof document === "undefined") {
2840
2892
  return;
2841
2893
  }
2842
- const writeState = () => writeNotificationTabState(trimmedUserId);
2843
- const removeState = () => removeNotificationTabState(trimmedUserId);
2894
+ const writeState = () => writeNotificationTabState(trimmedUserId, normalizedAppName);
2895
+ const removeState = () => removeNotificationTabState(trimmedUserId, normalizedAppName);
2844
2896
  writeState();
2845
2897
  const intervalId = window.setInterval(writeState, ACTIVE_TAB_HEARTBEAT_MS);
2846
2898
  window.addEventListener("focus", writeState);
@@ -2858,20 +2910,21 @@ function NotificationsRealtimeProvider(t0) {
2858
2910
  removeState();
2859
2911
  };
2860
2912
  };
2861
- t18 = [canUseRts, trimmedUserId];
2862
- $[32] = canUseRts;
2863
- $[33] = trimmedUserId;
2864
- $[34] = t17;
2865
- $[35] = t18;
2913
+ t19 = [canUseRts, normalizedAppName, trimmedUserId];
2914
+ $[35] = canUseRts;
2915
+ $[36] = normalizedAppName;
2916
+ $[37] = trimmedUserId;
2917
+ $[38] = t18;
2918
+ $[39] = t19;
2866
2919
  } else {
2867
- t17 = $[34];
2868
- t18 = $[35];
2920
+ t18 = $[38];
2921
+ t19 = $[39];
2869
2922
  }
2870
- useEffect(t17, t18);
2871
- let t19;
2923
+ useEffect(t18, t19);
2872
2924
  let t20;
2873
- if ($[36] !== canUseRts || $[37] !== notifications || $[38] !== notificationsQuery.loading || $[39] !== toastOnNew || $[40] !== trimmedUserId) {
2874
- t19 = () => {
2925
+ let t21;
2926
+ if ($[40] !== canUseRts || $[41] !== normalizedAppName || $[42] !== notifications || $[43] !== notificationsQuery.loading || $[44] !== toastOnNew || $[45] !== trimmedUserId) {
2927
+ t20 = () => {
2875
2928
  if (!toastOnNew) {
2876
2929
  return;
2877
2930
  }
@@ -2892,7 +2945,7 @@ function NotificationsRealtimeProvider(t0) {
2892
2945
  return createdAtMs >= toastStartMs.current - NEW_NOTIFICATION_START_TOLERANCE_MS;
2893
2946
  });
2894
2947
  if (eligible.length) {
2895
- showNotificationsForCurrentFocusState(eligible, trimmedUserId);
2948
+ showNotificationsForCurrentFocusState(eligible, trimmedUserId, normalizedAppName);
2896
2949
  }
2897
2950
  return;
2898
2951
  }
@@ -2913,51 +2966,52 @@ function NotificationsRealtimeProvider(t0) {
2913
2966
  if (!eligible_0.length) {
2914
2967
  return;
2915
2968
  }
2916
- showNotificationsForCurrentFocusState(eligible_0, trimmedUserId);
2969
+ showNotificationsForCurrentFocusState(eligible_0, trimmedUserId, normalizedAppName);
2917
2970
  };
2918
- t20 = [canUseRts, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
2919
- $[36] = canUseRts;
2920
- $[37] = notifications;
2921
- $[38] = notificationsQuery.loading;
2922
- $[39] = toastOnNew;
2923
- $[40] = trimmedUserId;
2924
- $[41] = t19;
2925
- $[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;
2926
2980
  } else {
2927
- t19 = $[41];
2928
- t20 = $[42];
2981
+ t20 = $[46];
2982
+ t21 = $[47];
2929
2983
  }
2930
- useEffect(t19, t20);
2931
- let t21;
2932
- if ($[43] !== notifications || $[44] !== notificationsQuery.error || $[45] !== notificationsQuery.loading || $[46] !== unreadCount || $[47] !== unseenCount) {
2933
- t21 = {
2984
+ useEffect(t20, t21);
2985
+ let t22;
2986
+ if ($[48] !== notifications || $[49] !== notificationsQuery.error || $[50] !== notificationsQuery.loading || $[51] !== unreadCount || $[52] !== unseenCount) {
2987
+ t22 = {
2934
2988
  notifications,
2935
2989
  unreadCount,
2936
2990
  unseenCount,
2937
2991
  loading: notificationsQuery.loading,
2938
2992
  error: notificationsQuery.error
2939
2993
  };
2940
- $[43] = notifications;
2941
- $[44] = notificationsQuery.error;
2942
- $[45] = notificationsQuery.loading;
2943
- $[46] = unreadCount;
2944
- $[47] = unseenCount;
2945
- $[48] = t21;
2994
+ $[48] = notifications;
2995
+ $[49] = notificationsQuery.error;
2996
+ $[50] = notificationsQuery.loading;
2997
+ $[51] = unreadCount;
2998
+ $[52] = unseenCount;
2999
+ $[53] = t22;
2946
3000
  } else {
2947
- t21 = $[48];
2948
- }
2949
- const value = t21;
2950
- const t22 = canUseRts ? value : null;
2951
- let t23;
2952
- if ($[49] !== children || $[50] !== t22) {
2953
- t23 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t22, children });
2954
- $[49] = children;
2955
- $[50] = t22;
2956
- $[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;
2957
3011
  } else {
2958
- t23 = $[51];
3012
+ t24 = $[56];
2959
3013
  }
2960
- return t23;
3014
+ return t24;
2961
3015
  }
2962
3016
  function _temp5(n_2) {
2963
3017
  return n_2.id;