Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add last-notification-page-button feature - #6133

Merged
fregante merged 29 commits into
mainfrom
6126-way-to-go-to-last-page-for-notifications
Nov 6, 2022
Merged

fregante merged 29 commits into
mainfrom
6126-way-to-go-to-last-page-for-notifications

Conversation

@yakov116

@yakov116 yakov116 commented Nov 3, 2022

Copy link
Copy Markdown
Member

@yakov116 yakov116 linked an issue Nov 3, 2022 that may be closed by this pull request
Comment thread source/features/linkify-notification-page-numbers.tsx Outdated
Comment thread source/features/linkify-notification-page-numbers.tsx Outdated
Comment thread readme.md Outdated
Comment thread source/features/linkify-notification-page-numbers.tsx Outdated
@yakov116
yakov116 marked this pull request as draft November 3, 2022 20:01
@yakov116
yakov116 marked this pull request as ready for review November 3, 2022 20:39
@yakov116
yakov116 requested a review from fregante November 3, 2022 20:56
Comment thread source/features/last-notification-page-button.tsx Outdated
@yakov116 yakov116 changed the title Add linkify-notification-page-numbers feature Add last-notification-page-button feature Nov 4, 2022
Comment thread readme.md Outdated
Comment thread source/features/last-notification-page-button.tsx Outdated
Comment thread source/features/last-notification-page-button.tsx Outdated
Comment thread source/features/last-notification-page-button.tsx Outdated
const lastCursor = Math.floor(lastNotificationPageNumber / 50) * 50;
const nextButtonSearch = new URLSearchParams(nextButton.search);
nextButtonSearch.set('after', btoa('cursor:' + String(lastCursor)));
nextButton.search = nextButtonSearch.toString();

Copy link
Copy Markdown
Member

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 :(

Suggested change
nextButton.search = nextButtonSearch.toString();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fregante fregante Nov 4, 2022

Copy link
Copy Markdown
Member

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.

@yakov116 yakov116 Nov 4, 2022

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member Author

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)

Copy link
Copy Markdown
Member

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}`}

Comment thread source/features/last-notification-page-button.tsx Outdated
Comment thread source/features/last-notification-page-button.tsx
Comment thread source/features/last-notification-page-button.tsx Outdated
yakov116 and others added 2 commits November 4, 2022 07:33
@yakov116
yakov116 marked this pull request as draft November 4, 2022 11:39
@yakov116
yakov116 marked this pull request as ready for review November 6, 2022 03:56

@fregante fregante left a comment

Copy link
Copy Markdown
Member

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+$/));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why new RegExp()

Comment thread source/features/last-notification-page-button.tsx Outdated
import {assertNodeContent} from '../helpers/dom-utils';

function init(): void | false {
const nextButton = select('a[data-hotkey="ArrowRight"]');

Copy link
Copy Markdown
Member

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');

@fregante fregante self-assigned this Nov 6, 2022
@fregante
fregante enabled auto-merge (squash) November 6, 2022 06:36
@fregante
fregante merged commit 104f6e4 into main Nov 6, 2022
@fregante
fregante deleted the 6126-way-to-go-to-last-page-for-notifications branch November 6, 2022 06:39
@janpio

janpio commented Nov 6, 2022

Copy link
Copy Markdown
Contributor

Thank you so much for implementing this @yakov116 (and for the reviews @fregante).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Way to go to "Last page" for notifications

3 participants