From 288e69edb41f576b9aca4ab4e0794603d1dca91b Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 14 May 2021 12:31:58 -0400 Subject: [PATCH 1/4] hideCurrentNotification --- app/components/UI/Notification/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/UI/Notification/index.js b/app/components/UI/Notification/index.js index 4232b9c91a0..317eea54d28 100644 --- a/app/components/UI/Notification/index.js +++ b/app/components/UI/Notification/index.js @@ -49,7 +49,13 @@ function Notification(props) { return route?.routeName === BROWSER_ROUTE; }, [navigation.state]); - useEffect(() => () => removeCurrentNotification(), [removeCurrentNotification]); + useEffect( + () => () => { + removeCurrentNotification(); + hideCurrentNotification(); + }, + [hideCurrentNotification, removeCurrentNotification] + ); useEffect(() => { if (!prevNotificationIsVisible && currentNotificationIsVisible) { From ba76294b83814465a572af456473680641408e0f Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 14 May 2021 14:38:26 -0400 Subject: [PATCH 2/4] thinkisfixed --- app/components/UI/Notification/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/components/UI/Notification/index.js b/app/components/UI/Notification/index.js index 317eea54d28..dec7f43a3a9 100644 --- a/app/components/UI/Notification/index.js +++ b/app/components/UI/Notification/index.js @@ -21,7 +21,7 @@ function Notification(props) { removeCurrentNotification } = props; - const notificationAnimated = useRef(new Animated.Value(100)).current; + const notificationAnimated = useRef(new Animated.Value(200)).current; const usePrevious = value => { const ref = useRef(); @@ -51,10 +51,11 @@ function Notification(props) { useEffect( () => () => { - removeCurrentNotification(); + animatedTimingStart(notificationAnimated, 200); hideCurrentNotification(); + removeCurrentNotification(); }, - [hideCurrentNotification, removeCurrentNotification] + [notificationAnimated, animatedTimingStart, hideCurrentNotification, removeCurrentNotification] ); useEffect(() => { From 1d133dd7c40348f829fc669a11735f9e558460fc Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 14 May 2021 17:24:18 -0400 Subject: [PATCH 3/4] removenotvisiblenots --- app/actions/notification/index.js | 6 ++++++ app/components/Nav/Main/index.js | 21 ++++++++++++++++++--- app/reducers/notification/index.js | 11 +++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/actions/notification/index.js b/app/actions/notification/index.js index 58690f7ce2d..142c3b8a250 100644 --- a/app/actions/notification/index.js +++ b/app/actions/notification/index.js @@ -70,3 +70,9 @@ export function showTransactionNotification({ autodismiss, transaction, status } status }; } + +export function removeNotVisibleNotifications() { + return { + type: 'REMOVE_NOT_VISIBLE_NOTIFICATIONS' + }; +} diff --git a/app/components/Nav/Main/index.js b/app/components/Nav/Main/index.js index 219c9c299d0..616d3f1026d 100644 --- a/app/components/Nav/Main/index.js +++ b/app/components/Nav/Main/index.js @@ -50,7 +50,8 @@ import { showTransactionNotification, hideCurrentNotification, showSimpleNotification, - removeNotificationById + removeNotificationById, + removeNotVisibleNotifications } from '../../../actions/notification'; import { toggleDappTransactionModal, toggleApproveModal } from '../../../actions/modals'; import AccountApproval from '../../UI/AccountApproval'; @@ -572,6 +573,15 @@ const Main = props => { } }); + // Remove all notifications that aren't visible + useEffect( + () => { + props.removeNotVisibleNotifications(); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); + // unapprovedTransaction effect useEffect(() => { Engine.context.TransactionController.hub.on('unapprovedTransaction', onUnapprovedTransaction); @@ -761,7 +771,11 @@ Main.propTypes = { /** * Dispatch infura availability not blocked */ - setInfuraAvailabilityNotBlocked: PropTypes.func + setInfuraAvailabilityNotBlocked: PropTypes.func, + /** + * Remove not visible notifications from state + */ + removeNotVisibleNotifications: PropTypes.func }; const mapStateToProps = state => ({ @@ -787,7 +801,8 @@ const mapDispatchToProps = dispatch => ({ toggleDappTransactionModal: (show = null) => dispatch(toggleDappTransactionModal(show)), toggleApproveModal: show => dispatch(toggleApproveModal(show)), setInfuraAvailabilityBlocked: () => dispatch(setInfuraAvailabilityBlocked()), - setInfuraAvailabilityNotBlocked: () => dispatch(setInfuraAvailabilityNotBlocked()) + setInfuraAvailabilityNotBlocked: () => dispatch(setInfuraAvailabilityNotBlocked()), + removeNotVisibleNotifications: () => dispatch(removeNotVisibleNotifications()) }); export default connect( diff --git a/app/reducers/notification/index.js b/app/reducers/notification/index.js index 6f802e2adef..4c207bfed60 100644 --- a/app/reducers/notification/index.js +++ b/app/reducers/notification/index.js @@ -13,6 +13,7 @@ export const ACTIONS = { REPLACE_NOTIFICATION_BY_ID: 'REPLACE_NOTIFICATION_BY_ID', REMOVE_NOTIFICATION_BY_ID: 'REMOVE_NOTIFICATION_BY_ID', REMOVE_CURRENT_NOTIFICATION: 'REMOVE_CURRENT_NOTIFICATION', + REMOVE_NOT_VISIBLE_NOTIFICATIONS: 'REMOVE_NOT_VISIBLE_NOTIFICATIONS', SHOW_SIMPLE_NOTIFICATION: 'SHOW_SIMPLE_NOTIFICATION', SHOW_TRANSACTION_NOTIFICATION: 'SHOW_TRANSACTION_NOTIFICATION' }; @@ -172,6 +173,16 @@ const notificationReducer = (state = initialState, action) => { }) }; } + case ACTIONS.REMOVE_NOT_VISIBLE_NOTIFICATIONS: { + const visibleNotifications = notifications.reduce( + (newNotifications, notification) => notification.isVisible && newNotifications.concat(notification), + [] + ); + return { + ...state, + notifications: visibleNotifications + }; + } default: return state; } From abba5d87801cb2470880e26347232597b7c668a2 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 17 May 2021 16:37:13 -0400 Subject: [PATCH 4/4] checkarray --- app/reducers/notification/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/reducers/notification/index.js b/app/reducers/notification/index.js index 4c207bfed60..fc57b1261e5 100644 --- a/app/reducers/notification/index.js +++ b/app/reducers/notification/index.js @@ -174,10 +174,11 @@ const notificationReducer = (state = initialState, action) => { }; } case ACTIONS.REMOVE_NOT_VISIBLE_NOTIFICATIONS: { - const visibleNotifications = notifications.reduce( - (newNotifications, notification) => notification.isVisible && newNotifications.concat(notification), - [] - ); + const visibleNotifications = + notifications?.reduce( + (newNotifications, notification) => notification.isVisible && newNotifications.concat(notification), + [] + ) || []; return { ...state, notifications: visibleNotifications