diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index dc3f6716a..7458c3b95 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -332,7 +332,7 @@ export function insertToDraft(value) { }; } -export function toggleDMChannel(otherUserId, visible) { +export function toggleDMChannel(otherUserId, visible, channelId) { return async (dispatch, getState) => { const state = getState(); const {currentUserId} = state.entities.users; @@ -342,6 +342,11 @@ export function toggleDMChannel(otherUserId, visible) { category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, name: otherUserId, value: visible, + }, { + user_id: currentUserId, + category: Preferences.CATEGORY_CHANNEL_OPEN_TIME, + name: channelId, + value: Date.now().toString(), }]; savePreferences(currentUserId, dm)(dispatch, getState); diff --git a/app/actions/views/more_dms.js b/app/actions/views/more_dms.js index 22c8ee8e2..761a253c3 100644 --- a/app/actions/views/more_dms.js +++ b/app/actions/views/more_dms.js @@ -13,22 +13,22 @@ export function makeDirectChannel(otherUserId) { const channelName = getDirectChannelName(currentUserId, otherUserId); const {channels, myMembers} = state.entities.channels; - getProfilesByIds([otherUserId])(dispatch, getState); - getStatusesByIds([otherUserId])(dispatch, getState); + dispatch(getProfilesByIds([otherUserId])); + dispatch(getStatusesByIds([otherUserId])); let result; let channel = Object.values(channels).find((c) => c.name === channelName); if (channel && myMembers[channel.id]) { result = {data: channel}; - toggleDMChannel(otherUserId, 'true')(dispatch, getState); + dispatch(toggleDMChannel(otherUserId, 'true', channel.id)); } else { result = await createDirectChannel(currentUserId, otherUserId)(dispatch, getState); channel = result.data; } if (channel) { - handleSelectChannel(channel.id)(dispatch, getState); + dispatch(handleSelectChannel(channel.id)); } return result; @@ -40,15 +40,15 @@ export function makeGroupChannel(otherUserIds) { const state = getState(); const {currentUserId} = state.entities.users; - getProfilesByIds(otherUserIds)(dispatch, getState); - getStatusesByIds(otherUserIds)(dispatch, getState); + dispatch(getProfilesByIds(otherUserIds)); + dispatch(getStatusesByIds(otherUserIds)); const result = await createGroupChannel([currentUserId, ...otherUserIds])(dispatch, getState); const channel = result.data; if (channel) { - toggleGMChannel(channel.id, 'true')(dispatch, getState); - handleSelectChannel(channel.id)(dispatch, getState); + dispatch(toggleGMChannel(channel.id, 'true')); + dispatch(handleSelectChannel(channel.id)); } return result;