Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-34366: Migrate 'components/post_view/post_list_virtualized' and associated tests to TypeScript #10426

Merged
merged 11 commits into from
Jun 15, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
isScrolling: boolean;
createAt: Date | number;
toastPresent: boolean;
isRhsPost: boolean;
isRhsPost?: boolean;
}

export default class FloatingTimestamp extends React.PureComponent<Props> {
Expand Down
2 changes: 1 addition & 1 deletion components/post_view/floating_timestamp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FloatingTimestamp from './floating_timestamp';

type OwnProps = {
postId: string;
isRhsPost: boolean;
isRhsPost?: boolean;
}

function mapStateToProps(state: GlobalState, ownProps: OwnProps) {
Expand Down
17 changes: 2 additions & 15 deletions components/post_view/post_list_row/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,16 @@ import {bindActionCreators, Dispatch} from 'redux';

import {GenericAction} from 'mattermost-redux/types/actions';

import {Channel} from '@mattermost/types/channels';
import {Post} from '@mattermost/types/posts';

import {getShortcutReactToLastPostEmittedFrom} from 'selectors/emojis';
import {emitShortcutReactToLastPostFrom} from 'actions/post_actions.jsx';

import {GlobalState} from 'types/store';

import PostListRow from './post_list_row';

type Props = {
post: Post;
sinansonmez marked this conversation as resolved.
Show resolved Hide resolved
channel: Channel;
}

function mapStateToProps(state: GlobalState, ownProps: Props) {
function mapStateToProps(state: GlobalState) {
const shortcutReactToLastPostEmittedFrom = getShortcutReactToLastPostEmittedFrom(state);

return {
post: ownProps.post,
channel: ownProps.channel,
shortcutReactToLastPostEmittedFrom,
};
return {shortcutReactToLastPostEmittedFrom};
}

function mapDispatchToProps(dispatch: Dispatch<GenericAction>) {
Expand Down
2 changes: 1 addition & 1 deletion components/post_view/post_list_row/post_list_row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type PostListRowProps = {
shouldHighlight?: boolean;
loadOlderPosts: () => void;
loadNewerPosts: () => void;
togglePostMenu: () => void;
togglePostMenu: (opened: boolean) => void;

/**
* To Check if the current post is last in the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ describe('LatestPostReader', () => {
test('should render aria-label as a child in the given locale', () => {
const {mountOptions} = mockStore(baseState);

useIntl.mockImplementation(() => createIntl({locale: 'en', messages: enMessages, defaultLocale: 'en'}));
(useIntl as jest.Mock).mockImplementation(() => createIntl({locale: 'en', messages: enMessages, defaultLocale: 'en'}));

let wrapper = mount(<LatestPostReader {...baseProps}/>, mountOptions);
let span = wrapper.childAt(0);

expect(span.prop('children')).toContain(author.username);
expect(span.prop('children')).toContain('January');

useIntl.mockImplementation(() => createIntl({locale: 'es', messages: esMessages, defaultLocale: 'es'}));
(useIntl as jest.Mock).mockImplementation(() => createIntl({locale: 'es', messages: esMessages, defaultLocale: 'es'}));

wrapper = mount(<LatestPostReader {...baseProps}/>, mountOptions);
span = wrapper.childAt(0);
Expand Down
Loading