Skip to content

Commit bf2069e

Browse files
committed
Update UI for download options and version increment to 1.1.9
1 parent f688c78 commit bf2069e

File tree

5 files changed

+23
-35
lines changed

5 files changed

+23
-35
lines changed

index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ <h2 class="header-h2">Notes</h2>
4343
<div id="notification" class="hidden">
4444
<p id="message"></p>
4545
<div id="notification-buttons">
46-
<a id="download-link" href="#" target="_blank">Download</a>
47-
<button id="dismiss-button">Dismiss</button>
46+
<select id="file-select" class="dropdown"></select>
47+
<a id="download-link" href="#" class="button">Download</a>
48+
<button id="dismiss-button" class="button">Dismiss</button>
4849
</div>
4950
</div>
5051
<div id="exportModal" class="modal">

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ let tray = null;
77

88
app.on('ready', () => {
99
mainWindow = new MicaBrowserWindow({
10-
width: 1000,
11-
height: 600,
10+
width: 1200,
11+
height: 700,
1212
webPreferences: {
1313
contextIsolation: true,
1414
nodeIntegration: false,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iotas-notepad",
3-
"version": "1.1.8",
3+
"version": "1.1.9",
44
"main": "index.js",
55
"scripts": {
66
"electron": "electron .",

preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ contextBridge.exposeInMainWorld('API', {
1010
node: () => process.versions.node,
1111
chrome: () => process.versions.chrome,
1212
electron: () => process.versions.electron,
13-
iotanotepad: () => "1.1.8"
13+
iotanotepad: () => "1.1.9"
1414
},
1515
});

src/script.js

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ document.getElementById('open-dev-tools').addEventListener('click', () => {
147147

148148
document.addEventListener("DOMContentLoaded", () => {
149149
loadNotes();
150-
displayReleases();
150+
checkForUpdates();
151151
loadSettings();
152152
applyThemeFlavor(); // Apply the saved theme flavor on startup
153153
updateThemeDropdown();
@@ -187,30 +187,6 @@ function isNewerVersion(currentVersion, latestVersion) {
187187
return false;
188188
}
189189

190-
async function displayReleases() {
191-
const releases = await fetchReleases();
192-
const latestRelease = releases[0]; // Get the latest release
193-
194-
if (latestRelease && isNewerVersion(version, latestRelease.tag_name)) {
195-
// Show notification
196-
const notification = document.getElementById("notification");
197-
const message = document.getElementById("message");
198-
const downloadLink = document.getElementById("download-link");
199-
message.innerText = `New version ${latestRelease.tag_name} is available!`;
200-
window.API.sendNotification('Update Available', 'A new version of the app is available.');
201-
downloadLink.href = latestRelease.assets[0].browser_download_url; // Assuming the first asset is the setup file
202-
downloadLink.innerText = "Download";
203-
downloadLink.onclick = (e) => {
204-
e.preventDefault();
205-
const downloadUrl = latestRelease.assets[0].browser_download_url;
206-
const fileName = latestRelease.assets[0].name;
207-
notification.classList.add("hidden");
208-
downloadFile(downloadUrl, fileName);
209-
};
210-
notification.classList.remove("hidden");
211-
}
212-
}
213-
214190
window.API.on('check-for-updates', () => {
215191
console.log("Received check-for-updates event");
216192
checkForUpdates();
@@ -225,17 +201,28 @@ async function checkForUpdates() {
225201
const notification = document.getElementById("notification");
226202
const message = document.getElementById("message");
227203
const downloadLink = document.getElementById("download-link");
204+
const fileSelect = document.getElementById("file-select");
205+
228206
message.innerText = `New version ${latestRelease.tag_name} is available!`;
229207
window.API.sendNotification('Update Available', 'A new version of the app is available.');
230-
downloadLink.href = latestRelease.assets[0].browser_download_url; // Assuming the first asset is the setup file
231-
downloadLink.innerText = "Download";
208+
209+
// Populate the dropdown menu with available assets
210+
fileSelect.innerHTML = '';
211+
latestRelease.assets.forEach(asset => {
212+
const option = document.createElement('option');
213+
option.value = asset.browser_download_url;
214+
option.textContent = asset.name;
215+
fileSelect.appendChild(option);
216+
});
217+
232218
downloadLink.onclick = (e) => {
233219
e.preventDefault();
234-
const downloadUrl = latestRelease.assets[0].browser_download_url;
235-
const fileName = latestRelease.assets[0].name;
220+
const downloadUrl = fileSelect.value;
221+
const fileName = fileSelect.options[fileSelect.selectedIndex].text;
236222
notification.classList.add("hidden");
237223
downloadFile(downloadUrl, fileName);
238224
};
225+
239226
notification.classList.remove("hidden");
240227
} else {
241228
// Show popup indicating the app is up-to-date

0 commit comments

Comments
 (0)