Skip to content

fix for unread button on unsubscribed channels #1641 #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

loveucifer
Copy link

@loveucifer loveucifer commented Jul 28, 2025

Fixes: #1641


Before & After

Before After
The button was incorrectly shown for unsubscribed channels. The button is now not present in the channel.
A screenshot showing the message action sheet with the 'Mark as unread from here' button visible. A screenshot showing the message action sheet without the 'Mark as unread from here' button.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explained in the README (please follow links from there and read): https://github.com/zulip/zulip-flutter?tab=readme-ov-file#submitting-a-pull-request

  • This needs a test
  • Write the commit message according to the project style

Comment on lines 609 to 610
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead &&
(message is! StreamMessage || store.subscriptions[message.streamId] != null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead &&
(message is! StreamMessage || store.subscriptions[message.streamId] != null);
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead &&
(message is! StreamMessage || store.subscriptions[message.streamId] != null);

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments below. Please squash the commit that adds the test into the commit that makes it necessary, as explained in our docs.

Comment on lines 1342 to 1344
});
testWidgets('not visible if message is in unsubscribed stream', (tester) async {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add blank line separating tests

Comment on lines 1346 to 1371
final stream = eg.stream();
final readMessage = eg.streamMessage(stream: stream, flags: [MessageFlag.read]);
final narrow = TopicNarrow.ofMessage(readMessage);

// Manually set up the store, but without subscribing to the stream.
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
connection = store.connection as FakeApiConnection;
await store.addUser(eg.selfUser);
await store.addUser(eg.user(userId: readMessage.senderId));
await store.addStream(stream);
// Do NOT add the subscription.

// Prepare the API response for the message list.
connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: [readMessage]).toJson());

// Build the message list page.
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
child: MessageListPage(initNarrow: narrow)));
await tester.pumpAndSettle();

// Open the action sheet for the message.
await tester.longPress(find.byType(MessageContent), warnIfMissed: false);
await tester.pump(const Duration(milliseconds: 250)); // animation
check(find.byType(BottomSheet)).findsOne();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of reimplementing setupToMessageActionSheet with a difference, let's just call it, then afterward remove the subscription with store.handleEvent(SubscriptionRemoveEvent(.

Using a common helper function helps with code maintainability when there's a future change that needs to be made to many tests' setup at once.

earlier, the 'Mark as unread' button was displayed for any read message even if they were unsubscribed .

This pr change adds a condition that should only show the button for direct messages or for stream messages where the subscription exists. The corresponding test is added to verify this new behavior which uses the `setupToMessageActionSheet` helper, dismissing the action sheet and also firing the `SubscriptionRemoveEvent`, and then re-opening the sheet to confirm that the button is now  not present there
@loveucifer loveucifer force-pushed the fix/omit-unread-button-unsubscribed branch from 82f41f5 to f4fdacd Compare July 30, 2025 10:38
@loveucifer
Copy link
Author

Comments below. Please squash the commit that adds the test into the commit that makes it necessary, as explained in our docs.

I tried to do this git rebase -i HEAD~2 for the 2 files I changed hope this is the change you requested I had not used that yet I hope I did it correctly

@loveucifer loveucifer requested a review from chrisbobbe July 30, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

msglist: Don't show "Mark as unread from here" button in unsubscribed channels
2 participants