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,21 +212,23 @@ class AppComponent extends AuthComponent {
} }
showInfectionDoneNotification() { showInfectionDoneNotification() {
if (this.state.completedSteps.infection_done) { if (this.shouldShowNotification()) {
// No need to show the notification to redirect to the report if we're already in the report page const hostname = window.location.hostname;
if (!window.location.href.includes("report")) { const port = window.location.port;
const hostname = window.location.hostname; const url = `https://${hostname}:${port}${reportZeroTrustRoute}`;
const port = window.location.port;
let url = `https://${hostname}:${port}${reportZeroTrustRoute}`;
Notifier.start( Notifier.start(
"Monkey Island", "Monkey Island",
"Infection is done! Click here to go to the report page.", "Infection is done! Click here to go to the report page.",
url, url,
notificationIcon); 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"));
}
} }
AppComponent.defaultProps = {}; AppComponent.defaultProps = {};