Skip to content
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

Add badge in spaces button (PSG-944) #7088

Merged
merged 8 commits into from
Nov 30, 2022
Merged

Conversation

alfogrillo
Copy link
Contributor

@alfogrillo alfogrillo commented Nov 18, 2022

Description

This PR add the badges for messages in the "spaces button" in the bottom bar.
The badge is meant to show the total number of unread messages across all the root spaces.

Dependency

matrix-org/matrix-ios-sdk#1645

Simulator Screen Recording - iPhone 14 Pro - 2022-11-18 at 12 29 04

@alfogrillo alfogrillo requested review from a team and pixlwave and removed request for a team November 18, 2022 11:34
Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Oh this would be a lovely change! I recently missed an invite for the whole day when I was inside of a space so would love to have this back.

I've added some comments inline.

The PR is also missing a changelog.

Riot/Modules/Home/AllChats/AllChatsViewController.swift Outdated Show resolved Hide resolved
Riot/Modules/Home/AllChats/AllChatsViewController.swift Outdated Show resolved Hide resolved
Comment on lines 531 to 536
spacesButton.badgeText = session.map {
"\($0.spaceService.rootSpacesNotificationCount)"
}
spacesButton.badgeBackgroundColor = session.map {
$0.spaceService.rootSpacesHaveHighlightNotification ? theme.noticeColor : theme.noticeSecondaryColor
} ?? .clear
Copy link
Member

Choose a reason for hiding this comment

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

Should this implementation be shared with the old one on the MasterTabBarController?

Seems like using mainSession.spaceService.notificationCounter.notificationState(forAllSpacesExcept:) might be helpful rather than the private extension on the space service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmmh, the logic looks different.
Here we show the count of all unread messages including the ones in current space.
Invites to spaces are ignored unfortunately! 😅
@Johennes do you think it makes sense to cover also invites under this PR (changing the ACs)?
Not having them covered looks like a UX bug to me.

Copy link
Member

Choose a reason for hiding this comment

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

Here we show the count of all unread messages including the ones in current space.

My bad I hadn't noticed that 🙈

Copy link
Member

Choose a reason for hiding this comment

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

One thought looking at f1ce202. Moving the notificationState(forAllSpacesExcept: nil) up to this method would mean you could read allCount and allHighlightCount without having to iterate through the spaces twice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Including space invites in the highlight count seems sensible to me as I assume you otherwise might miss them just like normal messages in another space than the one you're in?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting. Maybe it still makes sense to sum that up? It's still an unread message of sorts so I suppose it should count as a 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or alternatively we could only use it to drive the color of the spaces icon badge?

Copy link
Contributor Author

@alfogrillo alfogrillo Nov 18, 2022

Choose a reason for hiding this comment

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

If we go this way probably we would need to implement both.
If you rely just on the color you could find yourself in a situation where you don't have unread messages but just invites and the badge wouldn't show. :-/

Copy link
Member

Choose a reason for hiding this comment

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

Side note to do with as you wish: I was referring to invites as "an invite to a DM which only show up in the All Chats screen".

Copy link
Contributor

Choose a reason for hiding this comment

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

If you rely just on the color you could find yourself in a situation where you don't have unread messages but just invites and the badge wouldn't show. :-/

Could we just use the red exclamation mark on the spaces icon in that case?

Side note to do with as you wish: I was referring to invites as "an invite to a DM which only show up in the All Chats screen".

Oh, I see! That's this case then:

simulator_screenshot_F08BEE4B-2C68-47EB-A56D-8695A6C6A65B

Well, I suppose we should be covering both. This one seems more straightforward though because the invite can simply count as a red badge of 1 in the all spaces space?

@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Base: 11.73% // Head: 11.77% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (9be5f59) compared to base (11e39db).
Patch coverage: 40.47% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7088      +/-   ##
===========================================
+ Coverage    11.73%   11.77%   +0.03%     
===========================================
  Files         1620     1620              
  Lines       159302   159293       -9     
  Branches     64811    64810       -1     
===========================================
+ Hits         18689    18749      +60     
+ Misses      139977   139906      -71     
- Partials       636      638       +2     
Flag Coverage Δ
uitests 54.83% <ø> (+0.03%) ⬆️
unittests 5.98% <40.47%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...Modules/Home/AllChats/AllChatsViewController.swift 29.11% <40.47%> (+0.18%) ⬆️
...ojiPicker/Data/EmojiMart/EmojiItem+EmojiMart.swift 95.34% <0.00%> (-0.31%) ⬇️
...oadcast/VoiceBroadcastSDK/VoiceBroadcastInfo.swift 0.00% <0.00%> (ø)
...castPlayback/View/VoiceBroadcastPlaybackView.swift 0.00% <0.00%> (ø)
...ck/MatrixSDK/VoiceBroadcastPlaybackViewModel.swift 0.00% <0.00%> (ø)
...iot/Modules/Common/Views/BadgedBarButtonItem.swift 68.91% <0.00%> (+68.91%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Looks good to me with the extra comments just added.

But I'd love for invites to be included too if that's an option 😄

@alfogrillo
Copy link
Contributor Author

@amshakal could you please review the design?

@sonarcloud
Copy link

sonarcloud bot commented Nov 28, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for making the extra changes 🙌

@alfogrillo alfogrillo merged commit ef8a9be into develop Nov 30, 2022
@alfogrillo alfogrillo deleted the alfogrillo/badges_spaces branch November 30, 2022 09:22
@alfogrillo alfogrillo changed the title Add badge in spaces button (PSG-966) Add badge in spaces button (PSG-944) Dec 13, 2022
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.

4 participants