Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: check for updates using custom provider

thecodrre0f7f53b9053
diff --git a/apps/web/desktop/autoupdate.js b/apps/web/desktop/autoupdate.js
index 89de0b389..354eae1cb 100644
--- a/apps/web/desktop/autoupdate.js
+++ b/apps/web/desktop/autoupdate.js
@@ -1,8 +1,15 @@
const { autoUpdater } = require("electron-updater");
const { EVENTS } = require("./events");
const { sendMessageToRenderer } = require("./ipc/utils");
+const { getChangelog } = require("../src/utils/version");
async function configureAutoUpdater() {
+ autoUpdater.setFeedURL({
+ provider: "generic",
+ url: `https://notesnook.com/releases/${process.platform}/`,
+ useMultipleRangeRequest: false,
+ });
+
autoUpdater.autoDownload = false;
autoUpdater.allowDowngrade = false;
autoUpdater.allowPrerelease = false;
@@ -10,7 +17,9 @@ async function configureAutoUpdater() {
autoUpdater.addListener("checking-for-update", () => {
sendMessageToRenderer(EVENTS.checkingForUpdate);
});
- autoUpdater.addListener("update-available", (info) => {
+ autoUpdater.addListener("update-available", async (info) => {
+ info.releaseNotes = await getChangelog(info.version);
+ console.log("Get release notes!", info.releaseNotes);
sendMessageToRenderer(EVENTS.updateAvailable, info);
});
autoUpdater.addListener("download-progress", (progress) => {
diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js
index eee14505f..f631b3a85 100644
--- a/apps/web/desktop/electron.js
+++ b/apps/web/desktop/electron.js
@@ -1,3 +1,4 @@
+require("isomorphic-fetch");
const { app, BrowserWindow, nativeTheme, shell } = require("electron");
const path = require("path");
const os = require("os");
diff --git a/apps/web/desktop/package.json b/apps/web/desktop/package.json
index 82d5a2bde..b818f606b 100644
--- a/apps/web/desktop/package.json
+++ b/apps/web/desktop/package.json
@@ -12,7 +12,7 @@
"electron-better-ipc": "^2.0.1",
"electron-serve": "^1.1.0",
"electron-updater": "^4.6.5",
- "node-fetch": "^3.2.0"
+ "isomorphic-fetch": "^3.0.0"
},
"devDependencies": {
"@types/node-fetch": "^2.6.1",
diff --git a/apps/web/desktop/protocol.js b/apps/web/desktop/protocol.js
index 4c2f23958..751c1d7e7 100644
--- a/apps/web/desktop/protocol.js
+++ b/apps/web/desktop/protocol.js
@@ -2,7 +2,6 @@ const { protocol } = require("electron");
const { isDevelopment, getPath } = require("./utils");
const fs = require("fs");
const path = require("path");
-const fetch = require("node-fetch").default;
const { logger } = require("./logger");
const { Blob } = require("buffer");
diff --git a/apps/web/src/components/install-notice/index.js b/apps/web/src/components/install-notice/index.js
index 0f8684791..9aad2ecbc 100644
--- a/apps/web/src/components/install-notice/index.js
+++ b/apps/web/src/components/install-notice/index.js
@@ -1,6 +1,5 @@
import ReactDOM from "react-dom";
import { Box, Button, Flex, Text } from "rebass";
-import { closeOpenedDialog } from "../../common/dialog-controller";
import Config from "../../utils/config";
import { getDownloadLink, getPlatform } from "../../utils/platform";
import DropdownButton from "../dropdown-button";
@@ -17,18 +16,11 @@ const nativeFeatures = [
const platform = getPlatform();
const isMobile = platform === "Android" || platform === "iOS";
-const storeName = platform === "Android" ? "Play Store" : "App Store";
function getOptions(onClose) {
return getDownloadLink(platform).map((item) => ({
key: item.type || item.link,
title: () => {
- switch (platform) {
- case "iOS":
- case "Android":
- return `Install from ${storeName}`;
- default:
- return `Download (${item.type})`;
- }
+ return `${item.type}`;
},
onClick: () => {
window.open(item.link, "_blank");
diff --git a/apps/web/src/utils/platform.js b/apps/web/src/utils/platform.js
index 8c4612a8a..005adc869 100644
--- a/apps/web/src/utils/platform.js
+++ b/apps/web/src/utils/platform.js
@@ -22,55 +22,77 @@ export function getPlatform() {
}
export function getDownloadLink(platform) {
+ const baseurl = `https://notesnook.com/downloads/${platform.toLowerCase()}`;
switch (platform) {
case "iOS":
return [
{
+ type: "Install from App Store",
link: "https://apps.apple.com/pk/app/notesnook-take-private-notes/id1544027013",
},
];
case "Android":
return [
{
+ type: "Install from Google Play Store",
link: "https://play.google.com/store/apps/details?id=com.streetwriters.notesnook",
},
+ {
+ type: "Download .apk (arm64-v8a)",
+ link: `${baseurl}/notesnook-arm64-v8a.apk`,
+ },
+ {
+ type: "Download .apk (armeabi-v7a)",
+ link: `${baseurl}/notesnook-armeabi-v7a.apk`,
+ },
+ {
+ type: "Download .apk (x86)",
+ link: `${baseurl}/notesnook-x86.apk`,
+ },
+ {
+ type: "Download .apk (x86_64)",
+ link: `${baseurl}/notesnook-x86_64.apk`,
+ },
];
case "macOS":
return [
{
- type: "x64",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_x64.dmg",
+ type: "Download .dmg (x64)",
+ link: `${baseurl}/notesnook_x64.dmg`,
},
{
- type: "arm64",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_amd64.dmg",
+ type: "Download .dmg (arm64)",
+ link: `${baseurl}/notesnook_arm64.dmg`,
},
];
case "Windows":
return [
{
- type: ".exe",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_x64.exe",
+ type: "Download .exe (x64)",
+ link: `${baseurl}/notesnook_x64.exe`,
},
];
case "Linux":
return [
{
- type: ".AppImage",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_x86_64.AppImage",
+ type: "Download .AppImage",
+ link: `${baseurl}/notesnook_x86_64.AppImage`,
},
{
- type: ".deb",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_x86_64.deb",
+ type: "Download .deb",
+ link: `${baseurl}/notesnook_amd64.deb`,
},
{
- type: ".rpm",
- link: "https://github.com/streetwriters/notesnook/releases/latest/download/notesnook_x86_64.rpm",
+ type: "Download .rpm",
+ link: `${baseurl}/notesnook_x86_64.rpm`,
},
];
default:
return [
- { link: "https://github.com/streetwriters/notesnook/releases/latest/" },
+ {
+ type: "Download",
+ link: "https://github.com/streetwriters/notesnook/releases/",
+ },
];
}
}
diff --git a/apps/web/src/utils/version.js b/apps/web/src/utils/version.js
index b77f353cf..2f732b5e0 100644
--- a/apps/web/src/utils/version.js
+++ b/apps/web/src/utils/version.js
@@ -26,6 +26,7 @@ function format(version, hash, type) {
* @param {"web"|"desktop"} type
*/
function formatVersion(version) {
+ if (!version) return "";
const [major, minor, bugfix0, bugfix1] = version.toString().split("");
return `${major}.${minor}.${bugfix0}${bugfix1 || ""}`;
}