-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add last-notification-page-button
feature
#6133
Conversation
linkify-notification-page-numbers
featurelast-notification-page-button
feature
const lastCursor = Math.floor(lastNotificationPageNumber / 50) * 50; | ||
const nextButtonSearch = new URLSearchParams(nextButton.search); | ||
nextButtonSearch.set('after', btoa('cursor:' + String(lastCursor))); | ||
nextButton.search = nextButtonSearch.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the next button too. Please check my suggestions carefully, I wrote some specific code that isn't this. Let's not do 40-comments reviews again :(
nextButton.search = nextButtonSearch.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fail to see how that would not work. String(nextButtonSearch)
is exactly the same as nextButtonSearch.toString()
and the search is exactly what we need.
This line is definitely wrong in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand what you are saying. 👍 Never mind this did not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your original suggestion was to remove the nextButtonURL, which I did.
If I don't include this line then the URL will only be the search, https://github.com/after=Y3Vyc29yOjEwNTA%3D&query=is%3Adone
missing the notifications URL.
I feel bad we are going though so many comments.
If you feel that I am missing something, I have no issue with you closing and allowing someone else to pick this up. (No hard feelings I promise)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, the only misunderstanding here is that ?
is missing when using String()
whereas it exists in url.search
. We just need to prepend the question mark so that the attribute will be exactly "?after=Y3Vyc29yOjEwNTA%3D&query=is%3Adone"
, which is relative to the current pathname.
Possible ways, depending on which one TS likes the most
href={'?' + String(nextButtonSearch)}
href={`?${nextButtonSearch}`}
Co-authored-by: Federico Brigante <me@fregante.com>
Co-authored-by: Federico Brigante <me@fregante.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just remembered this is a dynamic page so I think you'll need to use observe
rather than a regular select
I think. The listener function should be at the top level (outside init
)
To trigger this, mark 10+ notifications as "Done" and wait for the page to update.
} | ||
|
||
const lastNotificationPageNode = select('.js-notifications-list-paginator-counts')!.lastChild!; | ||
assertNodeContent(lastNotificationPageNode, new RegExp(/^of \d+$/)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why new RegExp()
import {assertNodeContent} from '../helpers/dom-utils'; | ||
|
||
function init(): void | false { | ||
const nextButton = select('a[data-hotkey="ArrowRight"]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute is added by us
addHotkey(select(nextPageButtonSelectors), 'ArrowRight'); |
Closes #6126
Test URLs
https://github.com/notifications?query=is%3Adone
Screenshot