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
fix toast not showing properly
ammarahm-ed3fdc513102b4
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.jsindex ceee65428..d60b61aad 100644--- a/apps/mobile/src/components/Toast/index.js+++ b/apps/mobile/src/components/Toast/index.js@@ -3,7 +3,7 @@ import {Keyboard, View} from 'react-native';import Animated, {Easing, useValue} from 'react-native-reanimated';import {useSafeAreaInsets} from 'react-native-safe-area-context';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';+import {notesnook} from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {DDS} from '../../services/DeviceDetection';import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';@@ -32,7 +32,7 @@ export const Toast = ({context = 'global'}) => {let toastOpacity = useValue(0);const showToastFunc = async data => {- console.log('toast show', data.message);+ console.log('toast show', data.message, toastMessages.length);if (!data) return;if (data.context !== context) return;if (toastMessages.findIndex(m => m.message === data.message) >= 0) {@@ -53,13 +53,16 @@ export const Toast = ({context = 'global'}) => {}toastTranslate.setValue(-dHeight);toastTranslate.setValue(0);- await sleep(50);+ await sleep(1);timing(toastOpacity, {toValue: 1,duration: 150,easing: Easing.ease}).start();+ if (hideTimeout.current) {+ clearTimeout(hideTimeout.current);+ }hideTimeout.current = setTimeout(() => {hideToastFunc();}, data.duration);@@ -80,12 +83,18 @@ export const Toast = ({context = 'global'}) => {color: colors.errorText});}+ if (hideTimeout.current) {+ clearTimeout(hideTimeout.current);+ }hideTimeout.current = setTimeout(() => {hideToastFunc();}, data?.duration);};const hideToastFunc = () => {+ if (hideTimeout.current) {+ clearTimeout(hideTimeout.current);+ }let msg = toastMessages.length > 1 ? toastMessages.shift() : null;if (msg) {timing(toastOpacity, {@@ -112,6 +121,9 @@ export const Toast = ({context = 'global'}) => {toastTranslate.setValue(-dHeight);toastMessages.shift();setData({});+ if (hideTimeout.current) {+ clearTimeout(hideTimeout.current);+ }});}};@@ -149,9 +161,11 @@ export const Toast = ({context = 'global'}) => {<Animated.ViewonTouchEnd={() => {if (!data.func) {+ if (hideTimeout.current) {+ clearTimeout(hideTimeout.current);+ }hideToastFunc();}-}}style={{width: DDS.isTab ? 400 : '100%',@@ -251,7 +265,7 @@ export const Toast = ({context = 'global'}) => {title={data.actionText}height={30}style={{- zIndex:10+ zIndex: 10}}/>) : null}