diff --git a/app/soapbox/actions/chats.js b/app/soapbox/actions/chats.js index 49ab6c782..d6ecfa11d 100644 --- a/app/soapbox/actions/chats.js +++ b/app/soapbox/actions/chats.js @@ -32,3 +32,16 @@ export function openChat(chatId) { } }; } + +export function closeChat(chatId) { + return (dispatch, getState) => { + const panes = getSettings(getState()).getIn(['chats', 'panes']); + const idx = panes.findIndex(pane => pane.get('chat_id') === chatId); + + if (idx > -1) { + return dispatch(changeSetting(['chats', 'panes'], panes.delete(idx))); + } else { + return false; + } + }; +} diff --git a/app/soapbox/features/chats/components/chat_panes.js b/app/soapbox/features/chats/components/chat_panes.js index 43cb1b442..8c4dd2b90 100644 --- a/app/soapbox/features/chats/components/chat_panes.js +++ b/app/soapbox/features/chats/components/chat_panes.js @@ -10,7 +10,8 @@ import { FormattedMessage } from 'react-intl'; import { makeGetChat } from 'soapbox/selectors'; import Avatar from 'soapbox/components/avatar'; import { acctFull } from 'soapbox/utils/accounts'; -import { openChat } from 'soapbox/actions/chats'; +import { openChat, closeChat } from 'soapbox/actions/chats'; +import IconButton from 'soapbox/components/icon_button'; const addChatsToPanes = (state, panesData) => { const getChat = makeGetChat(); @@ -46,6 +47,12 @@ class ChatPanes extends ImmutablePureComponent { // TODO: Focus chat input } + handleChatClose = (chatId) => { + return (e) => { + this.props.dispatch(closeChat(chatId)); + }; + } + renderChatPane = (pane, i) => { const chat = pane.get('chat'); const account = pane.getIn(['chat', 'account']); @@ -58,6 +65,9 @@ class ChatPanes extends ImmutablePureComponent {