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

Fix 2 codefactor warnings and remove whitespaces at end of lines of app.js #842

Merged
merged 2 commits into from
Feb 19, 2022

Conversation

mossroy
Copy link
Contributor

@mossroy mossroy commented Feb 19, 2022

Removed unused variable messageChannel, and a weird character in a comment

@mossroy mossroy changed the title Fix codefactor warnings and remove whitespaces at end of lines Fix 2 codefactor warnings and remove whitespaces at end of lines Feb 19, 2022
@mossroy mossroy changed the title Fix 2 codefactor warnings and remove whitespaces at end of lines Fix 2 codefactor warnings and remove whitespaces at end of lines of app.js Feb 19, 2022
@mossroy mossroy requested a review from Jaifroid February 19, 2022 17:26
Copy link
Member

@Jaifroid Jaifroid left a comment

Choose a reason for hiding this comment

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

Thanks for this cleanup! All looks good to me. I didn't test the effect of removing the messageChannel / tmpMessageChannel, but I had noticed previously that messageChannel was marked by my editor as being unused, so it's good to remove that anomaly.

@@ -677,7 +677,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
// If this is the first time we are initiating the SW, allow Promises to complete by delaying potential reload till next tick
delay = 0;
}
messageChannel = tmpMessageChannel;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand why this has been removed. Is it because we don't actually need to store this message channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, the global variable messageChannel was defined, assigned here, but never used.
I suppose we were keeping a single messageChannel instance at some point in the past, and afterwards we changed our mind.
So I removed the variable declaration, and assignment here.

Copy link
Member

Choose a reason for hiding this comment

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

OK. At some point (not now) it might be good to check whether the implementation still needs the Service Worker to be kept alive. The Service Worker spec is specifically designed to put the SW to sleep when not being used, and it should fire up again immediately it is invoked again. It's possible, in fact, that an older implementation tried to keep the messageChannel alive (hence we have a global messageChannel assignment here), which should not be necessary. Each use of the SW can define a new messageChannel. I'm only speculating here, nothing tested!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubt we could simply remove this keepalive implementation.
The SW can be removed and re-created by the browser, by design from the beginning.
The problem is that, when it's re-created, it does not have the messageChannel variable to ask app.js for the content. We send this messageChannel through the "init" message.

When I faced this issue in #145, I did not find a better solution.
But I'd be very glad to have a better one.

Copy link
Member

Choose a reason for hiding this comment

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

OK, we can investigate another time. Fine to merge this if you've done some testing on SW mode.

@mossroy mossroy merged commit c798936 into master Feb 19, 2022
@mossroy mossroy deleted the remove-eol-whitespaces-and-fix-codefactor-warnings branch February 19, 2022 18:23
@Jaifroid
Copy link
Member

Sorry, commented too late!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants