Merge pull request #1244 from streetwriters/remove-play-request

Remove play request
This commit is contained in:
Ammar Ahmed
2022-10-26 14:44:57 +05:00
committed by GitHub
7 changed files with 113 additions and 17 deletions

View File

@@ -55,6 +55,8 @@ 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 { getGithubVersion } from "../../utils/github-version";
const Launcher = React.memo(
function Launcher() {
@@ -166,8 +168,11 @@ const Launcher = React.memo(
const checkAppUpdateAvailable = async () => {
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) => <Update version={version} fwdRef={ref} />
});

View File

@@ -156,6 +156,21 @@ export const Update = ({ version: appVersion, fwdRef }) => {
}}
>
<Heading size={SIZE.md}>Release notes:</Heading>
{version.body ? (
<Paragraph
color={colors.icon}
style={{
marginBottom: 5,
fontFamily: "monospace",
fontSize: 12,
lineHeight: 20,
marginTop: 10
}}
>
{version.body}
</Paragraph>
) : null}
{notes.map((item) => (
<Paragraph
key={item}

View File

@@ -213,7 +213,6 @@ export const useAppEvents = () => {
}, []);
const onSyncComplete = useCallback(async () => {
console.log('Sync complete');
initAfterSync();
setLastSynced(await db.lastSynced());
eSendEvent(eCloseProgressDialog, "sync_progress");

View File

@@ -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");

View File

@@ -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,

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
}
}

View File

@@ -0,0 +1,77 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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()
};
};