diff --git a/client/components/App.vue b/client/components/App.vue index f2ac5c4d..56ebe3b5 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -58,7 +58,6 @@ export default { clearTimeout(this.dayChangeTimeout); }, methods: { - isPublic: () => document.body.classList.contains("public"), msUntilNextDay() { // Compute how many milliseconds are remaining until the next day starts const today = new Date(); diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js index e7265195..d4296257 100644 --- a/client/js/socket-events/init.js +++ b/client/js/socket-events/init.js @@ -6,7 +6,6 @@ const socket = require("../socket"); const webpush = require("../webpush"); const sidebar = $("#sidebar"); const storage = require("../localStorage"); -const utils = require("../utils"); const constants = require("../constants"); const {vueApp, initChannel} = require("../vue"); @@ -54,9 +53,14 @@ socket.on("init", function(data) { } vueApp.$nextTick(() => openCorrectChannel(previousActive, data.active)); - - utils.confirmExit(); vueApp.synchronizeNotifiedState(); + + if (document.body.classList.contains("public")) { + window.addEventListener( + "beforeunload", + () => "Are you sure you want to navigate away from this page?" + ); + } }); function openCorrectChannel(clientActive, serverActive) { diff --git a/client/js/utils.js b/client/js/utils.js index 9c95df89..dfcbd52d 100644 --- a/client/js/utils.js +++ b/client/js/utils.js @@ -9,7 +9,6 @@ var serverHash = -1; // eslint-disable-line no-var module.exports = { findCurrentNetworkChan, serverHash, - confirmExit, scrollIntoViewNicely, hasRoleInChannel, move, @@ -42,14 +41,6 @@ function scrollIntoViewNicely(el) { el.scrollIntoView({block: "center", inline: "nearest"}); } -function confirmExit() { - if ($(document.body).hasClass("public")) { - window.onbeforeunload = function() { - return "Are you sure you want to navigate away from this page?"; - }; - } -} - function move(array, old_index, new_index) { if (new_index >= array.length) { let k = new_index - array.length;