aboutsummaryrefslogtreecommitdiff
path: root/src/store/actions
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2020-12-29 20:21:24 -0500
committerGitHub <noreply@github.com>2020-12-29 20:21:24 -0500
commitbd2f89805d0bb1c2f1d08fe8d91099aa4f109d35 (patch)
treeac7219e034a0c4035096c6df8dbe6b92446b5111 /src/store/actions
parentec478d4981c726856485b49b49ac33b0d9e6a903 (diff)
[TMA-461] Notifications Screen (#151)
* renamed ProfileStack to MainStack, created initial notifications data type * cleaned up code * added notifications to redux * finished sectioned list * updated types to make more sense * finished sectioned notifications by date * updated notification type and tested mock backend integration * finished read or unread logic * minor changes * another minor fix * finished integration * moved stuff * added ability to navigate to user profile Co-authored-by: Husam Salhab <47015061+hsalhab@users.noreply.github.com>
Diffstat (limited to 'src/store/actions')
-rw-r--r--src/store/actions/index.ts1
-rw-r--r--src/store/actions/notifications.ts21
-rw-r--r--src/store/actions/user.ts2
-rw-r--r--src/store/actions/userX.ts2
4 files changed, 24 insertions, 2 deletions
diff --git a/src/store/actions/index.ts b/src/store/actions/index.ts
index f9fd5e9c..285ca4de 100644
--- a/src/store/actions/index.ts
+++ b/src/store/actions/index.ts
@@ -6,3 +6,4 @@ export * from './socials';
export * from './taggUsers';
export * from './userBlock';
export * from './userX';
+export * from './notifications';
diff --git a/src/store/actions/notifications.ts b/src/store/actions/notifications.ts
new file mode 100644
index 00000000..bace1776
--- /dev/null
+++ b/src/store/actions/notifications.ts
@@ -0,0 +1,21 @@
+import {Action, ThunkAction} from '@reduxjs/toolkit';
+import {getNotificationsData} from '../../services';
+import {userNotificationsFetched} from '../reducers';
+import {RootState} from '../rootReducer';
+
+export const loadUserNotifications = (): ThunkAction<
+ Promise<void>,
+ RootState,
+ unknown,
+ Action<string>
+> => async (dispatch) => {
+ try {
+ const notifications = await getNotificationsData();
+ dispatch({
+ type: userNotificationsFetched.type,
+ payload: notifications,
+ });
+ } catch (error) {
+ console.log(error);
+ }
+};
diff --git a/src/store/actions/user.ts b/src/store/actions/user.ts
index e77b8513..eee5fcde 100644
--- a/src/store/actions/user.ts
+++ b/src/store/actions/user.ts
@@ -26,7 +26,7 @@ export const loadUserData = (
const token = await getTokenOrLogout(dispatch);
const [profile, avatar, cover] = await Promise.all([
loadProfileInfo(token, user.userId),
- loadAvatar(token, user.userId),
+ loadAvatar(user.userId, false),
loadCover(token, user.userId),
]);
dispatch({
diff --git a/src/store/actions/userX.ts b/src/store/actions/userX.ts
index 87162eb1..e313546e 100644
--- a/src/store/actions/userX.ts
+++ b/src/store/actions/userX.ts
@@ -52,7 +52,7 @@ export const loadUserX = (
payload: {screenType, userId, data},
}),
);
- loadAvatar(token, userId).then((data) =>
+ loadAvatar(userId, false).then((data) =>
dispatch({
type: userXAvatarFetched.type,
payload: {screenType, userId, data},