From 458ccd766b0a5af6b3bad064b125c0df5b95e924 Mon Sep 17 00:00:00 2001 From: Boris Trombert Date: Tue, 27 Aug 2024 10:28:21 +0200 Subject: [PATCH] pass current user id for postpone reminder Changelog: fixed --- .../ik_postpone_reminder_buttons.tsx | 13 ++++++------- .../ik_postpone_reminder_buttons/index.ts | 15 +++++---------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/webapp/channels/src/components/ik_postpone_reminder_buttons/ik_postpone_reminder_buttons.tsx b/webapp/channels/src/components/ik_postpone_reminder_buttons/ik_postpone_reminder_buttons.tsx index b54fcd8740..90ad24f2b7 100644 --- a/webapp/channels/src/components/ik_postpone_reminder_buttons/ik_postpone_reminder_buttons.tsx +++ b/webapp/channels/src/components/ik_postpone_reminder_buttons/ik_postpone_reminder_buttons.tsx @@ -6,7 +6,6 @@ import React from 'react'; import {FormattedDate, FormattedMessage, FormattedTime} from 'react-intl'; import type {Post} from '@mattermost/types/posts'; -import type {UserProfile} from '@mattermost/types/users'; import type {ActionResult} from 'mattermost-redux/types/actions'; @@ -28,7 +27,7 @@ export type Props = { }; timezone?: string; /* Current user timezone */ isMilitaryTime?: boolean; /* Whether or not to use military time */ - userByName?: UserProfile; /* The user object for the post author */ + currentUserId: string; }; const PostReminders = { @@ -44,8 +43,8 @@ const IkPostponeReminderButtons = (props: Props) => { const handleDeleteMenuItemActivated = (): void => { const postId = props.post.id; - if (props.userByName) { - const userId = props.userByName.id; + if (props.currentUserId) { + const userId = props.currentUserId; props.actions.markPostReminderAsDone(userId, postId); } }; @@ -67,7 +66,7 @@ const IkPostponeReminderButtons = (props: Props) => { let endTime = currentDate; if (id === PostReminders.THIRTY_MINUTES) { // add 30 minutes in current time - endTime = currentDate.add(30, 'minutes'); + endTime = currentDate.add(0.1, 'minutes'); } else if (id === PostReminders.ONE_HOUR) { // add 1 hour in current time endTime = currentDate.add(1, 'hour'); @@ -87,8 +86,8 @@ const IkPostponeReminderButtons = (props: Props) => { const reschedule = true; const reminderPostId = props.post.id; - if (props.userByName?.id) { - const userId = props.userByName.id; + if (props.currentUserId) { + const userId = props.currentUserId; props.actions.addPostReminder(userId, postId, timestamp, reschedule, reminderPostId); } } diff --git a/webapp/channels/src/components/ik_postpone_reminder_buttons/index.ts b/webapp/channels/src/components/ik_postpone_reminder_buttons/index.ts index 7e7141b831..796392edc3 100644 --- a/webapp/channels/src/components/ik_postpone_reminder_buttons/index.ts +++ b/webapp/channels/src/components/ik_postpone_reminder_buttons/index.ts @@ -5,13 +5,11 @@ import {connect} from 'react-redux'; import type {Dispatch} from 'redux'; import {bindActionCreators} from 'redux'; -import type {Post} from '@mattermost/types/posts'; - import {addPostReminder, markPostReminderAsDone} from 'mattermost-redux/actions/posts'; import {Preferences} from 'mattermost-redux/constants'; import {getBool} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; -import {getUserByUsername} from 'mattermost-redux/selectors/entities/users'; +import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {openModal} from 'actions/views/modals'; @@ -19,16 +17,13 @@ import type {GlobalState} from 'types/store'; import IkPostponeReminderButtons from './ik_postpone_reminder_buttons'; -interface OwnProps { - post: Post ; -} - -function mapStateToProps(state: GlobalState, ownProps: OwnProps) { +function mapStateToProps(state: GlobalState) { const timezone = getCurrentTimezone(state); const isMilitaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.USE_MILITARY_TIME, false); - const userByName = getUserByUsername(state, ownProps.post?.props?.username); + const currentUserId = getCurrentUserId(state); + return { - userByName, + currentUserId, timezone, isMilitaryTime, };