@@ -155,47 +155,34 @@ void showTopicActionSheet(BuildContext context, {
155
155
}) {
156
156
final store = PerAccountStoreWidget .of (context);
157
157
final channelMuted = store.subscriptions[channelId]? .isMuted;
158
- final visibilityPolicy = store.topicVisibilityPolicy (channelId, topic);
159
-
160
- final narrow = TopicNarrow (channelId, topic);
161
- UserTopicUpdateButton button (UserTopicVisibilityPolicy to) {
162
- return UserTopicUpdateButton (
163
- currentVisibilityPolicy: visibilityPolicy,
164
- newVisibilityPolicy: to,
165
- narrow: narrow,
166
- pageContext: context);
167
- }
168
158
169
- final mute = button (UserTopicVisibilityPolicy .muted);
170
- final unmute = button (UserTopicVisibilityPolicy .none);
171
- final unmuteInMutedChannel = button (UserTopicVisibilityPolicy .unmuted);
172
- final follow = button (UserTopicVisibilityPolicy .followed);
173
- final unfollow = button (UserTopicVisibilityPolicy .none);
159
+ final optionButtons = < ActionSheetMenuItemButton > [];
174
160
175
161
// TODO(server-7): simplify this condition away
176
162
final supportsUnmutingTopics = store.connection.zulipFeatureLevel! >= 170 ;
177
163
// TODO(server-8): simplify this condition away
178
164
final supportsFollowingTopics = store.connection.zulipFeatureLevel! >= 219 ;
179
165
180
- final optionButtons = < ActionSheetMenuItemButton > [];
166
+ final visibilityOptions = < UserTopicVisibilityPolicy > [];
167
+ final visibilityPolicy = store.topicVisibilityPolicy (channelId, topic);
181
168
if (channelMuted != null && ! channelMuted) {
182
169
// Channel is subscribed and not muted.
183
170
switch (visibilityPolicy) {
184
171
case UserTopicVisibilityPolicy .muted:
185
- optionButtons .add (unmute );
172
+ visibilityOptions .add (UserTopicVisibilityPolicy .none );
186
173
if (supportsFollowingTopics) {
187
- optionButtons .add (follow );
174
+ visibilityOptions .add (UserTopicVisibilityPolicy .followed );
188
175
}
189
176
case UserTopicVisibilityPolicy .none:
190
177
case UserTopicVisibilityPolicy .unmuted:
191
- optionButtons .add (mute );
178
+ visibilityOptions .add (UserTopicVisibilityPolicy .muted );
192
179
if (supportsFollowingTopics) {
193
- optionButtons .add (follow );
180
+ visibilityOptions .add (UserTopicVisibilityPolicy .followed );
194
181
}
195
182
case UserTopicVisibilityPolicy .followed:
196
- optionButtons .add (mute );
183
+ visibilityOptions .add (UserTopicVisibilityPolicy .muted );
197
184
if (supportsFollowingTopics) {
198
- optionButtons .add (unfollow );
185
+ visibilityOptions .add (UserTopicVisibilityPolicy .none );
199
186
}
200
187
case UserTopicVisibilityPolicy .unknown:
201
188
// TODO(#1074): This should be unreachable as we keep `unknown` out of
@@ -208,19 +195,19 @@ void showTopicActionSheet(BuildContext context, {
208
195
switch (visibilityPolicy) {
209
196
case UserTopicVisibilityPolicy .none:
210
197
case UserTopicVisibilityPolicy .muted:
211
- optionButtons .add (unmuteInMutedChannel );
198
+ visibilityOptions .add (UserTopicVisibilityPolicy .unmuted );
212
199
if (supportsFollowingTopics) {
213
- optionButtons .add (follow );
200
+ visibilityOptions .add (UserTopicVisibilityPolicy .followed );
214
201
}
215
202
case UserTopicVisibilityPolicy .unmuted:
216
- optionButtons .add (mute );
203
+ visibilityOptions .add (UserTopicVisibilityPolicy .muted );
217
204
if (supportsFollowingTopics) {
218
- optionButtons .add (follow );
205
+ visibilityOptions .add (UserTopicVisibilityPolicy .followed );
219
206
}
220
207
case UserTopicVisibilityPolicy .followed:
221
- optionButtons .add (mute );
208
+ visibilityOptions .add (UserTopicVisibilityPolicy .muted );
222
209
if (supportsFollowingTopics) {
223
- optionButtons .add (unfollow );
210
+ visibilityOptions .add (UserTopicVisibilityPolicy .none );
224
211
}
225
212
case UserTopicVisibilityPolicy .unknown:
226
213
// TODO(#1074): This should be unreachable as we keep `unknown` out of
@@ -231,6 +218,13 @@ void showTopicActionSheet(BuildContext context, {
231
218
} else {
232
219
// Not subscribed to the channel; there is no user topic change to be made.
233
220
}
221
+ optionButtons.addAll (visibilityOptions.map ((to) {
222
+ return UserTopicUpdateButton (
223
+ currentVisibilityPolicy: visibilityPolicy,
224
+ newVisibilityPolicy: to,
225
+ narrow: TopicNarrow (channelId, topic),
226
+ pageContext: context);
227
+ }));
234
228
235
229
if (optionButtons.isEmpty) {
236
230
// TODO(a11y): This case makes a no-op gesture handler; as a consequence,
0 commit comments