FIX: sync reviewable count when opening the hamburger menu (PR #10368)

When a tab is open but left unattended for a while, the red, green, and blue pills tend to go out of sync.

So whevener we open the notifications menu, we sync up the notification count (eg. blue and green pills) with the server.

However, the reviewable count (eg. the red pill) is not a notification and is located in the hamburger menu. This commit adds a new route on the server side to retrieve the reviewable count for the current user and a ping (refreshReviewableCount) from the client side to sync the reviewable count whenever they open the hamburger menu.

REFACTOR: I also refactored the hamburger-menu widget code to prevent repetitive uses of “this.”.

PERF: I improved the performance of the ‘notify_reviewable’ job by doing only 1 query to the database to retrieve all the pending reviewables and then tallying based on the various rights.


This is the interested part.

Not sure I like calling this from inside the widget, but I don’t see how else I can refresh the counts whenever the hamburger menu is open. Plus, we use a similar “workflow” for notifications.

It is not amazing but probably OK based on our current structure and we can live with it.

1 Like

I think it’s good practice to always return promise when we have one

1 Like