From 54bf4f28557067f114a19c30778f15564d745408 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Wed, 26 Oct 2022 10:25:35 +0500 Subject: [PATCH 1/4] mobile: hide svg in dark mode --- apps/mobile/app/screens/settings/app-lock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/mobile/app/screens/settings/app-lock.js b/apps/mobile/app/screens/settings/app-lock.js index f948db494..67daa9a59 100644 --- a/apps/mobile/app/screens/settings/app-lock.js +++ b/apps/mobile/app/screens/settings/app-lock.js @@ -225,7 +225,7 @@ const AppLock = ({ route }) => { )} - {welcome ? ( + {welcome && !colors.night ? ( Date: Wed, 26 Oct 2022 10:28:15 +0500 Subject: [PATCH 2/4] mobile: do not send request to play.google.com in github release --- apps/mobile/app/components/launcher/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/mobile/app/components/launcher/index.js b/apps/mobile/app/components/launcher/index.js index 81aa2b548..5708e5a2e 100644 --- a/apps/mobile/app/components/launcher/index.js +++ b/apps/mobile/app/components/launcher/index.js @@ -55,6 +55,7 @@ import { SvgView } from "../ui/svg"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { Walkthrough } from "../walkthroughs"; +import { Config } from "react-native-config"; const Launcher = React.memo( function Launcher() { @@ -164,7 +165,7 @@ const Launcher = React.memo( }, [introCompleted]); const checkAppUpdateAvailable = async () => { - if (__DEV__) return; + if (__DEV__ || Config.GITHUB_RELEASE === "true") return; try { const version = await checkVersion(); if (!version.needsUpdate) return false; From e37b57b64bcd36bb650df7881ddbc0719c09094d Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Wed, 26 Oct 2022 10:34:18 +0500 Subject: [PATCH 3/4] mobile: do not check for subscriptions in github release --- apps/mobile/app/components/launcher/index.js | 2 +- apps/mobile/app/hooks/use-app-events.js | 1 - .../app/screens/settings/subscription.js | 2 +- apps/mobile/app/services/event-manager.ts | 2 +- apps/mobile/app/services/premium.js | 24 +++++++++---------- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/mobile/app/components/launcher/index.js b/apps/mobile/app/components/launcher/index.js index 5708e5a2e..9db395c8e 100644 --- a/apps/mobile/app/components/launcher/index.js +++ b/apps/mobile/app/components/launcher/index.js @@ -55,7 +55,7 @@ import { SvgView } from "../ui/svg"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { Walkthrough } from "../walkthroughs"; -import { Config } from "react-native-config"; +import Config from "react-native-config"; const Launcher = React.memo( function Launcher() { diff --git a/apps/mobile/app/hooks/use-app-events.js b/apps/mobile/app/hooks/use-app-events.js index 879077815..6dd4dd88c 100644 --- a/apps/mobile/app/hooks/use-app-events.js +++ b/apps/mobile/app/hooks/use-app-events.js @@ -213,7 +213,6 @@ export const useAppEvents = () => { }, []); const onSyncComplete = useCallback(async () => { - console.log('Sync complete'); initAfterSync(); setLastSynced(await db.lastSynced()); eSendEvent(eCloseProgressDialog, "sync_progress"); diff --git a/apps/mobile/app/screens/settings/subscription.js b/apps/mobile/app/screens/settings/subscription.js index 3243ff974..30ecd25ee 100644 --- a/apps/mobile/app/screens/settings/subscription.js +++ b/apps/mobile/app/screens/settings/subscription.js @@ -34,7 +34,7 @@ import { } from "../../utils/constants"; import { eOpenPremiumDialog } from "../../utils/events"; import { SIZE } from "../../utils/size"; -import { Config } from "react-native-config"; +import Config from "react-native-config"; export const Subscription = () => { const user = useUserStore((state) => state.user); const monthlyPlan = usePricing("monthly"); diff --git a/apps/mobile/app/services/event-manager.ts b/apps/mobile/app/services/event-manager.ts index 63ae30d7c..6090aaa57 100644 --- a/apps/mobile/app/services/event-manager.ts +++ b/apps/mobile/app/services/event-manager.ts @@ -21,7 +21,7 @@ import Clipboard from "@react-native-clipboard/clipboard"; import EventManager from "@notesnook/core/utils/event-manager"; import { RefObject } from "react"; import ActionSheet from "react-native-actions-sheet"; -import { Config } from "react-native-config"; +import Config from "react-native-config"; import { eHideToast, eOnNoteEdited, diff --git a/apps/mobile/app/services/premium.js b/apps/mobile/app/services/premium.js index bdedcb685..b0ed74bee 100644 --- a/apps/mobile/app/services/premium.js +++ b/apps/mobile/app/services/premium.js @@ -20,6 +20,7 @@ along with this program. If not, see . import { CHECK_IDS } from "@notesnook/core/common"; import React from "react"; import { Platform } from "react-native"; +import Config from "react-native-config"; import * as RNIap from "react-native-iap"; import { db } from "../common/database"; import { MMKV } from "../common/database/mmkv"; @@ -35,10 +36,8 @@ import { eShowGetPremium } from "../utils/events"; import { eSendEvent, presentSheet, ToastEvent } from "./event-manager"; -import Config from "react-native-config"; import SettingsService from "./settings"; -import { sleep } from "../utils/time"; let premiumStatus = 0; let products = []; let user = null; @@ -61,16 +60,17 @@ async function setPremiumStatus() { } } catch (e) { premiumStatus = 0; - } finally { - if (get()) { - await subscriptions.clear(); - } - try { - await RNIap.initConnection(); - products = await RNIap.getSubscriptions(itemSkus); - } catch (e) { - console.log("subscriptions: ", e); - } + } + if (Config.GITHUB_RELEASE) return; + + if (get()) { + await subscriptions.clear(); + } + try { + await RNIap.initConnection(); + products = await RNIap.getSubscriptions(itemSkus); + } catch (e) { + console.log("subscriptions: ", e); } } From 79e9ab282768869d6d0facef4df46f9d8900e463 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Wed, 26 Oct 2022 14:05:29 +0500 Subject: [PATCH 4/4] mobile: check github app version on launch --- apps/mobile/app/components/launcher/index.js | 10 ++- .../app/components/sheets/update/index.js | 15 ++++ apps/mobile/app/utils/github-version.ts | 77 +++++++++++++++++++ 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 apps/mobile/app/utils/github-version.ts diff --git a/apps/mobile/app/components/launcher/index.js b/apps/mobile/app/components/launcher/index.js index 9db395c8e..3d30d04ee 100644 --- a/apps/mobile/app/components/launcher/index.js +++ b/apps/mobile/app/components/launcher/index.js @@ -56,6 +56,7 @@ import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { Walkthrough } from "../walkthroughs"; import Config from "react-native-config"; +import { getGithubVersion } from "../../utils/github-version"; const Launcher = React.memo( function Launcher() { @@ -165,10 +166,13 @@ const Launcher = React.memo( }, [introCompleted]); const checkAppUpdateAvailable = async () => { - if (__DEV__ || Config.GITHUB_RELEASE === "true") return; + if (__DEV__) return; try { - const version = await checkVersion(); - if (!version.needsUpdate) return false; + const version = + Config.GITHUB_RELEASE !== "true" + ? await getGithubVersion() + : await checkVersion(); + if (!version || !version?.needsUpdate) return false; presentSheet({ component: (ref) => }); diff --git a/apps/mobile/app/components/sheets/update/index.js b/apps/mobile/app/components/sheets/update/index.js index 05d02cc93..6d626685f 100644 --- a/apps/mobile/app/components/sheets/update/index.js +++ b/apps/mobile/app/components/sheets/update/index.js @@ -156,6 +156,21 @@ export const Update = ({ version: appVersion, fwdRef }) => { }} > Release notes: + + {version.body ? ( + + {version.body} + + ) : null} {notes.map((item) => ( . +*/ + +import { getVersion } from "react-native-device-info"; + +export interface GithubRelease { + url: string; + assets_url: string; + upload_url: string; + html_url: string; + id: number; + author: unknown; + node_id: string; + tag_name: string; + target_commitish: string; + name: string; + draft: boolean; + prerelease: boolean; + created_at: Date; + published_at: Date; + assets: unknown[]; + tarball_url: string; + zipball_url: string; + body: string; + mentions_count: number; + reactions: unknown; + discussion_url: string; +} + +export const getGithubVersion = async () => { + const url = `https://api.github.com/repos/streetwriters/notesnook/releases`; + let res; + try { + res = await fetch(url, { + headers: { + "User-Agent": + "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36", + "sec-fetch-site": "same-origin" + } + }); + } catch (e) { + console.warn(e); + } + + if (!res?.ok) return null; + const data = (await res?.json()) as GithubRelease[]; + + const versions = data?.filter((tag) => tag.tag_name.endsWith("android")); + const latestVersion = versions[0]; + const version = latestVersion.tag_name.replace("-android", ""); + return { + version: version || null, + releasedAt: new Date(latestVersion.published_at).toISOString(), + notes: "", + body: latestVersion.body, + url: latestVersion.url, + lastChecked: new Date().toISOString(), + needsUpdate: getVersion() !== version, + current: getVersion() + }; +};