From ed91266981e1662b512baa1856d8c921a8718e68 Mon Sep 17 00:00:00 2001 From: Ashm Walia Date: Fri, 15 Jan 2021 16:20:29 -0800 Subject: fixes --- src/store/actions/userFriends.ts | 1 - src/store/actions/userX.ts | 32 +++++++++++++++++++++++++++++++- src/store/reducers/userXReducer.ts | 2 ++ 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src/store') diff --git a/src/store/actions/userFriends.ts b/src/store/actions/userFriends.ts index 010dc5ed..154ed20e 100644 --- a/src/store/actions/userFriends.ts +++ b/src/store/actions/userFriends.ts @@ -71,7 +71,6 @@ export const friendUnfriendUser = ( }); data = 'no_record'; } - // Update loggedInUser's friends list console.log('friendship_status data: ', data); dispatch({ type: userXFriendshipEdited.type, diff --git a/src/store/actions/userX.ts b/src/store/actions/userX.ts index 2f910052..6772837b 100644 --- a/src/store/actions/userX.ts +++ b/src/store/actions/userX.ts @@ -93,7 +93,11 @@ export const updateUserXFriends = ( dispatch, ) => { try { - const screens = [ScreenType.Profile, ScreenType.Search]; + const screens = [ + ScreenType.Profile, + ScreenType.Search, + ScreenType.Notifications, + ]; const token = await getTokenOrLogout(dispatch); screens.forEach((screenType) => { if (userXInStore(state, screenType, userId)) { @@ -124,3 +128,29 @@ export const resetScreenType = ( console.log(error); } }; + +export const updateUserXProfileAllScreens = ( + userId: string, +): ThunkAction, RootState, unknown, Action> => async ( + dispatch, +) => { + try { + const screens = [ + ScreenType.Profile, + ScreenType.Search, + ScreenType.Notifications, + ]; + const token = await getTokenOrLogout(dispatch); + screens.forEach((screenType) => { + loadProfileInfo(token, userId).then((data) => { + console.log('DATA FETCHED: ', data); + dispatch({ + type: userXProfileFetched.type, + payload: {screenType, userId, data}, + }); + }); + }); + } catch (error) { + console.log(error); + } +}; diff --git a/src/store/reducers/userXReducer.ts b/src/store/reducers/userXReducer.ts index 9f90d58d..42de806d 100644 --- a/src/store/reducers/userXReducer.ts +++ b/src/store/reducers/userXReducer.ts @@ -64,6 +64,8 @@ const userXSlice = createSlice({ state[action.payload.screenType][ action.payload.userId ].profile.friendship_status = action.payload.data; + + console.log('Inside state management friends', action.payload); }, resetScreen: (state, action) => { -- cgit v1.2.3-70-g09d2