aboutsummaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-02-12 19:31:32 -0500
committerIvan Chen <ivan@tagg.id>2021-02-12 19:31:32 -0500
commit5cdde33f9c35c1d26f47d0a71ee75c635a94ee49 (patch)
tree8edbe5cce80696e7a3aaf98e463acca4c8ba7c21 /src/store
parentdfff52bb9c7e8a284e465cd90a61ada94a8d6a4e (diff)
now using suggested_people_linked, moved things around
Diffstat (limited to 'src/store')
-rw-r--r--src/store/actions/user.ts53
-rw-r--r--src/store/initialStates.ts3
-rw-r--r--src/store/reducers/userReducer.ts11
3 files changed, 29 insertions, 38 deletions
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<Promise<void>, RootState, unknown, Action<string>> => async (
- dispatch,
-) => {
- try {
- dispatch({
- type: setOnboardedSuggestedPeople.type,
- payload: {onboarded},
- });
- callback();
- } catch (error) {
- console.log(error);
- }
-};
-
export const updateIsOnboardedUser = (
isOnboardedUser: boolean,
): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async (
@@ -182,9 +163,24 @@ export const logout = (): ThunkAction<
}
};
-export const updateSPSwipeTutorial = (
- user: UserType,
- data: number,
+export const uploadedSuggestedPeoplePhoto = (): ThunkAction<
+ Promise<void>,
+ RootState,
+ unknown,
+ Action<string>
+> => async (dispatch) => {
+ try {
+ dispatch({
+ type: setSuggestedPeopleLinked.type,
+ payload: {stage: 1},
+ });
+ } catch (error) {
+ console.log(error);
+ }
+};
+
+export const suggestedPeopleAnimatedTutorialFinished = (
+ userId: string,
): ThunkAction<
Promise<boolean | undefined>,
RootState,
@@ -192,12 +188,13 @@ export const updateSPSwipeTutorial = (
Action<string>
> => 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);
}
diff --git a/src/store/initialStates.ts b/src/store/initialStates.ts
index 31b39e82..10fdad25 100644
--- a/src/store/initialStates.ts
+++ b/src/store/initialStates.ts
@@ -21,8 +21,7 @@ export const NO_PROFILE: ProfileType = {
//Default to an invalid value and ignore it gracefully while showing tutorials / popups.
profile_completion_stage: -1,
- sp_swipe_tutorial: 0,
- onboarded_sugggested_people: false,
+ suggested_people_linked: -1,
snapchat: '',
tiktok: '',
friendship_status: 'no_record',
diff --git a/src/store/reducers/userReducer.ts b/src/store/reducers/userReducer.ts
index ea14c9ab..5203fa3c 100644
--- a/src/store/reducers/userReducer.ts
+++ b/src/store/reducers/userReducer.ts
@@ -46,12 +46,8 @@ const userDataSlice = createSlice({
state.profile.profile_completion_stage = action.payload.stage;
},
- spSwipeTutorialUpdated: (state, action) => {
- state.profile.sp_swipe_tutorial = action.payload.sp_swipe_tutorial;
- },
-
- setOnboardedSuggestedPeople: (state, action) => {
- state.profile.onboarded_sugggested_people = action.payload.onboarded;
+ setSuggestedPeopleLinked: (state, action) => {
+ state.profile.suggested_people_linked = action.payload.stage;
},
setIsOnboardedUser: (state, action) => {
@@ -77,11 +73,10 @@ export const {
userDetailsFetched,
socialEdited,
profileCompletionStageUpdated,
- setOnboardedSuggestedPeople,
+ setSuggestedPeopleLinked,
setIsOnboardedUser,
setNewVersionAvailable,
setNewNotificationReceived,
setReplyPosted,
- spSwipeTutorialUpdated,
} = userDataSlice.actions;
export const userDataReducer = userDataSlice.reducer;