-
Notifications
You must be signed in to change notification settings - Fork 116
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
Chore: Setup viewer notifications in the correct location #563
Conversation
Verified that @pramodsum has signed the CLA. Thanks for the pull request! |
src/lib/PreviewUI.js
Outdated
@@ -299,6 +310,10 @@ class PreviewUI { | |||
* @return {void} | |||
*/ | |||
showNotification(message, buttonText) { | |||
if (!this.notification) { | |||
this.setupNotification(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea moving it here! One thought - you have a null check inside setupNotification
. Is there a situation where contentContainer doesn't exist and then someone calls showNotification
? This would fall into the first if block here but then fail on this.notifciation.show()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easiest fix would be:
if (!this.notification) {
this.setupNotification();
}
if (this.notification) {
this.showNotification();
}
But, I'm not a huge fan of how that reads... Open to other suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned it up a bit. Thoughts?
src/lib/PreviewUI.js
Outdated
@@ -309,6 +324,10 @@ class PreviewUI { | |||
* @return {void} | |||
*/ | |||
hideNotification() { | |||
if (!this.notification) { | |||
this.setupNotification(); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to setup notification here since it's only a prerequisite to showing a notification.
Something like this should work:
if (this.notification) {
this.notification.hide();
}
src/lib/PreviewUI.js
Outdated
@@ -264,9 +264,6 @@ class PreviewUI { | |||
// part of finishLoadingSetup in BaseViewer.js | |||
crawler.classList.remove(CLASS_HIDDEN); | |||
} | |||
|
|||
// Setup viewer notification | |||
this.notification = new Notification(this.contentContainer); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're in this file already, I'd move this check to be:
if (!this.contentContainer) {
return;
}
to reduce arrow-ness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm - please double check this patch doesn't re-introduce the original issue in #273
No description provided.