aboutsummaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-07 16:04:01 -0400
committerGitHub <noreply@github.com>2021-05-07 16:04:01 -0400
commit85dbf012ad864a1149939c7eaf43c3ebb56a1853 (patch)
treeb94d9570439ebfa42e6664144f124abe5d4113e3 /src/store
parentc9d32e68fbb9d1bc175722bfda49454a6f627eae (diff)
parent76bc8c5825f39257be6e7648d12b858f1e805569 (diff)
Merge pull request #397 from shravyaramesh/tma821-load-badges-faster-ft
[TMA-821] load badges faster
Diffstat (limited to 'src/store')
-rw-r--r--src/store/actions/user.ts22
-rw-r--r--src/store/initialStates.ts1
-rw-r--r--src/store/reducers/userReducer.ts5
3 files changed, 27 insertions, 1 deletions
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts
index 3ebd4190..96e636f6 100644
--- a/src/store/actions/user.ts
+++ b/src/store/actions/user.ts
@@ -6,10 +6,11 @@ import {
loadProfileInfo,
sendSuggestedPeopleLinked,
} from '../../services';
-import {UserType} from '../../types/types';
+import {UniversityBadge, UserType} from '../../types/types';
import {getTokenOrLogout} from '../../utils';
import {
clearHeaderAndProfileImages,
+ profileBadgesUpdated,
profileCompletionStageUpdated,
setIsOnboardedUser,
setNewNotificationReceived,
@@ -90,6 +91,25 @@ export const updateSocial = (
}
};
+/**
+ * To update new user badges
+ * @param badges current selection of badges
+ */
+export const updateUserBadges = (
+ badges: UniversityBadge[],
+): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async (
+ dispatch,
+) => {
+ try {
+ dispatch({
+ type: profileBadgesUpdated.type,
+ payload: {badges},
+ });
+ } catch (error) {
+ console.log(error);
+ }
+};
+
export const updateProfileCompletionStage = (
stage: number,
): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async (
diff --git a/src/store/initialStates.ts b/src/store/initialStates.ts
index 7fd3ac5a..e0f9d776 100644
--- a/src/store/initialStates.ts
+++ b/src/store/initialStates.ts
@@ -18,6 +18,7 @@ export const NO_PROFILE: ProfileInfoType = {
birthday: undefined,
university_class: 2021,
university: undefined,
+ badges: [],
//Default to an invalid value and ignore it gracefully while showing tutorials / popups.
profile_completion_stage: -1,
suggested_people_linked: -1,
diff --git a/src/store/reducers/userReducer.ts b/src/store/reducers/userReducer.ts
index a8789c1d..97bf845c 100644
--- a/src/store/reducers/userReducer.ts
+++ b/src/store/reducers/userReducer.ts
@@ -42,6 +42,10 @@ const userDataSlice = createSlice({
}
},
+ profileBadgesUpdated: (state, action) => {
+ state.profile.badges = action.payload.badges;
+ },
+
profileCompletionStageUpdated: (state, action) => {
state.profile.profile_completion_stage = action.payload.stage;
},
@@ -90,6 +94,7 @@ export const {
setReplyPosted,
setSuggestedPeopleImage,
clearHeaderAndProfileImages,
+ profileBadgesUpdated,
// setChatClientReady,
} = userDataSlice.actions;
export const userDataReducer = userDataSlice.reducer;