2017-11-04 18:32:18 +01:00
|
|
|
"use strict";
|
|
|
|
|
2019-11-16 18:24:03 +01:00
|
|
|
import socket from "../socket";
|
|
|
|
import upload from "../upload";
|
|
|
|
import store from "../store";
|
2017-11-04 18:32:18 +01:00
|
|
|
|
2019-11-05 13:30:45 +01:00
|
|
|
socket.once("configuration", function(data) {
|
2019-11-02 20:40:59 +01:00
|
|
|
store.commit("serverConfiguration", data);
|
2017-11-04 18:32:18 +01:00
|
|
|
|
2019-11-05 21:51:55 +01:00
|
|
|
// 'theme' setting depends on serverConfiguration.themes so
|
|
|
|
// settings cannot be applied before this point
|
|
|
|
store.dispatch("settings/applyAll");
|
2019-11-12 12:09:12 +01:00
|
|
|
socket.emit("setting:get");
|
2019-11-05 21:51:55 +01:00
|
|
|
|
2018-09-03 09:30:05 +02:00
|
|
|
if (data.fileUpload) {
|
2019-11-12 12:09:12 +01:00
|
|
|
upload.initialize();
|
2018-09-03 09:30:05 +02:00
|
|
|
}
|
|
|
|
|
2018-04-02 06:25:45 +02:00
|
|
|
// If localStorage contains a theme that does not exist on this server, switch
|
|
|
|
// back to its default theme.
|
2019-11-03 19:05:19 +01:00
|
|
|
const currentTheme = data.themes.find((t) => t.name === store.state.settings.theme);
|
2019-07-22 18:50:04 +02:00
|
|
|
|
|
|
|
if (currentTheme === undefined) {
|
2019-11-05 21:51:55 +01:00
|
|
|
store.commit("settings/update", {name: "theme", value: data.defaultTheme, sync: true});
|
2019-07-22 18:50:04 +02:00
|
|
|
} else if (currentTheme.themeColor) {
|
|
|
|
document.querySelector('meta[name="theme-color"]').content = currentTheme.themeColor;
|
2018-04-02 06:25:45 +02:00
|
|
|
}
|
|
|
|
|
2019-11-12 12:09:12 +01:00
|
|
|
if (document.body.classList.contains("public")) {
|
|
|
|
window.addEventListener(
|
|
|
|
"beforeunload",
|
|
|
|
() => "Are you sure you want to navigate away from this page?"
|
|
|
|
);
|
2018-06-19 17:00:07 +02:00
|
|
|
}
|
|
|
|
});
|