Ensure snnowflake was initialized in unload handlers

This commit is contained in:
Arlo Breault 2019-07-10 10:52:51 +02:00
parent 99952ca7de
commit 3455cd5da8
2 changed files with 12 additions and 4 deletions

View file

@ -61,14 +61,18 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
// Notification of closing tab with active proxy.
window.onbeforeunload = function() {
if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) {
if (
!silenceNotifications &&
snowflake !== null &&
Snowflake.MODE.WEBRTC_READY === snowflake.state
) {
return Snowflake.MESSAGE.CONFIRMATION;
}
return null;
};
window.onunload = function() {
snowflake.disable();
if (snowflake !== null) { snowflake.disable(); }
return null;
};