diff --git a/app/soapbox/actions/chats.js b/app/soapbox/actions/chats.js index 4e51d776a..729dc128e 100644 --- a/app/soapbox/actions/chats.js +++ b/app/soapbox/actions/chats.js @@ -23,14 +23,11 @@ export const CHAT_READ_REQUEST = 'CHAT_READ_REQUEST'; export const CHAT_READ_SUCCESS = 'CHAT_READ_SUCCESS'; export const CHAT_READ_FAIL = 'CHAT_READ_FAIL'; -export const CHAT_NOTIFICATION = 'CHAT_NOTIFICATION'; - export function fetchChats() { return (dispatch, getState) => { dispatch({ type: CHATS_FETCH_REQUEST }); return api(getState).get('/api/v1/pleroma/chats').then(({ data }) => { dispatch({ type: CHATS_FETCH_SUCCESS, chats: data }); - chatsNotification(data); }).catch(error => { dispatch({ type: CHATS_FETCH_FAIL, error }); }); @@ -153,20 +150,3 @@ export function markChatRead(chatId, lastReadId) { }); }; } - -export function chatsNotification(chat) { - return (dispatch, getState) => { - const playSound = getSettings(getState()).getIn(['chats', 'sound']); - // const flashWindow = getSettings(getState()).getIn(['chats', 'flash']); // implement when developing chat window flashing notification - - if (playSound) { - if (chat.last_message && - chat.last_message.account_id !== getState().get('me')) { - dispatch({ - type: CHAT_NOTIFICATION, - meta: { sound: 'chat' }, - }); - } - } - }; -}; diff --git a/app/soapbox/actions/streaming.js b/app/soapbox/actions/streaming.js index 523c7e56d..5fe687878 100644 --- a/app/soapbox/actions/streaming.js +++ b/app/soapbox/actions/streaming.js @@ -7,7 +7,6 @@ import { processTimelineUpdate, } from './timelines'; import { updateNotificationsQueue, expandNotifications } from './notifications'; -import { chatsNotification } from './chats'; import { updateConversations } from './conversations'; import { fetchFilters } from './filters'; import { getSettings } from 'soapbox/actions/settings'; @@ -56,8 +55,12 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a dispatch(fetchFilters()); break; case 'pleroma:chat_update': - dispatch(chatsNotification(JSON.parse(data.payload))); - dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload), me: getState().get('me') }); + dispatch({ + type: STREAMING_CHAT_UPDATE, + chat: JSON.parse(data.payload), + me: getState().get('me'), + meta: getSettings(getState()).getIn(['chats', 'sound']) && { sound: 'chat' }, + }); break; } }, diff --git a/app/soapbox/features/chats/components/chat_box.js b/app/soapbox/features/chats/components/chat_box.js index ef7b85bf8..cded7fd70 100644 --- a/app/soapbox/features/chats/components/chat_box.js +++ b/app/soapbox/features/chats/components/chat_box.js @@ -123,17 +123,6 @@ class ChatBox extends ImmutablePureComponent { onSetInputRef(el); }; - // componentDidUpdate(prevProps) { - // const markReadConditions = [ - // () => this.props.chat !== undefined, - // () => document.activeElement === this.inputElem, - // () => this.props.chat.get('unread') > 0, - // ]; - // - // if (markReadConditions.every(c => c() === true)) - // this.markRead(); - // } - handleRemoveFile = (e) => { this.setState({ attachment: undefined, resetFileKey: fileKeyGen() }); }