Refined-github: Fix "Undo close tab" strangeness

Created on 27 Sep 2019  路  9Comments  路  Source: sindresorhus/refined-github

If you open an issue in Firefox, then for example change the labels, close the tab with Ctrl + W then undo closing the tab with Ctrl + Shift + T it will load the issues as it was _before_ you changed the labels. This is super confusing if this is a typical workflow for you (as is it for me when triaging hundreds of issues).

It would be super impressive if Refined Github could somehow fix this problem somehow.

enhancement help wanted

Most helpful comment

Boom:

const marker = document.querySelector('.js-timeline-marker');
marker.dispatchEvent(new CustomEvent("socket:message", {
    bubbles: true,
    detail: {data: {gid: marker.dataset.gid}}
}))

All 9 comments

I think this is because Firefox doesn't restore the DOM but just reloads the HTML from cache, which doesn't have the latest changes.

I don't think this is fixable other than by reloading the whole page, which is not great.

Interesting. The underlying problem is the way Github updates its DOM then?

The problem also exists in Chrome, if you close the tab quickly enough after e.g. adding or removing a label - when reopening the tab the previous state is shown.

In theory an extension (I am not saying this should be in Refined GitHub, just that this could theoretically be solved via an extension) by tracking if you make any changes to an issue, so that when you close and re-open a tab it could automatically reload in these cases, correct?

Not really. Even if we save the DOM/HTML, we can't guarantee that events still work correctly if we inject it. I think Chrome preserves the whole application state in memory, we can't do that from an extension.

Oh sorry, I was unclear. I meant:
The extension takes care of tracking changes to a discussion, then if a tab is reopened (Ctrl + Shift + T) and it detects the "this is probably showing outdated information now" situation it reloads the page manually instead of letting the browser show an outdated version of it.

if a tab is reopened

I don't think we can detect that without adding tabs permission, which we can't.

I think you'll just have to press Ctrl + Shift + T Ctrl + R 馃槃

... or I can add another side project to my plate that I might get to one day: https://github.com/janpio/github-fix-reopened-tabs ;)

Thanks for the conversation here.

This may be possible after all. I noticed that an outdated page is updated by GitHub when the issue/PR is updated.

Example:

  1. Have outdated tab
  2. In another tab, leave a comment
  3. The outdated tab is updated to the latest version.

Perhaps this behavior can be triggered locally, rather than by the server.

The tricky thing would be to reliably detect the need for this and avoid heavy requests.

Boom:

const marker = document.querySelector('.js-timeline-marker');
marker.dispatchEvent(new CustomEvent("socket:message", {
    bubbles: true,
    detail: {data: {gid: marker.dataset.gid}}
}))

This would improve my life so much <3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

durka picture durka  路  3Comments

shivapoudel picture shivapoudel  路  3Comments

vanniktech picture vanniktech  路  3Comments

sompylasar picture sompylasar  路  3Comments

yakov116 picture yakov116  路  3Comments