diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/notifications/Notification.tsx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index e648b554..94367304 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -85,13 +85,37 @@ const Notification: React.FC<NotificationProps> = (props) => { break; case 'CMT': // find the moment we need to display - const moment = loggedInUserMoments?.find( + let moment: MomentType | undefined = loggedInUserMoments?.find( (m) => m.moment_id === notification_object?.moment_id, ); + let userXId; + + //This needs to be done if user replies to a comment on a moment that is not user's own moment + if (!moment) { + try { + if (!userXInStore(state, screenType, id)) { + await fetchUserX( + dispatch, + {userId: id, username: username}, + screenType, + ); + } + + //Wait for data to be loaded + setTimeout(() => {}, 200); + const {moments} = state.userX[screenType][id]; + moment = moments?.find( + (m) => m.moment_id === notification_object?.moment_id, + ); + userXId = id; + } catch (err) { + console.log(err); + } + } if (moment) { navigation.push('IndividualMoment', { moment, - userXId: undefined, // we're only viewing our own moment here + userXId: userXId, // we're only viewing our own moment here screenType, }); setTimeout(() => { |