aboutsummaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorAshm Walia <ashmwalia@outlook.com>2021-01-31 03:49:46 -0800
committerAshm Walia <ashmwalia@outlook.com>2021-01-31 03:49:46 -0800
commit60d281814c60a471598746b4dad8f3d18be0931c (patch)
tree20d1c99eb593fa999bce1376c40c22b78ebefc20 /src/store
parent69b337ed7c3844cf04a6bd1c0557ba598735f34e (diff)
Fixed
Diffstat (limited to 'src/store')
-rw-r--r--src/store/actions/userX.ts81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/store/actions/userX.ts b/src/store/actions/userX.ts
index 07bea678..af8188f1 100644
--- a/src/store/actions/userX.ts
+++ b/src/store/actions/userX.ts
@@ -1,3 +1,4 @@
+import {UserXSpecifics} from './../../types/types';
import {userXInStore} from './../../utils/';
import {getTokenOrLogout, loadAllSocialsForUser} from './../../utils';
import {UserType, ScreenType} from '../../types/types';
@@ -85,6 +86,86 @@ export const loadUserX = (
}
};
+export const loadUserXSpecifics = (
+ user: UserType,
+ specifics: UserXSpecifics[],
+ screenType: ScreenType,
+): ThunkAction<Promise<void>, RootState, unknown, Action<string>> => async (
+ dispatch,
+) => {
+ const {userId} = user;
+ await dispatch({type: userXRequested.type, payload: {screenType, userId}});
+ await dispatch({
+ type: userXUserFetched.type,
+ payload: {screenType, userId, user},
+ });
+ const token = await getTokenOrLogout(dispatch);
+ for (let specific of specifics) {
+ switch (specific) {
+ case 'Profile':
+ console.log(specific);
+ loadProfileInfo(token, userId).then((data) => {
+ dispatch({
+ type: userXProfileFetched.type,
+ payload: {screenType, userId, data},
+ });
+ });
+ break;
+ case 'Socials':
+ loadAllSocialsForUser(userId).then((data) =>
+ dispatch({
+ type: userXSocialsFetched.type,
+ payload: {screenType, userId, data},
+ }),
+ );
+ break;
+ case 'Avatar':
+ loadAvatar(userId, false).then((data) =>
+ dispatch({
+ type: userXAvatarFetched.type,
+ payload: {screenType, userId, data},
+ }),
+ );
+ break;
+ case 'Cover':
+ loadCover(token, userId).then((data) =>
+ dispatch({
+ type: userXCoverFetched.type,
+ payload: {screenType, userId, data},
+ }),
+ );
+ break;
+ case 'Friends':
+ loadFriends(userId, token).then((data) =>
+ dispatch({
+ type: userXFriendsFetched.type,
+ payload: {screenType, userId, data},
+ }),
+ );
+ break;
+ case 'Moments':
+ console.log(specific);
+ loadMoments(userId, token).then((data) =>
+ dispatch({
+ type: userXMomentsFetched.type,
+ payload: {screenType, userId, data},
+ }),
+ );
+ break;
+ case 'MomentCategories':
+ loadMomentCategories(userId, token).then((data) => {
+ dispatch({
+ type: userXMomentCategoriesFetched.type,
+ payload: {screenType, userId, data},
+ });
+ });
+ break;
+ default:
+ break;
+ }
+ }
+};
+
export const updateUserXFriends = (
userId: string,
state: RootState,