diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-01-29 15:14:26 -0800 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-01-29 15:14:26 -0800 |
| commit | 96fda980905d0c7a30813c364c6623dda695012f (patch) | |
| tree | 8a29aca6c75d38ac52c6d941a427a9b55e69dc78 /src/store | |
| parent | 77002bb0e78d5c47e6daca14e8c699706a3f94a2 (diff) | |
full screen; with button; needs refresh&alignment;
Diffstat (limited to 'src/store')
| -rw-r--r-- | src/store/actions/userFriends.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/store/actions/userFriends.ts b/src/store/actions/userFriends.ts index 18ad247c..ae808e9a 100644 --- a/src/store/actions/userFriends.ts +++ b/src/store/actions/userFriends.ts @@ -11,6 +11,7 @@ import { declineFriendRequestService, friendOrUnfriendUser, loadFriends, + unfriendService, } from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; import { @@ -85,6 +86,39 @@ export const friendUnfriendUser = ( } }; +export const unfriendUser = ( + friend: ProfilePreviewType, // userX's profile preview + screenType: ScreenType, //screentype from content +): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async ( + dispatch, +) => { + try { + const token = await getTokenOrLogout(dispatch); + // Calls method to send post or delete request + const success = await unfriendService(friend.id, token); + if (success) { + let data = 'no_record'; + await dispatch({ + type: updateFriends.type, + payload: { + friend, + isFriend: true, + }, + }); + await dispatch({ + type: userXFriendshipEdited.type, + payload: { + userId: friend.id, + screenType, + data, + }, + }); + } + } catch (error) { + console.log(error); + } +}; + export const acceptFriendRequest = ( requester: ProfilePreviewType, ): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async ( |
