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

Commit

Permalink
Automated cherry pick of #3776 (#3777)
Browse files Browse the repository at this point in the history

Co-authored-by: Eli Yukelzon <[email protected]>
  • Loading branch information
mattermost-build and reflog committed Sep 26, 2019
1 parent b6c6882 commit 647eba0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions actions/views/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export function loadPosts({channelId, postId, type}) {
};
}

export function syncPostsInChannel(channelId, since) {
export function syncPostsInChannel(channelId, since, fetchThreads = true) {
return async (dispatch, getState) => {
const time = Date.now();
const state = getState();
Expand All @@ -286,7 +286,7 @@ export function syncPostsInChannel(channelId, since) {
sinceTimeToGetPosts = lastPostsApiCallForChannel;
}

const {data, error} = await dispatch(PostActions.getPostsSince(channelId, sinceTimeToGetPosts, false));
const {data, error} = await dispatch(PostActions.getPostsSince(channelId, sinceTimeToGetPosts, fetchThreads));
if (data) {
dispatch({
type: ActionTypes.RECEIVED_POSTS_FOR_CHANNEL_AT_TIME,
Expand Down
4 changes: 2 additions & 2 deletions actions/views/channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ describe('channel view actions', () => {
},
});

await store.dispatch(Actions.syncPostsInChannel(channelId, 12350));
await store.dispatch(Actions.syncPostsInChannel(channelId, 12350, false));
expect(PostActions.getPostsSince).toHaveBeenCalledWith(channelId, 12350, false);
});

Expand All @@ -486,7 +486,7 @@ describe('channel view actions', () => {
},
});

await store.dispatch(Actions.syncPostsInChannel(channelId, 12355));
await store.dispatch(Actions.syncPostsInChannel(channelId, 12355, false));
expect(PostActions.getPostsSince).toHaveBeenCalledWith(channelId, 12343, false);
});
});
Expand Down
2 changes: 1 addition & 1 deletion actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function reconnect(includeWebSocket = true) {
const mostRecentPost = getPost(state, mostRecentId);
dispatch(loadChannelsForCurrentUser());
if (mostRecentPost) {
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at));
dispatch(syncPostsInChannel(currentChannelId, mostRecentPost.create_at, false));
} else {
// if network timed-out the first time when loading a channel
// we can request for getPosts again when socket is connected
Expand Down
2 changes: 1 addition & 1 deletion actions/websocket_actions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('handleNewPostEvents', () => {
describe('reconnect', () => {
test('should call syncPostsInChannel when socket reconnects', () => {
reconnect(false);
expect(syncPostsInChannel).toHaveBeenCalledWith('otherChannel', '12345');
expect(syncPostsInChannel).toHaveBeenCalledWith('otherChannel', '12345', false);
});
});

Expand Down
2 changes: 1 addition & 1 deletion components/permalink_view/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {ActionTypes, Constants, ErrorPageTypes} from 'utils/constants.jsx';

export function focusPost(postId, returnTo = '') {
return async (dispatch, getState) => {
const {data} = await dispatch(getPostThread(postId));
const {data} = await dispatch(getPostThread(postId, false));

if (!data) {
browserHistory.replace(`/error?type=${ErrorPageTypes.PERMALINK_NOT_FOUND}&returnTo=${returnTo}`);
Expand Down
8 changes: 4 additions & 4 deletions components/permalink_view/permalink_view.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('components/PermalinkView', () => {
const testStore = await mockStore(initialState);
await testStore.dispatch(focusPost('postid1'));

expect(getPostThread).toHaveBeenCalledWith('postid1');
expect(getPostThread).toHaveBeenCalledWith('postid1', false);
expect(testStore.getActions()).toEqual([
{type: 'MOCK_GET_POST_THREAD', data: {posts: {postid1: {id: 'postid1', message: 'some message', channel_id: 'channelid1'}}, order: ['postid1']}},
{type: 'MOCK_SELECT_CHANNEL', args: ['channelid1']},
Expand All @@ -149,7 +149,7 @@ describe('components/PermalinkView', () => {

await testStore.dispatch(focusPost('postid2'));

expect(getPostThread).toHaveBeenCalledWith('postid2');
expect(getPostThread).toHaveBeenCalledWith('postid2', false);
expect(testStore.getActions()).toEqual([
{type: 'MOCK_GET_POST_THREAD', data: {posts: {postid2: {id: 'postid2', message: 'some message', channel_id: 'channelid2'}}, order: ['postid2']}},
{type: 'MOCK_GET_CHANNEL', data: {id: 'channelid2', type: 'O', team_id: 'current_team_id'}},
Expand All @@ -165,7 +165,7 @@ describe('components/PermalinkView', () => {
const testStore = await mockStore(initialState);
await testStore.dispatch(focusPost('dmpostid1'));

expect(getPostThread).toHaveBeenCalledWith('dmpostid1');
expect(getPostThread).toHaveBeenCalledWith('dmpostid1', false);
expect(testStore.getActions()).toEqual([
{type: 'MOCK_GET_POST_THREAD', data: {posts: {dmpostid1: {id: 'dmpostid1', message: 'some message', channel_id: 'dmchannelid'}}, order: ['dmpostid1']}},
]);
Expand All @@ -176,7 +176,7 @@ describe('components/PermalinkView', () => {
const testStore = await mockStore(initialState);
await testStore.dispatch(focusPost('gmpostid1'));

expect(getPostThread).toHaveBeenCalledWith('gmpostid1');
expect(getPostThread).toHaveBeenCalledWith('gmpostid1', false);
expect(testStore.getActions()).toEqual([
{type: 'MOCK_GET_POST_THREAD', data: {posts: {gmpostid1: {id: 'gmpostid1', message: 'some message', channel_id: 'gmchannelid'}}, order: ['gmpostid1']}},
]);
Expand Down
2 changes: 1 addition & 1 deletion components/rhs_thread/rhs_thread.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class RhsThread extends React.Component {
const curPostsArray = this.props.posts || [];

if (this.props.socketConnectionStatus && !prevProps.socketConnectionStatus) {
this.props.actions.getPostThread(this.props.selected.id);
this.props.actions.getPostThread(this.props.selected.id, false);
}

if (prevPostsArray.length >= curPostsArray.length) {
Expand Down
2 changes: 1 addition & 1 deletion components/rhs_thread/rhs_thread.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ describe('components/RhsThread', () => {
wrapper.setProps({socketConnectionStatus: false});
wrapper.setProps({socketConnectionStatus: true});

expect(actions.getPostThread).toHaveBeenCalledWith(post.id);
expect(actions.getPostThread).toHaveBeenCalledWith(post.id, false);
});
});

0 comments on commit 647eba0

Please sign in to comment.