advanced-github-notifier icon indicating copy to clipboard operation
advanced-github-notifier copied to clipboard

Count is always off

Open bjeanes opened this issue 3 years ago • 8 comments

Notification badge often says there are no notifications when there are, but even when it does show that there is a new notification, the count is completely off:

image

Is anybody else experiencing this?

bjeanes avatar Aug 07 '20 22:08 bjeanes

I can't say I've experienced this. My suspicions would be the following:

  • You have a different GitHub account connected to the extension
  • Somehow the extension is a wrongly cached answer from the github API that has a different payload than what the site gets
  • Based on the times of those notifications I'd rule out de-sync between the extension state and github - which should correct itself about every minute

freaktechnik avatar Aug 11 '20 00:08 freaktechnik

You can see how off it is here:

image

12 notifications, most unread, extension reports 3

  • You have a different GitHub account connected to the extension

Nope, only 1 account. Furthermore, this is a new installation on a brand new OS installation (Linux, but I can't imagine that matters)

  • Somehow the extension is a wrongly cached answer from the github API that has a different payload than what the site gets

Let me know if there's a way I can debug this.

  • Based on the times of those notifications I'd rule out de-sync between the extension state and github - which should correct itself about every minute

Yeah I haven't seen the count vary at all, other than it goint from 3->2 when I opened this issue (which is one of the 3 it "sees". Unfortunately my screenshot utility doesn't seem to be able to capture the dropdown (it closes as soon as FF blurs) but there is a specific list of issues/PRs it thinks are unread/new.

I can't determine what it is. It's not the "subscribed"/"author"/"commented" reason, as the two other notifications are a dependabot PR and a new Release object from the GH Actions triggered by that dependabot PR.

I'd love to sort this out as I've been missing some notifications :. Let me know if/how I can help.

bjeanes avatar Aug 11 '20 01:08 bjeanes

You can look at the payloads of the github API the extension is getting by going to about:debugging, enabling local extension debugging and then inspecting the extension. This will open a tab with the web dev tools, where under network you'll find requests made by the extension since starting the extension inspection.

It is also possible that you may see clues in the console, which is what it defaults to, however the console will usually also contain a lot of false positive information from other extensions and Firefox itself.

freaktechnik avatar Aug 11 '20 01:08 freaktechnik

Haha well that was a journey. I figured it out by way of installing a different GH notification add-on and realising something while creating a new token:

image

You need repo permission for notifications in private repositories to be shown. My count is off because it was public repos only :man_facepalming:.

However, I have now added and removed a bunch of times and it does not appear to work when the add-on requests the token automatically (regardless of which option I choose):

image

It only works if I add an account with a manually created Personal Access Token. Using the same token as the other add-on:

image

If I remove that account and choose option 1 again (and disable and re-enable add-on for good measure), the count returns to 3, even though I can confirm that the token request is asking for repo permissions:

image

I guess I'll just use a PAT for now...?

bjeanes avatar Aug 11 '20 02:08 bjeanes

Removing authorised application from my account forced the notifier to go through a full authorisation request again (OAuth2 web flow), which again confirmed it was requesting private access. It still only shows 3.

Perhaps it needs both repo and notification scopes, not just repo?

bjeanes avatar Aug 11 '20 02:08 bjeanes

All Notification API calls require the notifications or repo API scopes. Doing this will give read-only access to some issue and commit content. You will still need the repo scope to access issues and commits from their respective endpoints.

https://docs.github.com/en/rest/reference/activity#list-notifications-for-the-authenticated-user

So if that's the case, the documentation is wrong. Officially the repo scope includes notifications. Also, I guess I should maybe look into forcing auth when you add an account- I thought I had that flag set, but apparently not.

freaktechnik avatar Aug 11 '20 08:08 freaktechnik

I wonder though if the handling of private repos for notifications somehow fails within the extension. I've had to correct that in the past and personally don't really have private repos that would get notifications. Notably it would probably be this function that fails: https://github.com/freaktechnik/advanced-github-notifier/blob/master/scripts/github.js#L309 or more accurately if then the fallback also fails: https://github.com/freaktechnik/advanced-github-notifier/blob/master/scripts/handler.js#L307 the notification is essentially ignored (see return null).

freaktechnik avatar Aug 11 '20 08:08 freaktechnik

No, I checked the actual response. GitHub is only returning a subset of my notifications (corresponding to the number the add-on displays on its icon). I don't think there is a logic error in the handling of the notifications at all.

bjeanes avatar Aug 11 '20 12:08 bjeanes