mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05: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
|
@ -4,6 +4,7 @@
|
|||
|
||||
### Bugfixes
|
||||
- Fix note titles with special characters producing invalid file names in user export zip file
|
||||
- Fix night-mode toggle not working when page is loaded with night-mode enabled
|
||||
|
||||
## <i class="fa fa-tag"></i> 1.9.6 <i class="fa fa-calendar-o"></i> 2022-11-06
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2,8 +2,7 @@ import modeType from './modeType'
|
|||
|
||||
const state = {
|
||||
syncscroll: true,
|
||||
currentMode: modeType.view,
|
||||
nightMode: false
|
||||
currentMode: modeType.view
|
||||
}
|
||||
|
||||
export default state
|
||||
|
|
Loading…
Reference in a new issue