Skip to content

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

fix: new version updated notice

thecodrra67278f1b508
diff --git a/apps/web/public/index.html b/apps/web/public/index.html
index b25f13b5d..091b96a1f 100644
--- a/apps/web/public/index.html
+++ b/apps/web/public/index.html
@@ -35,7 +35,7 @@
defer
data-website-id="f16c07d9-c77b-4781-bfbd-f58e95640002"
src="https://analytics.streetwriters.co/umami.js"
- data-host-url="https://app.notesnook.com"
+ data-domains="app.notesnook.com"
></script>
</head>
<body>
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index c5a633103..ad1e63560 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -24,7 +24,7 @@ import useHashRoutes from "./utils/use-hash-routes";
import hashroutes from "./navigation/hash-routes";
import rootroutes from "./navigation/rootroutes";
import { getCurrentPath } from "./navigation";
-import useVersion from "./utils/useVersion";
+import useVersion, { getCachedVersion } from "./utils/useVersion";
import {
showAppAvailableNotice,
showAppUpdatedNotice,
@@ -48,8 +48,10 @@ function App() {
useEffect(() => {
(async function () {
- if (version.appUpdated) await showAppUpdatedNotice(version);
- else if (version.appUpdateable) await showAppAvailableNotice(version);
+ const cached = getCachedVersion();
+ if (!cached) return;
+ if (cached.appUpdated) await showAppUpdatedNotice(cached);
+ else if (cached.appUpdateable) await showAppAvailableNotice(cached);
})();
}, [version]);
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index c6a497c34..f9f87297b 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -13,18 +13,18 @@ import { hashNavigate } from "../navigation";
export const db = new Database(StorageInterface, EventSource);
-// db.host({
-// API_HOST: "https://api.notesnook.com",
-// AUTH_HOST: "https://auth.streetwriters.co",
-// SSE_HOST: "https://events.streetwriters.co",
-// });
-
db.host({
- API_HOST: "http://localhost:5264",
- AUTH_HOST: "http://localhost:8264",
- SSE_HOST: "http://localhost:7264",
+ API_HOST: "https://api.notesnook.com",
+ AUTH_HOST: "https://auth.streetwriters.co",
+ SSE_HOST: "https://events.streetwriters.co",
});
+// db.host({
+// API_HOST: "http://localhost:5264",
+// AUTH_HOST: "http://localhost:8264",
+// SSE_HOST: "http://localhost:7264",
+// });
+
// db.host({
// API_HOST: "http://192.168.10.8:5264",
// AUTH_HOST: "http://192.168.10.8:8264",
diff --git a/apps/web/src/utils/useVersion.js b/apps/web/src/utils/useVersion.js
index d26b11fa6..52501efd7 100644
--- a/apps/web/src/utils/useVersion.js
+++ b/apps/web/src/utils/useVersion.js
@@ -1,6 +1,6 @@
-import { useState } from "react";
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
import { db } from "../common";
+import config from "./config";
var APP_VERSION = {
formatted: format(1110),
@@ -21,7 +21,7 @@ export default () => {
const version = await getVersion();
setVersion(version);
})();
- }, [setVersion]);
+ }, []);
return version;
};
@@ -41,8 +41,17 @@ export function getAppVersion() {
return APP_VERSION;
}
+export function getCachedVersion() {
+ return CACHED_VERSION;
+}
+
export async function getVersion() {
try {
+ var app_version = config.get("app_version");
+ if (!app_version) {
+ app_version = APP_VERSION;
+ config.set("app_version", APP_VERSION);
+ }
if (APP_VERSION.fetched) return CACHED_VERSION;
const version = await db.version();
@@ -53,7 +62,7 @@ export async function getVersion() {
formatted: format(version.web),
numerical: version.web,
appUpdated:
- version.web > APP_VERSION.numerical &&
+ version.web > app_version.numerical &&
APP_VERSION.numerical === version.web,
appUpdateable: version.web > APP_VERSION.numerical,
updateSeverity: version.severity,