better handling of file watchers

feature/settings-window
Michael Ochmann 3 years ago
parent 5d943b1240
commit 43d1ef1e33
  1. 15
      src/Ation.js

@ -28,7 +28,7 @@ class Ation {
app.whenReady().then(async () => {
if (this.fileToOpen)
this.openFile(this.fileToOpen, true);
this.openFile(this.fileToOpen);
protocol.registerFileProtocol("slideimg", (request, callback) => {
const uri = request.url.replace(/^slideimg:\/\//, "");
const extension = path.extname(uri).replace(/^\./, "");
@ -66,12 +66,17 @@ class Ation {
if (!change)
this.currentFile = filePath;
this.watcher = fsn.watch(filePath, () => {
this.openFile(this.currentFile, true);
if (this.watcher)
this.watcher.close();
this.watcher = fsn.watch(filePath, (eventType, path) => {
if (path.match(/~$/)) // handling unix swap files here
setTimeout(() => this.openFile(this.currentFile, true), 1000);
else
this.openFile(this.currentFile, true);
});
this.windowManager.mainWindow.send("Ation::openFile", [basePath, data]);
} catch {
} catch (error) {
console.log(error);
return;
}
}

Loading…
Cancel
Save