mobile: refactor & remove version.js file

This commit is contained in:
ammarahm-ed
2022-09-01 16:26:48 +05:00
parent 3f075699ae
commit bd3fa871b4
6 changed files with 19 additions and 36 deletions

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import Clipboard from "@react-native-clipboard/clipboard";
import React, { useRef, useState } from "react";
import { Linking, Platform, Text, TextInput, View } from "react-native";
import { getVersion } from "react-native-device-info";
import { db } from "../../../common/database";
import { eSendEvent, ToastEvent } from "../../../services/event-manager";
import PremiumService from "../../../services/premium";
@@ -29,7 +30,6 @@ import { eCloseProgressDialog } from "../../../utils/events";
import { openLinkInBrowser } from "../../../utils/functions";
import { SIZE } from "../../../utils/size";
import { sleep } from "../../../utils/time";
import { APP_VERSION } from "../../../version";
import DialogHeader from "../../dialog/dialog-header";
import { presentDialog } from "../../dialog/functions";
import { Button } from "../../ui/button";
@@ -59,7 +59,7 @@ export const Issue = ({ defaultTitle, defaultBody, issueTitle }) => {
body.current +
`\n_______________
**Device information:**
App version: ${APP_VERSION}
App version: ${getVersion()}
Platform: ${Platform.OS}
Model: ${Platform.constants.Brand || ""}-${Platform.constants.Model || ""}-${
Platform.constants.Version || ""
@@ -187,7 +187,9 @@ For example:
<Paragraph
size={SIZE.xs}
color={colors.icon}
>{`App version: ${APP_VERSION} Platform: ${Platform.OS} Model: ${Platform.constants.Brand}-${Platform.constants.Model}-${Platform.constants.Version}`}</Paragraph>
>{`App version: ${getVersion()} Platform: ${Platform.OS} Model: ${
Platform.constants.Brand
}-${Platform.constants.Model}-${Platform.constants.Version}`}</Paragraph>
<Seperator />
<Button

View File

@@ -17,8 +17,10 @@ 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 React from "react";
import { Platform, View } from "react-native";
import { APP_VERSION } from "../../../version";
import { getVersion } from "react-native-device-info";
import { features } from "../../../features";
import { eSendEvent, presentSheet } from "../../../services/event-manager";
import SettingsService from "../../../services/settings";
import { useThemeStore } from "../../../stores/use-theme-store";
@@ -28,8 +30,6 @@ import { Button } from "../../ui/button";
import Seperator from "../../ui/seperator";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { features } from "../../../features";
import React from "react";
export type FeatureType = {
title: string;
body: string;
@@ -89,13 +89,13 @@ NewFeature.present = () => {
const { version, introCompleted } = SettingsService.get();
if (!introCompleted) {
SettingsService.set({
version: APP_VERSION
version: getVersion()
});
return;
}
if (version && version === APP_VERSION) return false;
if (version && version === getVersion()) return false;
SettingsService.set({
version: APP_VERSION
version: getVersion()
});
const _features = features?.filter(
(feature) => !feature.platform || feature.platform === Platform.OS

View File

@@ -59,13 +59,14 @@ import {
eOpenRestoreDialog
} from "../../utils/events";
import { sleep } from "../../utils/time";
import { APP_VERSION } from "../../version";
import { MFARecoveryCodes, MFASheet } from "./2fa";
import AppLock from "./app-lock";
import { useDragState } from "./editor/state";
import { verifyUser } from "./functions";
import { SettingSection } from "./types";
import { getTimeLeft } from "./user-section";
import { getVersion } from "react-native-device-info";
const format = (ver: number) => {
const parts = ver.toString().split("");
return `v${parts[0]}.${parts[1]}.${
@@ -1014,7 +1015,7 @@ export const settingsGroups: SettingSection[] = [
console.error(e);
}
},
description: format(APP_VERSION)
description: getVersion()
}
]
}

View File

@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Platform } from "react-native";
import { getVersion } from "react-native-device-info";
import create, { State } from "zustand";
import { APP_VERSION } from "../version";
import PremiumService from "../services/premium";
import { SUBSCRIPTION_STATUS } from "../utils/constants";
import { db } from "../common/database";
import { MMKV } from "../common/database/mmkv";
import PremiumService from "../services/premium";
import { SUBSCRIPTION_STATUS } from "../utils/constants";
import layoutmanager from "../utils/layout-manager";
export interface MessageStore extends State {
message: Message;
@@ -167,7 +167,7 @@ async function shouldShowAnnouncement(announcement: Announcement) {
);
if (announcement.appVersion) {
return announcement.appVersion === APP_VERSION;
return announcement.appVersion === (getVersion() as unknown as number);
}
if (!show) return false;

View File

@@ -60,7 +60,7 @@ export type Settings = {
lastRecoveryEmailTime?: number;
lastVerificationEmailTime?: number;
sessionExpired: boolean;
version: number | null;
version: string | null;
doubleSpacedLines?: boolean;
};

View File

@@ -1,20 +0,0 @@
/*
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/>.
*/
export const APP_VERSION = 217;