From 484724022cbd84331237bf1e70bbaddc6a0ee1e8 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Wed, 3 May 2023 10:34:26 +0500 Subject: [PATCH] mobile: fix premium toast is not presented --- .../mobile/app/components/premium/premium-toast.js | 14 ++++++-------- .../app/components/sheets/manage-tags/index.js | 2 +- apps/mobile/app/services/premium.js | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/mobile/app/components/premium/premium-toast.js b/apps/mobile/app/components/premium/premium-toast.js index c04494608..0f9a6b731 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 License along with this program. If not, see . */ -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,7 +100,7 @@ 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%" }} > diff --git a/apps/mobile/app/components/sheets/manage-tags/index.js b/apps/mobile/app/components/sheets/manage-tags/index.js index 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.js index 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) {