Skip to content

Commit 0755db1

Browse files
committed
NotificationsScreen: Hide per-account settings when notifs not enabled
We're already showing a persistent banner on this screen when the server has declared that it doesn't support push notifications.
1 parent 5790a4e commit 0755db1

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

src/settings/NotificationsScreen.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { LocalizableText } from '../types';
2020
import { TranslationContext } from '../boot/TranslationProvider';
2121
import { kWarningColor } from '../styles/constants';
2222
import { getIdentities, getIdentity, getIsActiveAccount } from '../account/accountsSelectors';
23-
import { getRealmName } from '../directSelectors';
23+
import { getRealm, getRealmName } from '../directSelectors';
2424
import ZulipText from '../common/ZulipText';
2525
import SettingsGroup from './SettingsGroup';
2626

@@ -124,6 +124,7 @@ export default function NotificationsScreen(props: Props): Node {
124124
getIdentities(state).filter(identity_ => !getIsActiveAccount(state, identity_)),
125125
);
126126
const realmName = useSelector(getRealmName);
127+
const pushNotificationsEnabled = useSelector(state => getRealm(state).pushNotificationsEnabled);
127128
const offlineNotification = useSelector(state => getSettings(state).offlineNotification);
128129
const onlineNotification = useSelector(state => getSettings(state).onlineNotification);
129130
const streamNotification = useSelector(state => getSettings(state).streamNotification);
@@ -213,31 +214,33 @@ export default function NotificationsScreen(props: Props): Node {
213214
})()}
214215
onPress={handleSystemSettingsPress}
215216
/>
216-
<SettingsGroup
217-
title={{
218-
text: 'Notification settings for this account ({email} in {realmName}):',
219-
values: {
220-
email: <ZulipText style={{ fontWeight: 'bold' }} text={identity.email} />,
221-
realmName: <ZulipText style={{ fontWeight: 'bold' }} text={realmName} />,
222-
},
223-
}}
224-
>
225-
<SwitchRow
226-
label="Notifications when offline"
227-
value={offlineNotification}
228-
onValueChange={handleOfflineNotificationChange}
229-
/>
230-
<SwitchRow
231-
label="Notifications when online"
232-
value={onlineNotification}
233-
onValueChange={handleOnlineNotificationChange}
234-
/>
235-
<SwitchRow
236-
label="Stream notifications"
237-
value={streamNotification}
238-
onValueChange={handleStreamNotificationChange}
239-
/>
240-
</SettingsGroup>
217+
{pushNotificationsEnabled && (
218+
<SettingsGroup
219+
title={{
220+
text: 'Notification settings for this account ({email} in {realmName}):',
221+
values: {
222+
email: <ZulipText style={{ fontWeight: 'bold' }} text={identity.email} />,
223+
realmName: <ZulipText style={{ fontWeight: 'bold' }} text={realmName} />,
224+
},
225+
}}
226+
>
227+
<SwitchRow
228+
label="Notifications when offline"
229+
value={offlineNotification}
230+
onValueChange={handleOfflineNotificationChange}
231+
/>
232+
<SwitchRow
233+
label="Notifications when online"
234+
value={onlineNotification}
235+
onValueChange={handleOnlineNotificationChange}
236+
/>
237+
<SwitchRow
238+
label="Stream notifications"
239+
value={streamNotification}
240+
onValueChange={handleStreamNotificationChange}
241+
/>
242+
</SettingsGroup>
243+
)}
241244
{otherAccounts.length > 0 && (
242245
<NestedNavRow title="Other accounts" onPress={handleOtherAccountsPress} />
243246
)}

0 commit comments

Comments
 (0)