Refactored notification logic to method

This commit is contained in:
Shay Nehmad 2019-09-09 17:36:00 +03:00
parent a51a6065b8
commit 53f31ddcc9
1 changed files with 14 additions and 12 deletions

View File

@ -212,12 +212,10 @@ class AppComponent extends AuthComponent {
}
showInfectionDoneNotification() {
if (this.state.completedSteps.infection_done) {
// No need to show the notification to redirect to the report if we're already in the report page
if (!window.location.href.includes("report")) {
if (this.shouldShowNotification()) {
const hostname = window.location.hostname;
const port = window.location.port;
let url = `https://${hostname}:${port}${reportZeroTrustRoute}`;
const url = `https://${hostname}:${port}${reportZeroTrustRoute}`;
Notifier.start(
"Monkey Island",
@ -226,6 +224,10 @@ class AppComponent extends AuthComponent {
notificationIcon);
}
}
shouldShowNotification() {
// No need to show the notification to redirect to the report if we're already in the report page
return (this.state.completedSteps.infection_done && !window.location.pathname.startsWith("/report"));
}
}