aboutsummaryrefslogtreecommitdiff
path: root/src/store/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/actions')
-rw-r--r--src/store/actions/taggUsers.ts3
-rw-r--r--src/store/actions/user.ts7
-rw-r--r--src/store/actions/userX.ts83
3 files changed, 47 insertions, 46 deletions
diff --git a/src/store/actions/taggUsers.ts b/src/store/actions/taggUsers.ts
index 72ce848b..0cd94e92 100644
--- a/src/store/actions/taggUsers.ts
+++ b/src/store/actions/taggUsers.ts
@@ -1,5 +1,5 @@
import {Action, ThunkAction} from '@reduxjs/toolkit';
-import {getAllExploreSections, loadRecentlySearchedUsers} from '../../services';
+import {loadRecentlySearchedUsers} from '../../services';
import {taggUsersFetched} from '../reducers';
import {RootState} from '../rootReducer';
@@ -11,7 +11,6 @@ export const loadRecentlySearched = (): ThunkAction<
> => async (dispatch) => {
try {
const recentSearches = await loadRecentlySearchedUsers();
- getAllExploreSections();
dispatch({
type: taggUsersFetched.type,
payload: {recentSearches},
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts
index 4f1da47c..46f96d9a 100644
--- a/src/store/actions/user.ts
+++ b/src/store/actions/user.ts
@@ -1,7 +1,6 @@
import {Action, ThunkAction} from '@reduxjs/toolkit';
import {
- loadAvatar,
- loadCover,
+ getProfilePic,
loadProfileInfo,
sendSuggestedPeopleLinked,
} from '../../services';
@@ -43,8 +42,8 @@ export const loadUserData = (
const token = await getTokenOrLogout(dispatch);
const [profile, avatar, cover] = await Promise.all([
loadProfileInfo(token, user.userId),
- loadAvatar(user.userId, false),
- loadCover(token, user.userId),
+ getProfilePic(token, user.userId, 'profile'),
+ getProfilePic(token, user.userId, 'header'),
]);
dispatch({
type: userDetailsFetched.type,
diff --git a/src/store/actions/userX.ts b/src/store/actions/userX.ts
index 07bea678..f32a4d8f 100644
--- a/src/store/actions/userX.ts
+++ b/src/store/actions/userX.ts
@@ -1,28 +1,27 @@
-import {userXInStore} from './../../utils/';
-import {getTokenOrLogout, loadAllSocialsForUser} from './../../utils';
-import {UserType, ScreenType} from '../../types/types';
-import {RootState} from '../rootReducer';
import {Action, ThunkAction} from '@reduxjs/toolkit';
+import moment from 'moment';
import {
- userXRequested,
+ fetchUserProfile,
+ loadFriends,
+ loadMoments,
+ loadProfileInfo,
+} from '../../services';
+import {ScreenType, UserType} from '../../types/types';
+import {
+ resetScreen,
userXAvatarFetched,
- userXFriendsFetched,
userXCoverFetched,
+ userXFriendsFetched,
+ userXMomentCategoriesFetched,
userXMomentsFetched,
userXProfileFetched,
+ userXRequested,
userXSocialsFetched,
userXUserFetched,
- userXMomentCategoriesFetched,
- resetScreen,
} from '../reducers';
-import {
- loadProfileInfo,
- loadAvatar,
- loadCover,
- loadFriends,
- loadMomentCategories,
- loadMoments,
-} from '../../services';
+import {RootState} from '../rootReducer';
+import {getTokenOrLogout, loadAllSocialsForUser} from './../../utils';
+import {userXInStore} from './../../utils/';
export const loadUserX = (
user: UserType,
@@ -38,30 +37,40 @@ export const loadUserX = (
payload: {screenType, userId, user},
});
const token = await getTokenOrLogout(dispatch);
- loadProfileInfo(token, userId).then((data) => {
- dispatch({
- type: userXProfileFetched.type,
- payload: {screenType, userId, data},
- });
+ fetchUserProfile(userId, token).then((profile) => {
+ if (profile) {
+ const birthday = profile.profile_info.birthday;
+ dispatch({
+ type: userXProfileFetched.type,
+ payload: {
+ screenType,
+ userId,
+ data: {
+ ...profile.profile_info,
+ birthday: birthday && moment(birthday).format('YYYY-MM-DD'),
+ },
+ },
+ });
+ dispatch({
+ type: userXAvatarFetched.type,
+ payload: {screenType, userId, data: profile.profile_pic},
+ });
+ dispatch({
+ type: userXCoverFetched.type,
+ payload: {screenType, userId, data: profile.header_pic},
+ });
+ dispatch({
+ type: userXMomentCategoriesFetched.type,
+ payload: {screenType, userId, data: profile.moment_categories},
+ });
+ }
});
- loadAllSocialsForUser(userId).then((data) =>
+ loadAllSocialsForUser(userId, token).then((data) =>
dispatch({
type: userXSocialsFetched.type,
payload: {screenType, userId, data},
}),
);
- loadAvatar(userId, false).then((data) =>
- dispatch({
- type: userXAvatarFetched.type,
- payload: {screenType, userId, data},
- }),
- );
- loadCover(token, userId).then((data) =>
- dispatch({
- type: userXCoverFetched.type,
- payload: {screenType, userId, data},
- }),
- );
loadFriends(userId, token).then((data) =>
dispatch({
type: userXFriendsFetched.type,
@@ -74,12 +83,6 @@ export const loadUserX = (
payload: {screenType, userId, data},
}),
);
- loadMomentCategories(userId, token).then((data) => {
- dispatch({
- type: userXMomentCategoriesFetched.type,
- payload: {screenType, userId, data},
- });
- });
} catch (error) {
console.log(error);
}