Skip to content

Commit

Permalink
Bugfix and version update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShishKabab committed Jun 17, 2020
1 parent 2d133ab commit 3bea584
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
34 changes: 24 additions & 10 deletions HTTPKoaServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var itemServerStatus;
var itemStartServer;
var itemStopServer;
var itemServerStatus;
var guiInitialized = false;

const port = 11922;
let backupPath = "";
Expand Down Expand Up @@ -206,11 +207,31 @@ async function main() {

if (!backupPath) {
gui.Window.get().on("loaded", () => {
guiInitialized = true;
updateBackupLocation();
});
}
}

function updateMenuItems() {
if (!guiInitialized) {
return;
}

itemOpenBackup.enabled = !!backupPath;
if (server) {
itemStartServer.enabled = false;
itemStopServer.enabled = true;
itemServerStatus.label = "Server running";
itemServerStatus.icon = "./img/active.png";
} else {
itemStopServer.enabled = false;
itemStartServer.enabled = true;
itemServerStatus.label = "Server not running";
itemServerStatus.icon = "./img/inactive.png";
}
}

async function closeApp() {
stopServer();
closeTray();
Expand All @@ -235,12 +256,11 @@ async function loadBackupLocation() {
async function updateBackupLocation() {
await stopServer();
if (await loadBackupLocation()) {
itemOpenBackup.enabled = true;
await startServer();
} else {
itemOpenBackup.enabled = false;
await selectNewBackupFolder();
}
updateMenuItems();
}

async function closeFolderSelect() {
Expand Down Expand Up @@ -285,21 +305,15 @@ async function startServer() {
err ? reject(err) : resolve(server);
});
});
itemStartServer.enabled = false;
itemStopServer.enabled = true;
itemServerStatus.label = "Server running";
itemServerStatus.icon = "./img/active.png";
updateMenuItems();
}
}

async function stopServer() {
if (server) {
server.close();
server = undefined;
itemStopServer.enabled = false;
itemStartServer.enabled = true;
itemServerStatus.label = "Server not running";
itemServerStatus.icon = "./img/inactive.png";
updateMenuItems();
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"mkdirp": "^0.5.1"
},
"build": {
"nwVersion": "0.35.5",
"nwVersion": "0.46.2",
"targets": [
"zip"
]
Expand Down

0 comments on commit 3bea584

Please sign in to comment.