Feature/#19 notifications tab title #31

Merged
kaffem merged 25 commits from feature/#19-notifications-tab-title into develop 2020-10-28 06:46:24 +01:00
kaffem commented 2020-08-04 18:34:47 +02:00 (Migrated from github.com)
No description provided.
Serraniel (Migrated from github.com) requested changes 2020-08-05 11:49:30 +02:00
Serraniel (Migrated from github.com) left a comment

I think the code how to get the notification count can be improved a bit more regarding its stability in case the user is logged out or there are no notifications.

I think the code how to get the notification count can be improved a bit more regarding its stability in case the user is logged out or there are no notifications.
Serraniel (Migrated from github.com) commented 2020-08-05 11:46:20 +02:00

Is 3 the correct index here? I just executed this via console and it wasn´t working correctly I think:
image

There probably also has to be a check if user is logged in and if there even is a notification I think.
You may try getting it via regular expression:

menuDropdowns.querySelector('li a[href="notification"]')?.innerText?.match('\\d+')[0] ?? '' 
Is 3 the correct index here? I just executed this via console and it wasn´t working correctly I think: ![image](https://user-images.githubusercontent.com/8461282/89397194-d5d1d000-d70f-11ea-804b-f4ca40b9c65d.png) There probably also has to be a check if user is logged in and if there even is a notification I think. You may try getting it via regular expression: ```js menuDropdowns.querySelector('li a[href="notification"]')?.innerText?.match('\\d+')[0] ?? '' ```
Serraniel (Migrated from github.com) commented 2020-08-05 11:48:30 +02:00

We should also insert a space after the number (at least the code I put in the other comment is without space). Also only add the space if there are notifications to insert.

We should also insert a space after the number (at least the code I put in the other comment is without space). Also only add the space if there are notifications to insert.
kaffem (Migrated from github.com) reviewed 2020-08-05 15:54:38 +02:00
kaffem (Migrated from github.com) commented 2020-08-05 15:54:38 +02:00

Is 3 the correct index here? I just executed this via console and it wasn´t working correctly I think:
image
Yeah the 3 is the correct index here, your split is missing another space.
chrome_8SQg6ZZOCH

> > > Is 3 the correct index here? I just executed this via console and it wasn´t working correctly I think: > ![image](https://user-images.githubusercontent.com/8461282/89397194-d5d1d000-d70f-11ea-804b-f4ca40b9c65d.png) Yeah the 3 is the correct index here, your split is missing another space. ![chrome_8SQg6ZZOCH](https://user-images.githubusercontent.com/29717789/89420569-2eff2b00-d733-11ea-95e1-8735ac78c4eb.png)
kaffem (Migrated from github.com) reviewed 2020-08-05 15:57:54 +02:00
kaffem (Migrated from github.com) commented 2020-08-05 15:57:54 +02:00

Right now there is a space added after the number in line 16; however I'll take a look into retrieving the notificationCount via regex since its not always working on pathnames like /watch2gether

Right now there is a space added after the number in line 16; however I'll take a look into retrieving the notificationCount via regex since its not always working on pathnames like /watch2gether
kaffem (Migrated from github.com) reviewed 2020-08-20 17:52:01 +02:00
kaffem (Migrated from github.com) commented 2020-08-20 17:52:01 +02:00

There probably also has to be a check if user is logged in and if there even is a notification I think.

9fe2668c3a adds checks for logged in + notifications

> There probably also has to be a check if user is logged in and if there even is a notification I think. 9fe2668c3afec7a4b100cffc9ae722d1baa13fe7 adds checks for logged in + notifications
kaffem commented 2020-08-20 17:55:18 +02:00 (Migrated from github.com)

Console Error NoTiFiCaTiOnCoUnT uNdEfInEd! seems to happen because runAfterLoad is called while the menu isn't visible..

Console Error ``NoTiFiCaTiOnCoUnT uNdEfInEd!`` seems to happen because runAfterLoad is called while the menu isn't visible..
Serraniel commented 2020-08-21 16:23:55 +02:00 (Migrated from github.com)

I just merged #24 which changed the runAfterLoad. Maybe it behaves better now, if you update the branch but idk.

I just merged #24 which changed the `runAfterLoad`. Maybe it behaves better now, if you update the branch but idk.
kaffem commented 2020-09-10 18:19:36 +02:00 (Migrated from github.com)

I just merged #24 which changed the runAfterLoad. Maybe it behaves better now, if you update the branch but idk.

Yeah I merged the commits from #24 into the branch for #19. Works a little bit better from what I saw in testing. I'll take a look at the merge conflicts and remove the logging later.

> I just merged #24 which changed the `runAfterLoad`. Maybe it behaves better now, if you update the branch but idk. Yeah I merged the commits from #24 into the branch for #19. Works a little bit better from what I saw in testing. I'll take a look at the merge conflicts and remove the logging later.
Serraniel commented 2020-09-11 16:22:41 +02:00 (Migrated from github.com)

I just merged #24 which changed the runAfterLoad. Maybe it behaves better now, if you update the branch but idk.

Yeah I merged the commits from #24 into the branch for #19. Works a little bit better from what I saw in testing. I'll take a look at the merge conflicts and remove the logging later.

There still are conflicts. I think you used an older commit of develop to resolve them. I just will quickly do this also because of the build changes I did.

> > I just merged #24 which changed the `runAfterLoad`. Maybe it behaves better now, if you update the branch but idk. > > Yeah I merged the commits from #24 into the branch for #19. Works a little bit better from what I saw in testing. I'll take a look at the merge conflicts and remove the logging later. There still are conflicts. I think you used an older commit of *develop* to resolve them. I just will quickly do this also because of the build changes I did.
Serraniel commented 2020-09-11 18:03:09 +02:00 (Migrated from github.com)

I think this looks good now. You can merge if you don´t see anything bad in the changes I did.

I think this looks good now. You can merge if you don´t see anything bad in the changes I did.
Serraniel (Migrated from github.com) approved these changes 2020-09-11 18:03:32 +02:00
kaffem (Migrated from github.com) reviewed 2020-09-14 00:37:12 +02:00
kaffem (Migrated from github.com) left a comment

Considering the things mentioned, I'd suggest we either put this feature on hold until #42 gets resolved, or we use the old solution with the pathnameChange instead of the pushState event, or we use the new solution on /home and whenever the user opens his notifications (/notification) to update the NotificationCount. With this assigned to a variable we then just use the variable to insert the NotificationCount into the title on all the other pathnames.

Considering the things mentioned, I'd suggest we either put this feature on hold until #42 gets resolved, or we use the old solution with the pathnameChange instead of the pushState event, or we use the new solution on /home and whenever the user opens his notifications (/notification) to update the NotificationCount. With this assigned to a variable we then just use the variable to insert the NotificationCount into the title on all the other pathnames.
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
kaffem (Migrated from github.com) commented 2020-09-14 00:24:10 +02:00

Getting the NotificationCount on every pushState event increases the chance of it failing. With this solution it fails for every item of the Community and Anime dropdownmenus. With the old solution it failed when inserting the Count into the title for the stats, jobs, seasonal, airing, random, profile, watchlist and notifications. 10 vs 8 pathnames where it doesn't work.
Furthermore with this solution we run into problems on the profile pathname:
chrome_yyDTOAsutx
We are adding the NotificationCount to the old count whenever we switch from one tab under profile to another; this did not happen with the old solution.

This seems to be related to #42 tho, if you enable Low-end mobile and check the pathnames after visting /home first, you'll see the notification count appear for a while and then disappear once the site is fully shown. With the new solution its definitely because of #42; we are trying to access the menu while the page isn't fully loaded.

Getting the NotificationCount on every pushState event increases the chance of it failing. With this solution it fails for every item of the Community and Anime dropdownmenus. With the old solution it failed when inserting the Count into the title for the stats, jobs, seasonal, airing, random, profile, watchlist and notifications. 10 vs 8 pathnames where it doesn't work. Furthermore with this solution we run into problems on the profile pathname: ![chrome_yyDTOAsutx](https://user-images.githubusercontent.com/29717789/93030124-fe0ef180-f620-11ea-99b3-151a7ed6a99b.png) We are adding the NotificationCount to the old count whenever we switch from one tab under profile to another; this did not happen with the old solution. This seems to be related to #42 tho, if you enable Low-end mobile and check the pathnames after visting /home first, you'll see the notification count appear for a while and then disappear once the site is fully shown. With the new solution its definitely because of #42; we are trying to access the menu while the page isn't fully loaded.
kaffem (Migrated from github.com) commented 2020-09-14 00:29:53 +02:00

We should rename this, if we keep using the pushState event.

We should rename this, if we keep using the pushState event.
kaffem (Migrated from github.com) commented 2020-09-14 00:31:54 +02:00

I don't quite understand, why you moved this from helpers to core.

I don't quite understand, why you moved this from helpers to core.
Serraniel (Migrated from github.com) reviewed 2020-09-16 21:32:24 +02:00
Serraniel (Migrated from github.com) commented 2020-09-16 21:32:23 +02:00

What would you suggest? Maybe location change? I think each pushstate also always could be a location change maybe?

What would you suggest? Maybe location change? I think each pushstate also always could be a location change maybe?
Serraniel (Migrated from github.com) reviewed 2020-09-16 21:33:44 +02:00
Serraniel (Migrated from github.com) commented 2020-09-16 21:33:44 +02:00

The current helper file more was intended for JS helpers, not website helpers. But I agree that core already also is very mixed up between extension core and aniwatch core. This should be optimized in the feature I think.

The current helper file more was intended for JS helpers, not website helpers. But I agree that core already also is very mixed up between extension core and aniwatch core. This should be optimized in the feature I think.
Serraniel (Migrated from github.com) reviewed 2020-09-16 21:36:59 +02:00
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
Serraniel (Migrated from github.com) commented 2020-09-16 21:36:59 +02:00

Do you remember how exactly you produced that bug with the number written in the title multiple times? I haven´t seen that yet.

But something else I noticed was the fact, the title seems to be updated by aniwatch after the blue loading bar on the top disappears. This should be investigated as a new opportunity to decide when we update the title and also would fix the current issue, that we just guess a random number to wait until location change before we update the title, which doesn´t always works as the following gif shows:
2020-09-16_21-32-11-463

Do you remember how exactly you produced that bug with the number written in the title multiple times? I haven´t seen that yet. But something else I noticed was the fact, the title seems to be updated by aniwatch after the blue loading bar on the top disappears. This should be investigated as a new opportunity to decide when we update the title and also would fix the current issue, that we just guess a random number to wait until location change before we update the title, which doesn´t always works as the following gif shows: ![2020-09-16_21-32-11-463](https://user-images.githubusercontent.com/8461282/93383974-b7a9d480-f864-11ea-9ec9-8b560256357b.gif)
kaffem (Migrated from github.com) reviewed 2020-09-18 00:30:46 +02:00
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
kaffem (Migrated from github.com) commented 2020-09-18 00:30:46 +02:00

Yeah thats what I meant. Looks like we should not only wait for the popState but also for onload once their preloader is fixed, or wait for the loading bar to disappear(?)

Yeah thats what I meant. Looks like we should not only wait for the popState but also for onload once their preloader is fixed, or wait for the loading bar to disappear(?)
kaffem (Migrated from github.com) reviewed 2020-09-18 00:32:35 +02:00
kaffem (Migrated from github.com) commented 2020-09-18 00:32:34 +02:00
export function runAfterLocationChange(func, pattern = '.*') {

would be fine imo

```suggestion export function runAfterLocationChange(func, pattern = '.*') { ``` would be fine imo
Serraniel (Migrated from github.com) reviewed 2020-10-25 10:57:50 +01:00
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
Serraniel (Migrated from github.com) commented 2020-10-25 10:57:50 +01:00

I introduced another observer, which will execute after the blue loading bar in the top disappears. This error seems not to appear any more with that specific change.

I introduced another observer, which will execute after the blue loading bar in the top disappears. This error seems not to appear any more with that specific change.
Serraniel (Migrated from github.com) reviewed 2020-10-25 10:58:41 +01:00
Serraniel (Migrated from github.com) commented 2020-10-25 10:58:41 +01:00

Renamed this with commit a840f644b7

Renamed this with commit a840f644b723cb885232f4184698db2a27bc5f7d
Serraniel (Migrated from github.com) reviewed 2020-10-25 11:00:43 +01:00
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
Serraniel (Migrated from github.com) commented 2020-10-25 11:00:43 +01:00
  • There still is the problem, that some pages have a different loading method where the menu isn´t available directly in the DOM.
- [x] There still is the problem, that some pages have a different loading method where the menu isn´t available directly in the DOM.
Serraniel (Migrated from github.com) reviewed 2020-10-25 11:29:43 +01:00
@ -0,0 +7,4 @@
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
Serraniel (Migrated from github.com) commented 2020-10-25 11:29:42 +01:00

I was able to fix this. We started our scripts after the preloader disappeared. We now also wait for the document.readyState to be "complete" so we can ensure everything is loaded correctly, as the preloader disappears to early on some pages.

I was able to fix this. We started our scripts after the preloader disappeared. We now also wait for the `document.readyState` to be `"complete"` so we can ensure *everything* is loaded correctly, as the preloader disappears to early on some pages.
Serraniel (Migrated from github.com) approved these changes 2020-10-25 11:32:10 +01:00
Serraniel commented 2020-10-25 11:32:55 +01:00 (Migrated from github.com)

We can ignore the failing Travis builds for now, they are some kind of "global" issue in the project.

We can ignore the failing Travis builds for now, they are some kind of "global" issue in the project.
Serraniel commented 2020-10-25 11:33:13 +01:00 (Migrated from github.com)

@kaffem if there are no objections by you I think we could merge this now.

@kaffem if there are no objections by you I think we could merge this now.
Serraniel (Migrated from github.com) reviewed 2020-10-25 22:02:16 +01:00
Serraniel (Migrated from github.com) commented 2020-10-25 22:02:10 +01:00

This also fixes #42 .

This also fixes #42 .
kaffem (Migrated from github.com) reviewed 2020-10-28 01:02:48 +01:00
kaffem (Migrated from github.com) left a comment

Yes. That's it. Works good!

Yes. That's it. Works good!
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Serraniel/AniwatchPlus#31
No description provided.