@@ -231,6 +231,14 @@ class _TopicItem extends StatelessWidget {
231
231
final isTopicVisibleInStream = store.isTopicVisibleInStream (streamId, topic);
232
232
final visibilityIcon = iconDataForTopicVisibilityPolicy (
233
233
store.topicVisibilityPolicy (streamId, topic));
234
+ // The message with `maxId` might not remain in `topic` since we last fetch
235
+ // the list of topics. Make sure we check for that before passing `maxId`
236
+ // to the topic action sheet.
237
+ // See also: [ChannelStore.getStreamTopics]
238
+ final message = store.messages[maxId];
239
+ final isMaxIdInTopic = message is StreamMessage
240
+ && message.streamId == streamId
241
+ && message.topic.isSameAs (topic);
234
242
235
243
final trailingWidgets = [
236
244
if (hasMention) const _IconMarker (icon: ZulipIcons .at_sign),
@@ -249,7 +257,7 @@ class _TopicItem extends StatelessWidget {
249
257
onLongPress: () => showTopicActionSheet (context,
250
258
channelId: streamId,
251
259
topic: topic,
252
- someMessageIdInTopic: maxId),
260
+ someMessageIdInTopic: isMaxIdInTopic ? maxId : null ),
253
261
splashFactory: NoSplash .splashFactory,
254
262
child: Padding (padding: EdgeInsetsDirectional .fromSTEB (28 , 8 , 12 , 8 ),
255
263
child: Row (
0 commit comments