Skip to content
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

Merged
merged 29 commits into from
Nov 6, 2022

Conversation

yakov116
Copy link
Member

@yakov116 yakov116 commented Nov 3, 2022

@yakov116 yakov116 linked an issue Nov 3, 2022 that may be closed by this pull request
source/features/linkify-notification-page-numbers.tsx Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@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 changed the title Add linkify-notification-page-numbers feature Add last-notification-page-button feature Nov 4, 2022
readme.md Outdated Show resolved Hide resolved
source/features/last-notification-page-button.tsx Outdated Show resolved Hide resolved
source/features/last-notification-page-button.tsx Outdated Show resolved Hide resolved
source/features/last-notification-page-button.tsx Outdated Show resolved Hide resolved
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
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
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@fregante fregante Nov 4, 2022

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.

Copy link
Member Author

@yakov116 yakov116 Nov 4, 2022

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

source/features/last-notification-page-button.tsx Outdated Show resolved Hide resolved
yakov116 and others added 2 commits November 4, 2022 07:33
Co-authored-by: Federico Brigante <me@fregante.com>
@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
Copy link
Member

@fregante fregante left a 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+$/));
Copy link
Member

Choose a reason for hiding this comment

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

Why new RegExp()

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

function init(): void | false {
const nextButton = select('a[data-hotkey="ArrowRight"]');
Copy link
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
Copy link
Contributor

janpio commented Nov 6, 2022

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