Skip to content

Show badge with unread counter #90

Description

@brunolemos
  • Show an "unread dot" on sidebar items
  • Show a badge counter on app icon:
    • Web
    • Desktop
    • iOS
    • Android
  • Only enable for the columns the user specify

Help wanted

Activity

  1. changed the title [-]Show badge with unread counter (opt-in)[/-] [+]Show badge with unread counter[/+] on Jan 9, 2019
  2. panva commented on Mar 6, 2019

    @panva

    @brunolemos how about Menubar mode badge in the status bar?

  3. dkniffin commented on Jun 25, 2019

    @dkniffin
    Contributor

    Menubar badge would be 💯. I've been using Gitify for a long time, and it changes the color when there's unread notifications, which works great. But knowing the number too somehow would be icing on that cake.

  4. dkniffin commented on Jun 25, 2019

    @dkniffin
    Contributor

    I might actually take a stab at implementing that. I'm familiar with the react-native-web architecture, but not the specifics of this project. Is this the right place for that change?

    Also, for the number, the only way I can think to do it is to have different images for each number. Maybe created dynamically as discussed here: electron/electron#7322

  5. brunolemos commented on Jun 25, 2019

    @brunolemos
    MemberAuthor

    @dkniffin yes that would be the file!

    I think the hardest part will be that each column needs to have a config to enable or disable the badge (and I haven't created a UI for that or thought about config object structure yet); but we can think of a simpler solution to start.

    I recently created a method called getItemsFilterMetadata that returns the number of unread items for a specific column and that was a requirement for the badge feature, so it will come handy.

    const filteredItemsMetadata = getItemsFilterMetadata(
    column.type,
    getFilteredItems(
    column.type,
    allItems,
    { ...column.filters, unread: undefined },
    getFilteredItemsOptions,
    ),
    )

    unread: filteredItemsMetadata.inbox[inbox].unread,

    The code above shows the number 49 at the screenshot below:

    image

    Also needs to think where is the best place to put a watcher for these unread numbers. Probably a react Context. And then, send the info to electron using the window.ipc.send method.

  6. jletey commented on Jun 26, 2019

    @jletey
    Contributor

    @dkniffin are you going to just work on the icon badge counter? if so, I can have a go at the "unread dot" on sidebar items (kind of like Slack and Discord)

  7. dkniffin commented on Jun 26, 2019

    @dkniffin
    Contributor

    @johnletey Yeah, if I do anything on here, it would be the menubar indicator

  8. jletey commented on Jun 26, 2019

    @jletey
    Contributor

    @dkniffin Wonderful ... I will get started on the "unread dot" feature now!

  9. dkniffin commented on Jun 30, 2019

    @dkniffin
    Contributor

    @brunolemos I'm trying to get the menubar/tray indicator working. I know how to render it, but I'm having a hard time figuring out how to get the data needed to determine which state to render it in. You mentioned getItemsFilterMetadata, but I'm not sure how to use that in the Tray.ts file, since I need access to a column, but I don't know which column is being displayed. Thoughts?

  10. brunolemos commented on Jun 30, 2019

    @brunolemos
    MemberAuthor

    @dkniffin the tray.ts file is the last step, everything else will happen inside the components package.

    Check the file Sidebar.tsx, it is a mess but it has everything you need there. It lists all the columns and show an unread indicator.

    I think we need a React Context, e.g. UnreadWatcherContext.tsx, that will be responsible to check the unread indicator for all columns. If there are columns with unread items, let’s sum the number of items and communicate it to Electron (which is running on a different thread).

    To send messages to Electron, first check that it is an electron app (if (Platform.isElectron) {) and send the event (e.g. window.ipc.send(‘unread-counter’, numberOfUnreadItems)).

    You need to listen to this unread-counter event on Electron (file desktop/src/index.ts), with a app.on(‘unread-counter’, … event listener). And then change the menubar icon badge (tray.yourMethodHere(counter)).

  11. dkniffin commented on Jun 30, 2019

    @dkniffin
    Contributor

    Ok, thanks. That makes sense. I'll give that a shot

  12. brunolemos commented on Jun 30, 2019

    @brunolemos
    MemberAuthor

    You can use this to get all the columns:

    const columns = useReduxState(selectors.columnsArrSelector)

    And then for each column you do something like this to get the unread count for each one:

    const { allItems } = useColumnData(column.id, getFilteredItemsOptions)
    const filteredItemsMetadata = getItemsFilterMetadata(
    column.type,
    getFilteredItems(
    column.type,
    allItems,
    { ...column.filters, unread: undefined },
    getFilteredItemsOptions,
    ),
    )
    const inbox =
    column.type === 'notifications' &&
    column.filters &&
    column.filters.notifications &&
    column.filters.notifications.participating
    ? 'participating'
    : 'all'
    const isUnread =
    filteredItemsMetadata.inbox[inbox].unread > 0 ? true : false

  13. dkniffin commented on Jun 30, 2019

    @dkniffin
    Contributor

    @brunolemos These context objects are unfamiliar to me. Are these the same as React Contexts or is this a different thing?

  14. 1 remaining item

  15. dkniffin commented on Jun 30, 2019

    @dkniffin
    Contributor

    @brunolemos Sorry I keep pestering you with questions about this. I think I've got the context set up correctly, and I understand how to pass the event over to electron, but the piece I'm missing is where to actually do that passing. Does that belong in MainScreen.tsx or somewhere else?

  16. brunolemos commented on Jun 30, 2019

    @brunolemos
    MemberAuthor

    Hm you can do it directly inside the context provider for now, or create a new file (e.g. AppIconBadge.tsx) and include it at the MainScreen render (<AppIconBadge />). And then inside this file read the context value (that should return the number of unread items) and update the app icon accordingly.

  17. brunolemos commented on Jul 11, 2019

    @brunolemos
    MemberAuthor

    This is now available on v0.93.0! For web and desktop.

  18. brunolemos commented on Jul 11, 2019

    @brunolemos
    MemberAuthor

    To show an unread badge on mobile there are two possible ways:

    1. Run a script on app background every X minutes (has limitations: if app gets closed it will stop updating, minimum 15 minute interval to update, etc)
    2. Move this responsibility to the server (probably would not scale well, imagine the server having to do thousands of github API requests per minute)

    N2 would provide a better UX but not sure if it's feasible, github would block the server for spamming/ddos. Help wanted on N1 for now!

  19. added a commit that references this issue on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions