From 69ff164b673e1621c339959a93d67fef4124f06e Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Thu, 6 Jun 2024 13:43:11 +0200 Subject: [PATCH] update fullUser in profile-section fix part II --- assets/notifications/actions.ts | 9 +++------ .../notifications/components/NotificationsApp.tsx | 13 +++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/assets/notifications/actions.ts b/assets/notifications/actions.ts index 5ca8e4d39..1d295d498 100644 --- a/assets/notifications/actions.ts +++ b/assets/notifications/actions.ts @@ -2,8 +2,6 @@ import {get} from 'lodash'; import {gettext, notify, errorHandler} from 'utils'; import server from 'server'; import {IUser} from 'interfaces'; -import {store as userProfileStore} from '../user-profile/store'; -import {getUser as getUserProfileUser} from 'user-profile/actions'; export const UPDATE_NOTIFICATION_COUNT = 'UPDATE_NOTIFICATION_COUNT'; export function updateNotificationCount(count: any) { @@ -117,13 +115,12 @@ export function pushNotification(push: any): any { }; } -export function updateFullUser() { +export function updateFullUser(userId: string) { return (dispatch: any, getState: any) => { - const fullUser = getState().fullUser; - return server.get(`/users/${fullUser._id}`) + return server.get(`/users/${userId}`) .then((data: IUser) => { dispatch(getUser(data)); - userProfileStore.dispatch(getUserProfileUser(data)); + return data; }) .catch((error: any) => errorHandler(error, dispatch)); }; diff --git a/assets/notifications/components/NotificationsApp.tsx b/assets/notifications/components/NotificationsApp.tsx index 88652ed07..5eacc6ff1 100644 --- a/assets/notifications/components/NotificationsApp.tsx +++ b/assets/notifications/components/NotificationsApp.tsx @@ -7,10 +7,13 @@ import { loadNotifications, updateFullUser, } from '../actions'; +import {store as userProfileStore} from '../../user-profile/store'; +import {getUser as getUserProfileUser} from 'user-profile/actions'; import NotificationList from 'components/NotificationList'; import {postNotificationSchedule} from 'helpers/notification'; import {gettext} from 'utils'; +import {IUser} from 'interfaces/user'; class NotificationsApp extends React.Component { static propTypes: any; @@ -32,7 +35,7 @@ class NotificationsApp extends React.Component { fullUser={this.props.fullUser} resumeNotifications={() => { postNotificationSchedule(this.props.fullUser._id, {pauseFrom: '', pauseTo: ''}, gettext('Notifications resumed')).then(() => - this.props.resumeNotifications() + this.props.resumeNotifications(this.props.fullUser._id) ); }} />, @@ -63,9 +66,11 @@ const mapDispatchToProps = (dispatch: any) => ({ clearNotification: (id: any) => dispatch(deleteNotification(id)), clearAll: () => dispatch(deleteAllNotifications()), loadNotifications: () => dispatch(loadNotifications()), - resumeNotifications: () => ( - dispatch(updateFullUser()) - ), + resumeNotifications: (userId: string) => { + dispatch(updateFullUser(userId)).then((fullUser: IUser) => { + userProfileStore.dispatch(getUserProfileUser(fullUser)); + }) + } }); export default connect(mapStateToProps, mapDispatchToProps)(NotificationsApp);