Skip to content

Commit bb083a5

Browse files
committed
fix(app): update in-app subscriber when switching org
1 parent cb8947a commit bb083a5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/app/src/components/notifications/notification-bell.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import { usePathname } from 'next/navigation';
34
import { env } from '@/env.mjs';
45
import { Inbox } from '@novu/nextjs';
56
import { useSession } from '@/utils/auth-client';
@@ -8,15 +9,18 @@ export function NotificationBell() {
89
const applicationIdentifier = env.NEXT_PUBLIC_NOVU_APPLICATION_IDENTIFIER;
910
const { data: session } = useSession();
1011
const sessionData = session?.session;
12+
const pathname = usePathname();
13+
const orgId = pathname?.split('/')[1] || null;
14+
1115
// Don't render if we don't have the required config
12-
if (!applicationIdentifier || !sessionData?.userId || !sessionData?.activeOrganizationId) {
16+
if (!applicationIdentifier || !sessionData?.userId || !orgId) {
1317
return null;
1418
}
1519

1620
return (
1721
<Inbox
1822
applicationIdentifier={applicationIdentifier}
19-
subscriber={`${sessionData.userId}-${sessionData.activeOrganizationId}`}
23+
subscriber={`${sessionData.userId}-${orgId}`}
2024
appearance={{
2125
elements: {
2226
popoverContent: {

0 commit comments

Comments
 (0)