Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
JovannMC committed Aug 14, 2024
1 parent 5930886 commit 83de820
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,15 @@ function clearTrackers() {
const createWindow = async () => {
try {
await fs.promises.access(configPath);

// Read and parse the config file
const data = await fs.promises.readFile(configPath, "utf8");

// Check if the config file is empty (contains only "{}")
if (data.trim() === "{}") throw new Error;

const config: { [key: string]: any } = JSON.parse(data);

// Set configuration variables
canLogToFile = config.global?.debug?.canLogToFile ?? false;
wirelessTrackerEnabled = config.global?.trackers?.wirelessTrackerEnabled ?? false;
Expand All @@ -300,7 +304,7 @@ const createWindow = async () => {
heartbeatInterval = config.global?.trackers?.heartbeatInterval ?? 2000;
loggingMode = config.global?.debug?.loggingMode ?? 1;
} catch (err) {
// If the config file doesn't exist, create it
// If the config file doesn't exist or is empty, create it
log("First launch, creating config file and showing onboarding screen (after load)");
await fs.promises.writeFile(configPath, "{}");
firstLaunch = true;
Expand Down Expand Up @@ -737,6 +741,13 @@ ipcMain.on("stop-connection", () => {
stopConnectionIfActive("com");

clearTrackers();

// Clear all timeouts
for (const key in trackerTimeouts) {
if (trackerTimeouts.hasOwnProperty(key)) {
clearTimeout(trackerTimeouts[key]);
}
}

connectionActive = false;
});
Expand Down
1 change: 1 addition & 0 deletions src/static/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ function addEventListeners() {
refreshingDeviceList = true;

document.getElementById("device-list").textContent = "";
document.getElementById("tracker-count").textContent = "0";
deviceQueue.length = 0;

const devices = document.querySelectorAll(".card");
Expand Down

0 comments on commit 83de820

Please sign in to comment.