Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: toast does not show sometimes.

ammarahm-ed0c71c3cfe24d
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.js
index f1f1a3d55..efcee5a17 100644
--- a/apps/mobile/src/components/Toast/index.js
+++ b/apps/mobile/src/components/Toast/index.js
@@ -11,7 +11,7 @@ import {sleep} from '../../utils/TimeUtils';
import Paragraph from '../Typography/Paragraph';
const {timing} = Animated;
-const toastMessages = [];
+let toastMessages = [];
export const Toast = ({context = 'global'}) => {
const [state, dispatch] = useTracked();
const colors = state.colors;
@@ -43,7 +43,7 @@ export const Toast = ({context = 'global'}) => {
color: colors.errorText,
});
}
-
+ toastTranslate.setValue(dHeight);
toastTranslate.setValue(0);
await sleep(50);
timing(toastOpacity, {
@@ -114,18 +114,21 @@ export const Toast = ({context = 'global'}) => {
};
useEffect(() => {
+ toastMessages = [];
+ toastTranslate.setValue(dHeight);
+ toastOpacity.setValue(0);
Keyboard.addListener('keyboardDidShow', _onKeyboardShow);
Keyboard.addListener('keyboardDidHide', _onKeyboardHide);
eSubscribeEvent(eShowToast, showToastFunc);
eSubscribeEvent(eHideToast, hideToastFunc);
-
return () => {
+ toastMessages = [];
Keyboard.removeListener('keyboardDidShow', _onKeyboardShow);
Keyboard.removeListener('keyboardDidHide', _onKeyboardHide);
eUnSubscribeEvent(eShowToast, showToastFunc);
eUnSubscribeEvent(eHideToast, hideToastFunc);
};
- }, []);
+ }, [keyboard]);
return (
<Animated.View