A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix premium toast is not shown when using premium features on mobile (#2504)
Ammar Ahmedb69a94a96f54
diff --git a/apps/mobile/app/components/premium/premium-toast.js b/apps/mobile/app/components/premium/premium-toast.jsindex c04494608..fce278809 100644--- a/apps/mobile/app/components/premium/premium-toast.js+++ b/apps/mobile/app/components/premium/premium-toast.js@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import React, { useEffect, useRef, useState } from "react";+import React, { useCallback, useEffect, useRef, useState } from "react";import { View } from "react-native";import Animated, { FadeInUp, FadeOutUp } from "react-native-reanimated";-import { editorState } from "../../screens/editor/tiptap/utils";+import useKeyboard from "../../hooks/use-keyboard";import { DDS } from "../../services/device-detection";import {eSendEvent,@@ -31,6 +31,7 @@ import { useThemeStore } from "../../stores/use-theme-store";import { getElevation } from "../../utils";import {eCloseActionSheet,+ eCloseSheet,eOpenPremiumDialog,eShowGetPremium} from "../../utils/events";@@ -39,12 +40,12 @@ import { sleep } from "../../utils/time";import { Button } from "../ui/button";import Heading from "../ui/typography/heading";import Paragraph from "../ui/typography/paragraph";-import { useCallback } from "react";export const PremiumToast = ({ context = "global", offset = 0 }) => {const colors = useThemeStore((state) => state.colors);const [msg, setMsg] = useState(null);const timer = useRef();+ const keyboard = useKeyboard();const open = useCallback((event) => {@@ -72,7 +73,6 @@ export const PremiumToast = ({ context = "global", offset = 0 }) => {useEffect(() => {eSubscribeEvent(eShowGetPremium, open);return () => {- clearTimeout(timer.current);eUnSubscribeEvent(eShowGetPremium, open);};}, [open]);@@ -80,9 +80,7 @@ export const PremiumToast = ({ context = "global", offset = 0 }) => {const onPress = async () => {open(null);eSendEvent(eCloseActionSheet);- if (editorState().isFocused) {- //tiny.call(EditorWebView, tiny.blur);- }+ eSendEvent(eCloseSheet);await sleep(300);eSendEvent(eOpenPremiumDialog);};@@ -102,9 +100,13 @@ export const PremiumToast = ({ context = "global", offset = 0 }) => {flexDirection: "row",alignSelf: "center",justifyContent: "space-between",- top: offset,+ top: offset + keyboard.keyboardHeight,maxWidth: DDS.isLargeTablet() ? 400 : "98%"}}+ onTouchEnd={() => {+ setMsg(null);+ clearTimeout(timer.current);+ }}><Viewstyle={{diff --git a/apps/mobile/app/components/sheets/manage-tags/index.js b/apps/mobile/app/components/sheets/manage-tags/index.jsindex 1ec0115b5..2d05f95ae 100644--- a/apps/mobile/app/components/sheets/manage-tags/index.js+++ b/apps/mobile/app/components/sheets/manage-tags/index.js@@ -22,7 +22,7 @@ import { View } from "react-native";import { ScrollView } from "react-native-actions-sheet";import Icon from "react-native-vector-icons/MaterialCommunityIcons";import { db } from "../../../common/database";-import { presentSheet, ToastEvent } from "../../../services/event-manager";+import { ToastEvent, presentSheet } from "../../../services/event-manager";import Navigation from "../../../services/navigation";import { useTagStore } from "../../../stores/use-tag-store";import { useThemeStore } from "../../../stores/use-theme-store";diff --git a/apps/mobile/app/services/premium.js b/apps/mobile/app/services/premium.jsindex 5bb755e5f..ebe02e1b4 100644--- a/apps/mobile/app/services/premium.js+++ b/apps/mobile/app/services/premium.js@@ -98,7 +98,7 @@ async function getProducts() {}function get() {- if (__DEV__ || Config.isTesting) return true;+ if (__DEV__ || Config.isTesting === "true") return true;return SUBSCRIPTION_STATUS.BASIC !== premiumStatus;}@@ -128,7 +128,7 @@ const onUserStatusCheck = async (type) => {userstore.setPremium(get());}- let status = get();+ let status = false;let message = null;if (!status) {switch (type) {