Skip to content

Commit ea1d35e

Browse files
authored
Merge pull request #775 from SISheogorath/feature/nightMode
Persist nightmode so we can re-enable it on reload
2 parents fa4a841 + 32c578d commit ea1d35e

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

public/js/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import toMarkdown from 'to-markdown'
1616

1717
import { saveAs } from 'file-saver'
1818
import randomColor from 'randomcolor'
19+
import store from 'store'
1920

2021
import _ from 'lodash'
2122

@@ -431,11 +432,12 @@ $(document).ready(function () {
431432
clearMap()
432433
}
433434
checkEditorStyle()
435+
436+
/* cache dom references */
437+
var $body = $('body')
438+
434439
/* we need this only on touch devices */
435440
if (isTouchDevice) {
436-
/* cache dom references */
437-
var $body = $('body')
438-
439441
/* bind events */
440442
$(document)
441443
.on('focus', 'textarea, input', function () {
@@ -445,6 +447,12 @@ $(document).ready(function () {
445447
$body.removeClass('fixfixed')
446448
})
447449
}
450+
451+
// Re-enable nightmode
452+
if (store.get('nightMode') || Cookies.get('nightMode')) {
453+
$body.addClass('night')
454+
}
455+
448456
// showup
449457
$().showUp('.navbar', {
450458
upClass: 'navbar-hide',
@@ -1680,6 +1688,13 @@ function toggleNightMode () {
16801688
$body.addClass('night')
16811689
appState.nightMode = true
16821690
}
1691+
if (store.enabled) {
1692+
store.set('nightMode', !isActive)
1693+
} else {
1694+
Cookies.set('nightMode', !isActive, {
1695+
expires: 365
1696+
})
1697+
}
16831698
}
16841699
function emitPermission (_permission) {
16851700
if (_permission !== permission) {

0 commit comments

Comments
 (0)