Skip to content

Commit

Permalink
make update url configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Sep 26, 2024
1 parent 977c571 commit cc2648b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 14 additions & 3 deletions public/app/toast.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
const fs = require('fs');
const path = require('path');
const { Notification } = require('electron');

const NOTIFICATION_TITLE = 'LedFx Client - by Blade';
const NOTIFICATION_BODY = 'Testing Notification from the Main process';

function getConfig() {
const configPath = path.join(path.dirname(__dirname), isDev ? '../' : '../../', 'frontend_config.json')
const configData = fs.readFileSync(configPath);
return JSON.parse(configData);
}

function showNotification(title = NOTIFICATION_TITLE, body = NOTIFICATION_BODY) {
const config = getConfig();
const updateUrl = config.updateUrl;

new Notification({
toastXml: `<toast>
<visual>
Expand All @@ -13,10 +24,10 @@ function showNotification(title = NOTIFICATION_TITLE, body = NOTIFICATION_BODY)
</binding>
</visual>
<actions>
<action content="Goto Release" activationType="protocol" arguments="https://github.com/YeonV/LedFx-Builds/releases/latest" />
<action content="Goto Release" activationType="protocol" arguments="${updateUrl}" />
</actions>
</toast>`,
}).show();
}).show();
}

module.exports = { showNotification };
module.exports = { showNotification };
3 changes: 3 additions & 0 deletions public/frontend_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"updateUrl": "https://api.github.com/repos/YeonV/LedFx-Builds/releases/latest"
}

0 comments on commit cc2648b

Please sign in to comment.