Skip to content

Commit

Permalink
Merge branch 'rm/350367' into 'master'
Browse files Browse the repository at this point in the history
pass current user id for postpone reminder

See merge request kchat/webapp!900
  • Loading branch information
antonbuks committed Aug 27, 2024
2 parents 6a60cba + 458ccd7 commit 3c8411d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 = {
Expand All @@ -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);
}
};
Expand All @@ -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');
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,25 @@ 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';

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,
};
Expand Down

0 comments on commit 3c8411d

Please sign in to comment.