Skip to content

Commit cb839d4

Browse files
committed
Update version to 1.1.8 and remove Mica suffix from versioning
1 parent 72578e3 commit cb839d4

File tree

3 files changed

+20
-37
lines changed

3 files changed

+20
-37
lines changed

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-mica",
3+
"version": "1.1.8",
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-mica"
13+
iotanotepad: () => "1.1.8"
1414
},
1515
});

src/script.js

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,24 @@ document.addEventListener("DOMContentLoaded", () => {
9999
});
100100
});
101101

102-
async function fetchReleases(isMica) {
103-
const response = await fetch("https://api.github.com/repos/vorlie/iotas-notepad/releases");
104-
if (!response.ok) {
105-
console.error("Failed to fetch releases:", response.statusText);
106-
return null;
107-
}
108-
102+
async function fetchReleases() {
103+
const response = await fetch(
104+
"https://api.github.com/repos/vorlie/iotas-notepad/releases",
105+
);
109106
const releases = await response.json();
110-
111-
return releases.find(release => {
112-
const tag = release.tag_name;
113-
return isMica ? tag.includes("-mica") : !tag.includes("-mica");
114-
});
107+
return releases;
115108
}
116109

117110
function isNewerVersion(currentVersion, latestVersion) {
118-
const cleanVersion = (v) => v.replace(/-mica$/, ""); // Remove "-mica" if present
119-
120-
const current = cleanVersion(currentVersion).split(".").map(Number);
121-
const latest = cleanVersion(latestVersion).split(".").map(Number);
111+
const current = currentVersion.split(".").map(Number);
112+
const latest = latestVersion.split(".").map(Number);
122113

123114
for (let i = 0; i < latest.length; i++) {
124-
if (latest[i] > (current[i] || 0)) return true;
125-
if (latest[i] < (current[i] || 0)) return false;
115+
if (latest[i] > (current[i] || 0)) {
116+
return true;
117+
} else if (latest[i] < (current[i] || 0)) {
118+
return false;
119+
}
126120
}
127121
return false;
128122
}
@@ -157,36 +151,25 @@ window.API.on('check-for-updates', () => {
157151
});
158152

159153
async function checkForUpdates() {
160-
const isMica = window.API.versions.iotanotepad().includes("-mica"); // Detect if running Mica version
161-
const releases = await fetchReleases(isMica);
162-
163-
if (!releases || releases.length === 0) {
164-
console.error("No valid releases found.");
165-
return;
166-
}
167-
154+
const releases = await fetchReleases();
168155
const latestRelease = releases[0]; // Get the latest release
169156

170-
if (latestRelease && isNewerVersion(window.API.versions.iotanotepad(), latestRelease.tag_name)) {
157+
if (latestRelease && isNewerVersion(version, latestRelease.tag_name)) {
171158
// Show notification for new version
172159
const notification = document.getElementById("notification");
173160
const message = document.getElementById("message");
174161
const downloadLink = document.getElementById("download-link");
175-
176162
message.innerText = `New version ${latestRelease.tag_name} is available!`;
177-
window.API.sendNotification("Update Available", "A new version of the app is available.");
178-
179-
const downloadUrl = latestRelease.assets[0].browser_download_url;
180-
const fileName = latestRelease.assets[0].name;
181-
182-
downloadLink.href = downloadUrl;
163+
window.API.sendNotification('Update Available', 'A new version of the app is available.');
164+
downloadLink.href = latestRelease.assets[0].browser_download_url; // Assuming the first asset is the setup file
183165
downloadLink.innerText = "Download";
184166
downloadLink.onclick = (e) => {
185167
e.preventDefault();
168+
const downloadUrl = latestRelease.assets[0].browser_download_url;
169+
const fileName = latestRelease.assets[0].name;
186170
notification.classList.add("hidden");
187171
downloadFile(downloadUrl, fileName);
188172
};
189-
190173
notification.classList.remove("hidden");
191174
} else {
192175
// Show popup indicating the app is up-to-date

0 commit comments

Comments
 (0)