mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
Make sense out of settings sync and force sync
This commit is contained in:
parent
85907f54ba
commit
21bbe7d4c3
6 changed files with 71 additions and 21 deletions
|
@ -66,20 +66,28 @@
|
||||||
/>
|
/>
|
||||||
Synchronize settings with other clients
|
Synchronize settings with other clients
|
||||||
</label>
|
</label>
|
||||||
<p v-if="!$store.state.settings.syncSettings" class="sync-warning-override">
|
<template v-if="!$store.state.settings.syncSettings">
|
||||||
<strong>Warning</strong> Checking this box will override the settings of
|
<div v-if="$store.state.serverHasSettings" class="settings-sync-panel">
|
||||||
this client with those stored on the server.
|
<p>
|
||||||
</p>
|
<strong>Warning:</strong> Checking this box will override the
|
||||||
<p v-if="!$store.state.settings.syncSettings" class="sync-warning-base">
|
settings of this client with those stored on the server.
|
||||||
<strong>Warning</strong> No settings have been synced before. Enabling this
|
</p>
|
||||||
will sync all settings of this client as the base for other clients.
|
<p>
|
||||||
</p>
|
Use the button below to enable synchronization, and override any
|
||||||
<div v-if="$store.state.settings.syncSettings" class="opt force-sync-button">
|
settings already synced to the server.
|
||||||
<button type="button" class="btn" @click="onForceSyncClick">
|
</p>
|
||||||
Force sync settings
|
<button type="button" class="btn btn-small" @click="onForceSyncClick">
|
||||||
</button>
|
Sync settings and enable
|
||||||
<p>This will override any settings already synced to the server.</p>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="settings-sync-panel">
|
||||||
|
<p>
|
||||||
|
<strong>Warning:</strong> No settings have been synced before.
|
||||||
|
Enabling this will sync all settings of this client as the base for
|
||||||
|
other clients.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
@ -553,6 +561,11 @@ export default {
|
||||||
},
|
},
|
||||||
onForceSyncClick() {
|
onForceSyncClick() {
|
||||||
this.$store.dispatch("settings/syncAll", true);
|
this.$store.dispatch("settings/syncAll", true);
|
||||||
|
this.$store.dispatch("settings/update", {
|
||||||
|
name: "syncSettings",
|
||||||
|
value: true,
|
||||||
|
sync: true,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
registerProtocol() {
|
registerProtocol() {
|
||||||
const uri = document.location.origin + document.location.pathname + "?uri=%s";
|
const uri = document.location.origin + document.location.pathname + "?uri=%s";
|
||||||
|
|
|
@ -1760,8 +1760,33 @@ part/quit messages where we don't load previews (adds a blank line otherwise) */
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#settings .sync-warning-base {
|
#settings .settings-sync-panel {
|
||||||
display: none;
|
padding: 10px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: #d9edf7;
|
||||||
|
color: #31708f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings .settings-sync-panel p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings .settings-sync-panel .btn {
|
||||||
|
color: #007bff;
|
||||||
|
border-color: #007bff;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings .settings-sync-panel .btn:hover,
|
||||||
|
#settings .settings-sync-panel .btn:focus {
|
||||||
|
background-color: #007bff;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings .settings-sync-panel .btn:active,
|
||||||
|
#settings .settings-sync-panel .btn:focus {
|
||||||
|
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#settings .opt {
|
#settings .opt {
|
||||||
|
|
|
@ -11,7 +11,9 @@ export const config = normalizeConfig({
|
||||||
default: true,
|
default: true,
|
||||||
sync: "never",
|
sync: "never",
|
||||||
apply(store, value) {
|
apply(store, value) {
|
||||||
value && socket.emit("setting:get");
|
if (value) {
|
||||||
|
socket.emit("setting:get");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
advanced: {
|
advanced: {
|
||||||
|
|
|
@ -10,11 +10,15 @@ socket.on("setting:new", function(data) {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("setting:all", function(settings) {
|
socket.on("setting:all", function(settings) {
|
||||||
if (Object.keys(settings).length === 0) {
|
const serverHasSettings = Object.keys(settings).length > 0;
|
||||||
store.dispatch("settings/syncAll");
|
|
||||||
} else {
|
store.commit("serverHasSettings", serverHasSettings);
|
||||||
|
|
||||||
|
if (serverHasSettings) {
|
||||||
for (const name in settings) {
|
for (const name in settings) {
|
||||||
store.dispatch("settings/update", {name, value: settings[name], sync: false});
|
store.dispatch("settings/update", {name, value: settings[name], sync: false});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
store.dispatch("settings/syncAll");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,12 @@ export function createSettingsStore(store) {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
syncAll({state}, force = false) {
|
syncAll({state}, force = false) {
|
||||||
if (state.syncSettings === false || force === false) {
|
if (state.syncSettings === false && force === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
store.commit("serverHasSettings", true);
|
||||||
|
|
||||||
for (const name in state) {
|
for (const name in state) {
|
||||||
if (config[name].sync !== "never" || config[name].sync === "always") {
|
if (config[name].sync !== "never" || config[name].sync === "always") {
|
||||||
socket.emit("setting:set", {name, value: state[name]});
|
socket.emit("setting:set", {name, value: state[name]});
|
||||||
|
|
|
@ -36,6 +36,7 @@ const store = new Vuex.Store({
|
||||||
versionData: null,
|
versionData: null,
|
||||||
versionStatus: "loading",
|
versionStatus: "loading",
|
||||||
versionDataExpired: false,
|
versionDataExpired: false,
|
||||||
|
serverHasSettings: false,
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
appLoaded(state) {
|
appLoaded(state) {
|
||||||
|
@ -104,6 +105,9 @@ const store = new Vuex.Store({
|
||||||
versionDataExpired(state, payload) {
|
versionDataExpired(state, payload) {
|
||||||
state.versionDataExpired = payload;
|
state.versionDataExpired = payload;
|
||||||
},
|
},
|
||||||
|
serverHasSettings(state, value) {
|
||||||
|
state.serverHasSettings = value;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
currentSession: (state) => state.sessions.find((item) => item.current),
|
currentSession: (state) => state.sessions.find((item) => item.current),
|
||||||
|
|
Loading…
Reference in a new issue