mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
fix(night-mode): migrate cookie solution to store only
Signed-off-by: Erik Michelson <michelson@uni-bremen.de> Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
9055214418
commit
057777f31f
3 changed files with 13 additions and 20 deletions
|
@ -658,8 +658,13 @@ $(document).ready(function () {
|
|||
})
|
||||
}
|
||||
|
||||
if (Cookies.get('nightMode') !== undefined) {
|
||||
store.set('nightMode', Cookies.get('nightMode') === 'true')
|
||||
Cookies.remove('nightMode')
|
||||
}
|
||||
|
||||
// Re-enable nightmode
|
||||
if (store.get('nightMode') || Cookies.get('nightMode')) {
|
||||
if (store.get('nightMode') === true) {
|
||||
$body.addClass('night')
|
||||
ui.toolbar.night.addClass('active')
|
||||
}
|
||||
|
@ -2084,24 +2089,12 @@ $('.ui-delete-modal-confirm').click(function () {
|
|||
|
||||
function toggleNightMode () {
|
||||
const $body = $('body')
|
||||
const isActive = ui.toolbar.night.hasClass('active')
|
||||
if (isActive) {
|
||||
$body.removeClass('night')
|
||||
appState.nightMode = false
|
||||
} else {
|
||||
$body.addClass('night')
|
||||
appState.nightMode = true
|
||||
}
|
||||
if (store.enabled) {
|
||||
store.set('nightMode', !isActive)
|
||||
} else {
|
||||
Cookies.set('nightMode', !isActive, {
|
||||
expires: 365,
|
||||
sameSite: window.cookiePolicy,
|
||||
secure: window.location.protocol === 'https:'
|
||||
})
|
||||
}
|
||||
const isActive = store.get('nightMode') === true
|
||||
$body.toggleClass('night', !isActive)
|
||||
ui.toolbar.night.toggleClass('active', !isActive)
|
||||
store.set('nightMode', !isActive)
|
||||
}
|
||||
|
||||
function emitPermission (_permission) {
|
||||
if (_permission !== permission) {
|
||||
socket.emit('permission', _permission)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue