Skip to content

Commit

Permalink
Merge pull request #1870 from LedgerHQ/bugfix/enable-every-notificati…
Browse files Browse the repository at this point in the history
…ons-categories-by-default-on-app-update

Every notifications categories are enabled by default even when updating LL to 3.11
  • Loading branch information
cgrellard-ledger authored Nov 18, 2022
2 parents 457a5e1 + 984e4a7 commit c81b011
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/itchy-rats-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Every notifications categories are enabled by default even when updating LL to 3.11
18 changes: 17 additions & 1 deletion apps/ledger-live-mobile/src/logic/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
} from "../actions/notifications";
import { setRatingsModalLocked } from "../actions/ratings";
import { track } from "../analytics";
import { notificationsSelector } from "../reducers/settings";
import { setNotifications } from "../actions/settings";

export type EventTrigger = {
timeout: NodeJS.Timeout;
Expand Down Expand Up @@ -76,6 +78,7 @@ const getIsNotifEnabled = async () => {

const useNotifications = () => {
const pushNotificationsFeature = useFeature("brazePushNotifications");
const notifications = useSelector(notificationsSelector);

const isPushNotificationsModalOpen = useSelector(
notificationsModalOpenSelector,
Expand Down Expand Up @@ -264,14 +267,27 @@ const useNotifications = () => {
);

const initPushNotificationsData = useCallback(() => {
if (notifications && notifications.areNotificationsAllowed === undefined) {
dispatch(
setNotifications({
areNotificationsAllowed: true,
announcementsCategory: true,
recommendationsCategory: true,
}),
);
}
getPushNotificationsDataOfUserFromStorage().then(dataOfUser => {
updatePushNotificationsDataOfUserInStateAndStore({
...dataOfUser,
appFirstStartDate: dataOfUser?.appFirstStartDate || Date.now(),
numberOfAppStarts: (dataOfUser?.numberOfAppStarts ?? 0) + 1,
});
});
}, [updatePushNotificationsDataOfUserInStateAndStore]);
}, [
dispatch,
notifications,
updatePushNotificationsDataOfUserInStateAndStore,
]);

const triggerMarketPushNotificationModal = useCallback(() => {
if (
Expand Down

0 comments on commit c81b011

Please sign in to comment.