theme: big file reload fix

This commit is contained in:
bordun 2020-11-21 19:42:13 +01:00
parent 7316e85efb
commit 47d7e2c82d
2 changed files with 12 additions and 6 deletions

View file

@ -3,7 +3,7 @@
## 1.7.3
- bug fixes
- custom module: prevent reloading the module while the file is being written to
- custom module / theme: prevent reloading the module while the file is being written to
- widgets
- encoder: add `ticks` property back

View file

@ -23,6 +23,8 @@ class Theme {
this.themes = settings.read('theme') || []
this.files = []
if (!this.themes.length) return this
for (let theme of this.themes) {
if (theme.includes('.css') && fs.existsSync(theme)) {
@ -34,11 +36,15 @@ class Theme {
}
}
this.watcher = chokidar.watch(this.files).on('change', ()=>{
if (!ipc) ipc = require('./server').ipc
this.load()
ipc.send('reloadCss')
})
if (!this.files.length) {
this.watcher = chokidar.watch(this.files, {awaitWriteFinish: {stabilityThreshold: 200}}).on('change', ()=>{
if (!ipc) ipc = require('./server').ipc
this.load()
ipc.send('reloadCss')
})
}
this.load()