Move confirmExit

This commit is contained in:
Pavel Djundik 2019-10-20 17:45:38 +03:00
parent b74cc4387a
commit f76ad57c63
3 changed files with 7 additions and 13 deletions

View File

@ -58,7 +58,6 @@ export default {
clearTimeout(this.dayChangeTimeout); clearTimeout(this.dayChangeTimeout);
}, },
methods: { methods: {
isPublic: () => document.body.classList.contains("public"),
msUntilNextDay() { msUntilNextDay() {
// Compute how many milliseconds are remaining until the next day starts // Compute how many milliseconds are remaining until the next day starts
const today = new Date(); const today = new Date();

View File

@ -6,7 +6,6 @@ const socket = require("../socket");
const webpush = require("../webpush"); const webpush = require("../webpush");
const sidebar = $("#sidebar"); const sidebar = $("#sidebar");
const storage = require("../localStorage"); const storage = require("../localStorage");
const utils = require("../utils");
const constants = require("../constants"); const constants = require("../constants");
const {vueApp, initChannel} = require("../vue"); const {vueApp, initChannel} = require("../vue");
@ -54,9 +53,14 @@ socket.on("init", function(data) {
} }
vueApp.$nextTick(() => openCorrectChannel(previousActive, data.active)); vueApp.$nextTick(() => openCorrectChannel(previousActive, data.active));
utils.confirmExit();
vueApp.synchronizeNotifiedState(); 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) { function openCorrectChannel(clientActive, serverActive) {

View File

@ -9,7 +9,6 @@ var serverHash = -1; // eslint-disable-line no-var
module.exports = { module.exports = {
findCurrentNetworkChan, findCurrentNetworkChan,
serverHash, serverHash,
confirmExit,
scrollIntoViewNicely, scrollIntoViewNicely,
hasRoleInChannel, hasRoleInChannel,
move, move,
@ -42,14 +41,6 @@ function scrollIntoViewNicely(el) {
el.scrollIntoView({block: "center", inline: "nearest"}); 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) { function move(array, old_index, new_index) {
if (new_index >= array.length) { if (new_index >= array.length) {
let k = new_index - array.length; let k = new_index - array.length;