Fix notification re-appears (#1925)

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
nicolas 2021-02-22 07:09:48 -03:00 committed by GitHub
parent 45b24e98fd
commit 8e52ec5f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,8 @@ const watchedActions = [
ADD_QUEUED_TRANSACTIONS,
]
const LAST_TIME_USED_LOGGED_IN_ID = 'LAST_TIME_USED_LOGGED_IN_ID'
const sendAwaitingTransactionNotification = async (
dispatch,
safeAddress,
@ -39,7 +41,6 @@ const sendAwaitingTransactionNotification = async (
notificationKey,
notificationClickedCb,
) => {
const LAST_TIME_USED_LOGGED_IN_ID = 'LAST_TIME_USED_LOGGED_IN_ID'
if (!dispatch || !safeAddress || !awaitingTxsSubmissionDateList || !notificationKey) {
return
}
@ -48,8 +49,7 @@ const sendAwaitingTransactionNotification = async (
}
let lastTimeUserLoggedInForSafes = (await loadFromStorage<Record<string, string>>(LAST_TIME_USED_LOGGED_IN_ID)) || {}
const lastTimeUserLoggedIn =
lastTimeUserLoggedInForSafes && lastTimeUserLoggedInForSafes[safeAddress]
const lastTimeUserLoggedIn = lastTimeUserLoggedInForSafes[safeAddress]
? lastTimeUserLoggedInForSafes[safeAddress]
: null
@ -57,16 +57,17 @@ const sendAwaitingTransactionNotification = async (
return lastTimeUserLoggedIn ? new Date(submissionDate) > new Date(lastTimeUserLoggedIn) : true
})
if (filteredDuplicatedAwaitingTxList.length === 0) {
if (!filteredDuplicatedAwaitingTxList.length) {
return
}
dispatch(
enqueueSnackbar(enhanceSnackbarForAction(NOTIFICATIONS.TX_WAITING_MSG, notificationKey, notificationClickedCb)),
)
lastTimeUserLoggedInForSafes = {
...lastTimeUserLoggedInForSafes,
[safeAddress]: lastTimeUserLoggedIn || new Date(),
[safeAddress]: new Date(),
}
await saveToStorage(LAST_TIME_USED_LOGGED_IN_ID, lastTimeUserLoggedInForSafes)
}