From 5cdde33f9c35c1d26f47d0a71ee75c635a94ee49 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 12 Feb 2021 19:31:32 -0500 Subject: now using suggested_people_linked, moved things around --- src/store/actions/user.ts | 53 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'src/store/actions') diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts index 4229517d..ef134dc5 100644 --- a/src/store/actions/user.ts +++ b/src/store/actions/user.ts @@ -1,9 +1,9 @@ import {Action, ThunkAction} from '@reduxjs/toolkit'; import { - editSPSwipeTutorial, loadAvatar, loadCover, loadProfileInfo, + sendSuggestedPeopleLinked, } from '../../services'; import {UserType} from '../../types/types'; import {getTokenOrLogout} from '../../utils'; @@ -12,13 +12,12 @@ import { setIsOnboardedUser, setNewNotificationReceived, setNewVersionAvailable, - setOnboardedSuggestedPeople, setReplyPosted, + setSuggestedPeopleLinked, socialEdited, userDetailsFetched, userLoggedIn, } from '../reducers'; -import {spSwipeTutorialUpdated} from '../reducers/userReducer'; import {RootState} from '../rootReducer'; import {CommentThreadType} from './../../types/types'; @@ -91,24 +90,6 @@ export const updateProfileCompletionStage = ( } }; -// TODO: this should be called after a successful upload of a first SP image -export const updateOnboardedSuggestedPeople = ( - onboarded: boolean, - callback: () => void, -): ThunkAction, RootState, unknown, Action> => async ( - dispatch, -) => { - try { - dispatch({ - type: setOnboardedSuggestedPeople.type, - payload: {onboarded}, - }); - callback(); - } catch (error) { - console.log(error); - } -}; - export const updateIsOnboardedUser = ( isOnboardedUser: boolean, ): ThunkAction, RootState, unknown, Action> => async ( @@ -182,9 +163,24 @@ export const logout = (): ThunkAction< } }; -export const updateSPSwipeTutorial = ( - user: UserType, - data: number, +export const uploadedSuggestedPeoplePhoto = (): ThunkAction< + Promise, + RootState, + unknown, + Action +> => async (dispatch) => { + try { + dispatch({ + type: setSuggestedPeopleLinked.type, + payload: {stage: 1}, + }); + } catch (error) { + console.log(error); + } +}; + +export const suggestedPeopleAnimatedTutorialFinished = ( + userId: string, ): ThunkAction< Promise, RootState, @@ -192,12 +188,13 @@ export const updateSPSwipeTutorial = ( Action > => async (dispatch) => { try { - // update store first, assume success + // update store first, assume request is successful dispatch({ - type: spSwipeTutorialUpdated.type, - payload: {sp_swipe_tutorial: data}, + type: setSuggestedPeopleLinked.type, + payload: {stage: 2}, }); - return await editSPSwipeTutorial(user); + // need to tell the server that the stage is now 2 + return await sendSuggestedPeopleLinked(userId, 2); } catch (error) { console.log('Error while updating suggested people linked state: ', error); } -- cgit v1.2.3-70-g09d2