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 desktop dock icon indicator in Electron #525

Merged
merged 36 commits into from
Oct 9, 2020
Merged

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Sep 22, 2020

Fixes: https://github.com/Expensify/Expensify/issues/141720

cc @tgolen who probably has some ideas on how to improve this...

In order to accomplish this I added an unreadActionCount to reports in addition to isUnread this way we can pass a number to anything that wants to know about how many unread there are.

Other things I'd like to do:

  • Move these ipcRenderer events into some kind of ELECTRON_EVENTS file Done
  • Debounce the updatePageTitleAndUnreadCount() method since it gets called many times in quick succession when anything subscribes to IONKEYS.COLLECTION.REPORT (maybe there's another way around this - but seems to work ok) Done

Tests:

  1. Log into the Desktop app
  2. Make sure you have one unread chat in your LHN by adding a comment to a report as a shared user
  3. Verify your dock icon says there is 1 message

Screenshot 1376

1. Reboot the app and verify that the icon is updated correctly 1. Click on one of the unread chats 1. Verify that the dock icon number clears

Screenshot 1378

1. Nav away from the chat and add two more messages 1. Verify the dock icon count increments to 2

@marcaaron marcaaron self-assigned this Sep 22, 2020
src/lib/UnreadIndicatorUpdater/index.js Show resolved Hide resolved
src/lib/UnreadIndicatorUpdater/index.js Outdated Show resolved Hide resolved
src/lib/actions/Report.js Outdated Show resolved Hide resolved
src/page/home/HomePage.js Outdated Show resolved Hide resolved
},
}),
)(SidebarLink);
export default SidebarLink;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just cleaning this up. I couldn't really see any reason why we should want to add both the withRouter and withIon when we can just get the info from props.

@marcaaron marcaaron marked this pull request as ready for review September 22, 2020 22:38
@AndrewGable
Copy link
Contributor

I guess this is more a philosophical question, but should we be implementing the mobile count as well in this PR?

@marcaaron
Copy link
Contributor Author

I guess this is more a philosophical question, but should we be implementing the mobile count as well in this PR?

I'm up for looking into that! I don't think there's any rush here and that would definitely hook into this same logic I'd imagine.

@marcaaron
Copy link
Contributor Author

But to answer philosophically I wouldn't stress about having implemented something like this for only one platform as long as there are plans to eventually release a feature for all applicable platforms. Once this app is in people's hands I'd vote for sticking more closely to that philosophy, but have it be a flexible rule since we could end up with some pretty mondo PRs.

@marcaaron
Copy link
Contributor Author

Looks like iOS has this out of the box. Android not so much. Another thing to consider is that this update might need to happen as a response to a push notification and not a pusher update while the app is open.

@marcaaron
Copy link
Contributor Author

Alright, added a way to set the app badge icon in iOS, but can't test it since I don't have a working iOS device at the moment.

@roryabraham
Copy link
Contributor

@marcaaron lmk when it's ready and I can test for you 👍

@marcaaron
Copy link
Contributor Author

Go for it @roryabraham !

@marcaaron marcaaron changed the title Add desktop dock icon indicator in Electron [HOLD] Add desktop dock icon indicator in Electron Sep 23, 2020
@roryabraham roryabraham removed their request for review September 28, 2020 17:51
Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Nice cleanup on the sidebarlink. Just a couple of small things here.

metro.config.js Outdated
@@ -5,6 +5,7 @@
* @format
*/


Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary extra space

// There are unread items if the last one the user has read is less
// than the highest sequence number we have.
const unreadActionCount = (maxSequenceNumber || report.reportActionList.length) - usersLastReadActionID;
return unreadActionCount > 0 ? unreadActionCount : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think using Math.max() here makes it more readable.

@marcaaron
Copy link
Contributor Author

Just coming back to this one. This PR has gotten a little big and I've uncovered a few bugs in the existing code that I've fixed here... so, I'm going to split this into two PRs so we can focus on making sure that:

  1. Displaying unread chats in the LHN is super solid
  2. Then add in the UI bits to show the count

@marcaaron marcaaron changed the title Add desktop dock icon indicator in Electron [HOLD] Add desktop dock icon indicator in Electron Oct 6, 2020
@marcaaron
Copy link
Contributor Author

Putting a hold on this until we merge #597

@marcaaron marcaaron changed the title [HOLD] Add desktop dock icon indicator in Electron Add desktop dock icon indicator in Electron Oct 8, 2020
@marcaaron
Copy link
Contributor Author

Taking hold off this one now that half these changes have been merged :)

@marcaaron
Copy link
Contributor Author

Fix conflicts on this one and ready for another review.

@tgolen tgolen merged commit a5cfbd3 into master Oct 9, 2020
@tgolen tgolen deleted the marcaaron-desktopbadge branch October 9, 2020 20:55
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