aboutsummaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-11 17:27:30 -0500
committerGitHub <noreply@github.com>2021-02-11 17:27:30 -0500
commitd494b27509066f4d1b61078f1fe6457f20d5f449 (patch)
tree2418b7e9ff40fbb6d51124644065ead0a6f24e8b /src/store
parent2561d20e17a697726d6b77accf79c9da2d1f6ef6 (diff)
parenteeac3efd296656a0ef0a1e5797fec7c9955c7a12 (diff)
Merge pull request #239 from shravyaramesh/tma641-animation-tutorial
[TMA-641] Suggested People: Swipe Up Animation Tutorial
Diffstat (limited to 'src/store')
-rw-r--r--src/store/actions/user.ts29
-rw-r--r--src/store/initialStates.ts1
-rw-r--r--src/store/reducers/userReducer.ts7
3 files changed, 35 insertions, 2 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts
index 589e6f0d..990f9260 100644
--- a/src/store/actions/user.ts
+++ b/src/store/actions/user.ts
@@ -1,5 +1,10 @@
import {Action, ThunkAction} from '@reduxjs/toolkit';
-import {loadAvatar, loadCover, loadProfileInfo} from '../../services';
+import {
+ editSPSwipeTutorial,
+ loadAvatar,
+ loadCover,
+ loadProfileInfo,
+} from '../../services';
import {UserType} from '../../types/types';
import {getTokenOrLogout} from '../../utils';
import {
@@ -12,6 +17,7 @@ import {
userDetailsFetched,
userLoggedIn,
} from '../reducers';
+import {spSwipeTutorialUpdated} from '../reducers/userReducer';
import {RootState} from '../rootReducer';
import {CommentThreadType} from './../../types/types';
@@ -156,3 +162,24 @@ export const logout = (): ThunkAction<
console.log(error);
}
};
+
+export const updateSPSwipeTutorial = (
+ user: UserType,
+ data: number,
+): ThunkAction<
+ Promise<boolean | undefined>,
+ RootState,
+ unknown,
+ Action<string>
+> => async (dispatch) => {
+ try {
+ // update store first, assume success
+ dispatch({
+ type: spSwipeTutorialUpdated.type,
+ payload: {sp_swipe_tutorial: data},
+ });
+ return await editSPSwipeTutorial(user);
+ } 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 6ca133e0..93b1bc6e 100644
--- a/src/store/initialStates.ts
+++ b/src/store/initialStates.ts
@@ -21,6 +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,
snapchat: '',
tiktok: '',
friendship_status: 'no_record',
diff --git a/src/store/reducers/userReducer.ts b/src/store/reducers/userReducer.ts
index 29ec38cc..773977db 100644
--- a/src/store/reducers/userReducer.ts
+++ b/src/store/reducers/userReducer.ts
@@ -1,4 +1,4 @@
-import {createSlice, Action} from '@reduxjs/toolkit';
+import {createSlice} from '@reduxjs/toolkit';
import {NO_USER_DATA} from '../initialStates';
/**
@@ -46,6 +46,10 @@ const userDataSlice = createSlice({
state.profile.profile_completion_stage = action.payload.stage;
},
+ spSwipeTutorialUpdated: (state, action) => {
+ state.profile.sp_swipe_tutorial = action.payload.sp_swipe_tutorial;
+ },
+
setIsOnboardedUser: (state, action) => {
state.isOnboardedUser = action.payload.isOnboardedUser;
},
@@ -73,5 +77,6 @@ export const {
setNewVersionAvailable,
setNewNotificationReceived,
setReplyPosted,
+ spSwipeTutorialUpdated,
} = userDataSlice.actions;
export const userDataReducer = userDataSlice.reducer;