-
Notifications
You must be signed in to change notification settings - Fork 321
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
base: main
Are you sure you want to change the base?
fix for unread button on unsubscribed channels #1641 #1758
Conversation
There was a problem hiding this 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
lib/widgets/action_sheet.dart
Outdated
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead && | ||
(message is! StreamMessage || store.subscriptions[message.streamId] != null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead && | |
(message is! StreamMessage || store.subscriptions[message.streamId] != null); | |
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead && | |
(message is! StreamMessage || store.subscriptions[message.streamId] != null); |
There was a problem hiding this 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.
test/widgets/action_sheet_test.dart
Outdated
}); | ||
testWidgets('not visible if message is in unsubscribed stream', (tester) async { |
There was a problem hiding this comment.
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
test/widgets/action_sheet_test.dart
Outdated
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(); |
There was a problem hiding this comment.
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
82f41f5
to
f4fdacd
Compare
I tried to do this |
Fixes: #1641
Before & After