Skip to content

Commit

Permalink
Fix case for non set channel notify prop
Browse files Browse the repository at this point in the history
  • Loading branch information
larkox committed Sep 26, 2023
1 parent d3950a4 commit e24e4ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Props = {
defaultThreadReplies: 'all' | 'mention';
isCRTEnabled: boolean;
isMuted: boolean;
notifyLevel?: NotificationLevel;
notifyLevel: NotificationLevel;
notifyThreadReplies?: 'all' | 'mention';
channelType: ChannelType;
hasGMasDMFeature: boolean;
Expand All @@ -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<NotificationLevel>((notifyLevel === undefined || notifyLevel === 'default') ? defaultLevel : notifyLevel);
const [notifyAbout, setNotifyAbout] = useState<NotificationLevel>(notifyLevel === NotificationLevel.DEFAULT ? defaultLevel : notifyLevel);
const [threadReplies, setThreadReplies] = useState<boolean>((notifyThreadReplies || defaultThreadReplies) === 'all');
const [resetDefaultVisible, setResetDefaultVisible] = useState(diffNotificationLevel || defaultNotificationReplies !== threadReplies);

Expand Down
2 changes: 1 addition & 1 deletion app/screens/channel_notification_preferences/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit e24e4ce

Please sign in to comment.