Skip to content

Commit

Permalink
update fullUser in profile-section fix part II
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Jun 6, 2024
1 parent 352bf48 commit 69ff164
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 3 additions & 6 deletions assets/notifications/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) => {

Check failure on line 121 in assets/notifications/actions.ts

View workflow job for this annotation

GitHub Actions / client

Expected indentation of 12 spaces but found 8
dispatch(getUser(data));

Check failure on line 122 in assets/notifications/actions.ts

View workflow job for this annotation

GitHub Actions / client

Expected indentation of 16 spaces but found 12
userProfileStore.dispatch(getUserProfileUser(data));
return data;

Check failure on line 123 in assets/notifications/actions.ts

View workflow job for this annotation

GitHub Actions / client

Expected indentation of 16 spaces but found 12
})

Check failure on line 124 in assets/notifications/actions.ts

View workflow job for this annotation

GitHub Actions / client

Expected indentation of 12 spaces but found 8
.catch((error: any) => errorHandler(error, dispatch));

Check failure on line 125 in assets/notifications/actions.ts

View workflow job for this annotation

GitHub Actions / client

Expected indentation of 12 spaces but found 8
};
Expand Down
13 changes: 9 additions & 4 deletions assets/notifications/components/NotificationsApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any> {
static propTypes: any;
Expand All @@ -32,7 +35,7 @@ class NotificationsApp extends React.Component<any, any> {
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)
);
}}
/>,
Expand Down Expand Up @@ -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));
})

Check failure on line 72 in assets/notifications/components/NotificationsApp.tsx

View workflow job for this annotation

GitHub Actions / client

Missing semicolon
}
});

export default connect(mapStateToProps, mapDispatchToProps)(NotificationsApp);

0 comments on commit 69ff164

Please sign in to comment.