Skip to content

Commit

Permalink
Scope auto-update better
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed May 30, 2024
1 parent 5aeb2b9 commit 1e711f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import {
path,
port,
fs,
} from "../../../../utils/electron.js";

import {
onUpdateAvailable,
onUpdateProgress,
} from "../../../../utils/electron.js";
} from "../../../../utils/auto-update.js";

import saveSVG from "../../../../assets/icons/save.svg?raw";
import folderSVG from "../../../../assets/icons/folder_open.svg?raw";
Expand Down
25 changes: 25 additions & 0 deletions src/electron/frontend/utils/auto-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let updateAvailable = false;
const updateAvailableCallbacks = [];
export const onUpdateAvailable = (callback) => {
if (updateAvailable) callback(updateAvailable);
else updateAvailableCallbacks.push(callback);
};

let updateProgress = null;

const updateProgressCallbacks = [];
export const onUpdateProgress = (callback) => {
if (updateProgress) callback(updateProgress);
else updateProgressCallbacks.push(callback);
};

export const registerUpdateProgress = (info) => {
updateProgress = info;
updateProgressCallbacks.forEach((cb) => cb(info));
};

export const registerUpdate = (info) => {
updateAvailable = info;
document.body.setAttribute("data-update-available", JSON.stringify(info));
updateAvailableCallbacks.forEach((cb) => cb(info));
};

0 comments on commit 1e711f4

Please sign in to comment.