-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to new notifications endpoint #6190
Conversation
@@ -48,7 +48,6 @@ export { default as useGas } from './useGas'; | |||
export { default as useHeight } from './useHeight'; | |||
export { default as useHideSplashScreen } from './useHideSplashScreen'; | |||
export { default as useImageMetadata } from './useImageMetadata'; | |||
export { default as useInitializeAccountData } from './useInitializeAccountData'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to removal of redux explorer
if (walletSettings.length) { | ||
const newSettings = walletSettings.map(wallet => ({ | ||
...wallet, | ||
successfullyFinishedInitialSubscription: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main change: reset the successfullyFinishedInitialSubscription
flag so we know to resubscribe using the new endpoint (after it successfully resubscribes, it'll get set back to true
)
@@ -255,8 +252,7 @@ export const NotificationsHandler = ({ walletReady }: Props) => { | |||
}) | |||
) | |||
); | |||
initializeGlobalNotificationSettings(); | |||
initializeNotificationSettingsForAllAddressesAndCleanupSettingsForRemovedWallets(addresses); | |||
initializeNotificationSettingsForAllAddresses(addresses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initializeNotificationSettingsForAllAddresses
will now handle the global notification initialization as well since it's all put together in one payload to the backend
) => { | ||
analytics.track('Changed Notification Settings', { | ||
chainId, | ||
export const trackChangedGlobalNotificationSettings = (topic: GlobalNotificationTopicType, enableTopic: boolean) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed this since this was only used for the global notif changes
useEffect(() => () => { | ||
listener.remove(); | ||
}); | ||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to add this into the useEffect
because of the async nature of listener changes, which was causing the returned walletNotificationSettings
to not necessarily be in sync with the results after a setWalletNotificationSettings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice eye
|
||
const queue = _prepareSubscriptionQueueAndCreateInitialSettings(addresses, initializationState); | ||
const createInitialSettingsForAllAddresses = (addresses: AddressWithRelationship[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function uses needsUpdate
flag so that we only resubscribe when we need to (e.g, if successfullyFinishedInitialSubscription
is set to false
or if a wallet address that we have is missing from the existing notification settings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good. Main concerns:
- comparisons between addresses should be
toLowerCase()
just in case they differ in case values only JSON.parse
erratic behavior when not what we expect- creating a shared util for checking
status === RESULTS.GRANTED || status === RESULTS.LIMITED
since it's used in many places - shortcutting the need for getFCMToken after we know we have just saved it by returning the token value from
saveFCMToken
useEffect(() => () => { | ||
listener.remove(); | ||
}); | ||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice eye
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff
I followed your testing instructions here: https://www.notion.so/rainbowdotme/Notifications-upgrade-642eae49b0eb45b2a65cd89c367fed00#27a7325fd6894d9d9de645300fcdae2f
Everything behaved as expected except for one step. In the 'Toggling / changing the notifications settings in the app' section I saw an issue when toggling my group of watched wallets the first time. I saw a spinner for a while, then eventually received an error message indicating that the request had failed. However, it appeared later that the watched wallets had had their notification setting enabled.
My guess is that your PUT timed out but eventually we picked up the change. Would that make sense?
@@ -61,8 +59,8 @@ export default function useInitializeWallet() { | |||
try { | |||
PerformanceTracking.startMeasuring(PerformanceMetrics.useInitializeWallet); | |||
logger.debug('[useInitializeWallet]: Start wallet setup'); | |||
await resetAccountState(); | |||
logger.debug('[useInitializeWallet]: resetAccountState ran ok'); | |||
dispatch(requestsResetState()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the resetAccountState
function only has the WC v1 requests resetting logic left - so using this function directly instead
const dispatch = useDispatch(); | ||
|
||
const onNetworkChange = useCallback( | ||
async (chainId: ChainId) => { | ||
await resetAccountState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resetAccountState
only has the resetting of WC v1 requests now - given that this doesn't change based on accountSetting's network
anymore since we don't support testnets at the moment, and given that we will be removing WC v1, I am preemptively removing this here
not rerequesting, but the newest changes lgtm ✅ |
Includes retries if the current FCM token is out of date.
initialization Previously, we had to do firebase subscriptions one at a time. With the new API, we need to provide the full state of enabled notifications.
…fication settings for a wallet
…match NotificationsSection in its usage
… simpler unsubscribe logic
…d handle marketing topics
…setting in it; use this reset function directly instead
…ssion is GRANTED or LIMITED
…ions settings functions
604262a
to
a61a1a5
Compare
merged early as all tests had passed except for lint, and now lint passed in the final run. |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Fixes APP-887
What changed (plus any additional context for devs)
Please note: APP-985 is still a known issue
Screen recordings / screenshots
RPReplay_Final1728594734.MP4
What to test
https://www.notion.so/rainbowdotme/Notifications-upgrade-642eae49b0eb45b2a65cd89c367fed00#27a7325fd6894d9d9de645300fcdae2f