From e24e4ceabdf69027d70296ccfb70a1790033ddc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Tue, 26 Sep 2023 10:17:57 +0200 Subject: [PATCH] Fix case for non set channel notify prop --- .../channel_info/options/notification_preference/index.ts | 3 ++- .../channel_notification_preferences.tsx | 6 +++--- app/screens/channel_notification_preferences/index.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/screens/channel_info/options/notification_preference/index.ts b/app/screens/channel_info/options/notification_preference/index.ts index f82ea0f2301..2e63f35bc77 100644 --- a/app/screens/channel_info/options/notification_preference/index.ts +++ b/app/screens/channel_info/options/notification_preference/index.ts @@ -6,6 +6,7 @@ import withObservables from '@nozbe/with-observables'; import {of as of$} from 'rxjs'; import {switchMap} from 'rxjs/operators'; +import {NotificationLevel} from '@constants'; import {observeChannel, observeChannelSettings} from '@queries/servers/channel'; import {observeHasGMasDMFeature} from '@queries/servers/features'; import {observeCurrentUser} from '@queries/servers/user'; @@ -26,7 +27,7 @@ const enhanced = withObservables(['channelId'], ({channelId, database}: Props) = const settings = observeChannelSettings(database, channelId); const userNotifyLevel = observeCurrentUser(database).pipe(switchMap((u) => of$(getNotificationProps(u).push))); const notifyLevel = settings.pipe( - switchMap((s) => of$(s?.notifyProps.push)), + switchMap((s) => of$(s?.notifyProps.push || NotificationLevel.DEFAULT)), ); const hasGMasDMFeature = observeHasGMasDMFeature(database); diff --git a/app/screens/channel_notification_preferences/channel_notification_preferences.tsx b/app/screens/channel_notification_preferences/channel_notification_preferences.tsx index 2698394c44c..17636520b43 100644 --- a/app/screens/channel_notification_preferences/channel_notification_preferences.tsx +++ b/app/screens/channel_notification_preferences/channel_notification_preferences.tsx @@ -30,7 +30,7 @@ type Props = { defaultThreadReplies: 'all' | 'mention'; isCRTEnabled: boolean; isMuted: boolean; - notifyLevel?: NotificationLevel; + notifyLevel: NotificationLevel; notifyThreadReplies?: 'all' | 'mention'; channelType: ChannelType; hasGMasDMFeature: boolean; @@ -50,9 +50,9 @@ const ChannelNotificationPreferences = ({ }: Props) => { const serverUrl = useServerUrl(); const defaultNotificationReplies = defaultThreadReplies === 'all'; - const diffNotificationLevel = notifyLevel !== 'default' && notifyLevel !== defaultLevel; + const diffNotificationLevel = notifyLevel !== NotificationLevel.DEFAULT && notifyLevel !== defaultLevel; const notifyTitleTop = useSharedValue((isMuted ? MUTED_BANNER_HEIGHT : 0) + BLOCK_TITLE_HEIGHT); - const [notifyAbout, setNotifyAbout] = useState((notifyLevel === undefined || notifyLevel === 'default') ? defaultLevel : notifyLevel); + const [notifyAbout, setNotifyAbout] = useState(notifyLevel === NotificationLevel.DEFAULT ? defaultLevel : notifyLevel); const [threadReplies, setThreadReplies] = useState((notifyThreadReplies || defaultThreadReplies) === 'all'); const [resetDefaultVisible, setResetDefaultVisible] = useState(diffNotificationLevel || defaultNotificationReplies !== threadReplies); diff --git a/app/screens/channel_notification_preferences/index.ts b/app/screens/channel_notification_preferences/index.ts index 5490984856b..12116400e40 100644 --- a/app/screens/channel_notification_preferences/index.ts +++ b/app/screens/channel_notification_preferences/index.ts @@ -31,7 +31,7 @@ const enhanced = withObservables([], ({channelId, database}: EnhancedProps) => { const hasGMasDMFeature = observeHasGMasDMFeature(database); const notifyLevel = settings.pipe( - switchMap((s) => of$(s?.notifyProps.push)), + switchMap((s) => of$(s?.notifyProps.push || NotificationLevel.DEFAULT)), ); const notifyThreadReplies = settings.pipe(