Skip to content

Force init for some features - #3968

Closed
Esemesek wants to merge 1 commit into
refined-github:mainfrom
Esemesek:force-ajax-reload
Closed

Esemesek wants to merge 1 commit into
refined-github:mainfrom
Esemesek:force-ajax-reload

Conversation

@Esemesek

Copy link
Copy Markdown
Contributor

Navigating to files doesn't reload the whole page. This causes some of the features to not initialize - a similar situation to Go back in the browser history.

Solution:

Added additional flag to force re-init on pjax:end, but it does the same thing as repeatOnBackButton. According to pjax docs this is something that we should do.

I added an additional flag for this one because the repeatOnBackButton name doesn't really fit in this case. I can merge those two with a better name if we agree that this solution is okay.

cc @fregante

Closes #3945

@yakov116

Copy link
Copy Markdown
Member

This will lead to duplicate buttons

@Esemesek

Copy link
Copy Markdown
Contributor Author

@yakov116 Well, I was testing it multiple times and it never gave me multiple buttons. Additionally, it seems that we already had this 'solution' in place for the download-folder-button feature.

Comment thread source/features/index.tsx

document.addEventListener('pjax:end', () => {
if (repeatOnBackButton || !select.exists('has-rgh')) {
if (repeatOnBackButton || !select.exists('has-rgh') || forceReinit) {

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.

As this line suggests, this is equivalent to repeatOnBackButton: true, just under a different name.

This issue is a little complex. Basically we have 2 solutions:

  • rework how the automatic deduplication mechanism work (hard)
  • rename repeatOnBackButton: true to iAlreadyHandleDeduplicationThankYouVeryMuch: true and handle deduplication via the usual :not(.rgh-etc) selector like we do for most features.

I think the latter is easier. This way we still keep has-rgh as a generic fallback but also have the opportunity to opt-out when it causes problems (like in this case)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is exactly what I was asking about. Figured out the root of the issue, but I wasn't exactly sure how we want to tackle it - I think that I'll work on this dedup mechanism, and create another PR for it then.

@Esemesek

Copy link
Copy Markdown
Contributor Author

Closing this PR - will open another with a better solution.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Copy button doesn't show (and other file-related features)

3 participants