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

Show an unread badge when there are unread notifs from other accounts #3398

Closed
wants to merge 10 commits into from

Conversation

farooqkz
Copy link
Collaborator

This PR adds an unread badge next to hamburger icon and "switch account" button in side bar when there are unread notifications in other account(s).

@farooqkz
Copy link
Collaborator Author

It turns out I've included an unwanted commit. Will open another PR...

@farooqkz farooqkz closed this Sep 13, 2023
@farooqkz farooqkz reopened this Sep 13, 2023
@farooqkz
Copy link
Collaborator Author

It turns out I've included an unwanted commit. Will open another PR...

Reverted :D

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@Simon-Laux Simon-Laux left a comment

Choose a reason for hiding this comment

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

  • the check if "sync all accounts" is activated is missing, it is always shown, which does not make sense if only the active account is synced the unread count of the others can never change
  • I would like to have the unread badge rather on the right in the sidebar and displaying the count of unread messages (the badge on the hamburger menu would be to small for a number, but in the sidebar is enough space for it)
  • fix event listener leak
  • move special animation css colors to themebase if we want them
  • move update code into unread badge itself and have two variants (one small one for the hamburger menu and a bigger one with number for the sidebar.)

scss/_sidebar.scss Outdated Show resolved Hide resolved
accountIds.map(id => onDCEvent(id, 'IncomingMsg', update))
)

return update
Copy link
Member

Choose a reason for hiding this comment

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

the return value of useEffect should be a callback that removes the listeners again, that you created above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you explain more please?

Copy link
Member

Choose a reason for hiding this comment

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

https://react.dev/reference/react/useEffect#useeffect

the return value of the use effect function/callback must be a callback that does cleanup, in this case a callback that removes the event listeners again.

src/renderer/components/screens/MainScreen.tsx Outdated Show resolved Hide resolved
@farooqkz farooqkz requested a review from Simon-Laux September 14, 2023 12:52
@farooqkz farooqkz force-pushed the far-show-unread-multi-acc-badge branch from 094c590 to 2ebc6d6 Compare September 14, 2023 14:25
@farooqkz farooqkz requested a review from Simon-Laux September 20, 2023 15:21
@farooqkz
Copy link
Collaborator Author

farooqkz commented Sep 20, 2023

@Simon-Laux I think I've solved all the problems except for the listener leak thing. I will be grateful if you do a suggestion so that I can learn how should I handle this as it's my first time using useEffect. Thanks in advance.

P.S.: I think the animation of the badge in the sidebar needs some tweaking. Perhaps no animation is better? Suggestions welcome!

@@ -181,7 +181,10 @@ const Sidebar = React.memo(
</div>
<div key='logout' className='sidebar-item' onClick={onLogout}>
{tx('switch_account')}
<OtherAccountsUnreadBadge top='-38px' left='-14px' />
<OtherAccountsUnreadBadge
style={{ top: '-38px', left: '110px' }}
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer having these offsets in they (s)css unless the are either for prototyping or dynamic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The thing is that the parent component has to determine the offsets according to its use. The offsets are different for the hamburger menu icon and in the sidebar.

Copy link
Member

Choose a reason for hiding this comment

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

don't use global offsets if you can, in this case it does not make much sense to use global offsets. Also they can be styled in the scss file of the component they are used in/with.

@Simon-Laux
Copy link
Member

Anyways I would postpone this as there is no clear consensus of the other dc team members if this feature is actually effective enough for it's intended use case.

@hpk42
Copy link
Contributor

hpk42 commented Sep 25, 2023

Not sure myself -- would need to use it for a while to know.
Didn't follow much discussion here -- was there a support forum thread for it? or some other discussed/articulated need?

@farooqkz
Copy link
Collaborator Author

Not sure myself -- would need to use it for a while to know. Didn't follow much discussion here -- was there a support forum thread for it? or some other discussed/articulated need?

It was purely my idea to enhance multi account usage. Wasn't discussed or requested in the forum.

@Simon-Laux
Copy link
Member

Let's rather go for the full sidebar solution soon. closing this for now

@Simon-Laux Simon-Laux closed this Sep 28, 2023
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.

3 participants