Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(notifications): hide email sidebar badge when email notifications disabled (#8456)
Jacob Beckerman272863be1e5e
diff --git a/apps/web/src/components/app/use-navigation-unread.test.ts b/apps/web/src/components/app/use-navigation-unread.test.tsindex 1f9835f0c1..03e38d8f9f 100644--- a/apps/web/src/components/app/use-navigation-unread.test.ts+++ b/apps/web/src/components/app/use-navigation-unread.test.ts@@ -14,6 +14,7 @@ const mocks = vi.hoisted(() => ({withLocalState: vi.fn(),hasUnreadEntity: vi.fn(),transformEntities: vi.fn(),+ notificationPreferences: vi.fn(),}));vi.mock('@app/lib/analytics/posthog', () => ({@@ -38,6 +39,9 @@ vi.mock('@components/app/GlobalAppState', () => ({withLocalState: mocks.withLocalState,}),}));+vi.mock('@queries/notification/type-preferences', () => ({+ useNotificationTypePreferencesQuery: mocks.notificationPreferences,+}));// Query builders import the soup barrel, which otherwise opens real sockets.vi.mock('@service-storage/websocket', () => ({storageWS: { reconnectIfDisconnected: vi.fn() },@@ -88,9 +92,15 @@ function setup(graphql = false) {dispose = cleanup;const [graphqlEnabled, setGraphqlEnabled] = createSignal(graphql);const [done, setDone] = createSignal(false);+ const [disabledTypes, setDisabledTypes] = createSignal<string[]>([]);mocks.withLocalState.mockImplementation(({ state }) =>done() ? 'done' : state);+ mocks.notificationPreferences.mockImplementation(() => ({+ get data() {+ return { disabled_types: disabledTypes() };+ },+ }));const [witnesses, setWitnesses] = createSignal<{ id: string; state: NotificationState }[]>([]);@@ -137,6 +147,7 @@ function setup(graphql = false) {setWitnesses,setGraphqlEnabled,setDone,+ setDisabledTypes,};});}@@ -271,4 +282,17 @@ describe('navigation unread presence', () => {setNotifications([]);expect(unread('channels')).toBe(false);});++ it('hides email badge when email notifications are disabled', () => {+ const { unread, setLoading, setEmails, setDisabledTypes } = setup();+ setLoading(false);+ setEmails([unreadEmail]);+ expect(unread('mail')).toBe(true);+ setDisabledTypes(['new_email']);+ expect(unread('mail')).toBe(false);+ setDisabledTypes([]);+ expect(unread('mail')).toBe(true);+ setDisabledTypes(['channel_mention', 'new_email', 'task_assigned']);+ expect(unread('mail')).toBe(false);+ });});diff --git a/apps/web/src/components/app/use-navigation-unread.ts b/apps/web/src/components/app/use-navigation-unread.tsindex 833851ec60..091ac39e86 100644--- a/apps/web/src/components/app/use-navigation-unread.ts+++ b/apps/web/src/components/app/use-navigation-unread.ts@@ -14,6 +14,7 @@ import { notificationIsRead } from '@entity/utils/notification';import { notificationStateFromGraphql } from '@notifications/notification-state';import { isUnreadChannelMessageNotification } from '@notifications/top-level-channel-notification';import { createChannelUnreadQuery } from '@queries/channel/unread-presence';+import { useNotificationTypePreferencesQuery } from '@queries/notification/type-preferences';import { makeGraphqlSoupInput } from '@queries/soup/graphql/ast';import {type SoupApiItemFilter,@@ -29,6 +30,9 @@ const signalInsertFilter: SoupApiItemFilter = (item) =>export function useNavigationUnread() {const notificationSource = useGlobalNotificationSource();const graphqlFlag = useFeatureFlag(enableGraphqlSoup);+ const preferencesQuery = useNotificationTypePreferencesQuery();+ const isTypeDisabled = (type: string) =>+ preferencesQuery.data?.disabled_types.includes(type) ?? false;const channels = createChannelUnreadQuery(makeGraphqlSoupInput({// Preserve the previous feed's 500-entity candidate bound, but select@@ -60,7 +64,9 @@ export function useNavigationUnread() {// Guard resource reads so loading a badge cannot suspend the app shell.// Re-check cached rows: optimistic read/done changes can leave them in a page.+ // Respect user preference: hide badge when email notifications are disabled.const emailUnread = createMemo(() => {+ if (isTypeDisabled('new_email')) return false;if (email.isLoading) return false;return (email.data?.entities ?? []).some((entity) => entity.type === 'email' && !entity.isRead && !entity.done