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

Chore: Setup viewer notifications in the correct location #563

Merged
merged 7 commits into from
Jan 9, 2018

Conversation

pramodsum
Copy link
Contributor

No description provided.

@boxcla
Copy link

boxcla commented Dec 22, 2017

Verified that @pramodsum has signed the CLA. Thanks for the pull request!

@@ -299,6 +310,10 @@ class PreviewUI {
* @return {void}
*/
showNotification(message, buttonText) {
if (!this.notification) {
this.setupNotification();
}
Copy link
Contributor

@tonyjin tonyjin Dec 27, 2017

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()

Copy link
Contributor

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.

Copy link
Contributor Author

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?

@@ -309,6 +324,10 @@ class PreviewUI {
* @return {void}
*/
hideNotification() {
if (!this.notification) {
this.setupNotification();
}
Copy link
Contributor

@tonyjin tonyjin Dec 27, 2017

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();
}

@@ -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);
}
Copy link
Contributor

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

Copy link
Contributor

@tonyjin tonyjin left a 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

@pramodsum pramodsum merged commit 2b37a36 into box:master Jan 9, 2018
pramodsum added a commit to pramodsum/box-content-preview that referenced this pull request Jan 11, 2018
pramodsum added a commit that referenced this pull request Jan 11, 2018
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.

4 participants