Skip to content

Commit e0e5219

Browse files
committed
mute: Don't offer mute/unmute in action sheet when not subscribed
The concept of muting or unmuting a stream can only exist when the user is subscribed in the first place; without a subscription, there isn't even a place in the data model for the muted/unmuted state to live. For a topic, the data model doesn't rule it out but it wouldn't mean anything: you don't get unreads or notifications when you're not subscribed.
1 parent 6a97764 commit e0e5219

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/action-sheets/index.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,16 +627,25 @@ export const constructTopicActionButtons = (args: {|
627627
|}): Button<TopicArgs>[] => {
628628
const { backgroundData, streamId, topic } = args;
629629
const { mute, ownUserRole, subscriptions, unread } = backgroundData;
630+
const sub = subscriptions.get(streamId);
631+
const streamMuted = !!sub && !sub.in_home_view;
630632

631633
const buttons = [];
632634
const unreadCount = getUnreadCountForTopic(unread, streamId, topic);
633635
if (unreadCount > 0) {
634636
buttons.push(markTopicAsRead);
635637
}
636-
if (isTopicMuted(streamId, topic, mute)) {
637-
buttons.push(unmuteTopic);
638+
if (sub && !streamMuted) {
639+
// Stream subscribed and not muted.
640+
if (isTopicMuted(streamId, topic, mute)) {
641+
buttons.push(unmuteTopic);
642+
} else {
643+
buttons.push(muteTopic);
644+
}
645+
} else if (sub && streamMuted) {
646+
// TODO(#5691): offer new "unmute topic" concept, when server supports it
638647
} else {
639-
buttons.push(muteTopic);
648+
// Not subscribed to stream at all; no muting.
640649
}
641650
if (!resolved_topic.is_resolved(topic)) {
642651
buttons.push(resolveTopic);
@@ -646,11 +655,12 @@ export const constructTopicActionButtons = (args: {|
646655
if (roleIsAtLeast(ownUserRole, Role.Admin)) {
647656
buttons.push(deleteTopic);
648657
}
649-
const sub = subscriptions.get(streamId);
650-
if (sub && !sub.in_home_view) {
658+
if (sub && streamMuted) {
651659
buttons.push(unmuteStream);
652-
} else {
660+
} else if (sub && !streamMuted) {
653661
buttons.push(muteStream);
662+
} else {
663+
// Not subscribed to stream at all; no muting.
654664
}
655665
buttons.push(copyLinkToTopic);
656666
buttons.push(showStreamSettings);

0 commit comments

Comments
 (0)