Chat notifs: only play sound for recipient message

This commit is contained in:
Alex Gleason 2020-09-17 23:27:57 -05:00
parent b49c3ad13e
commit f643863ecc
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -55,11 +55,16 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
dispatch(fetchFilters());
break;
case 'pleroma:chat_update':
dispatch((dispatch, getState) => {
const chat = JSON.parse(data.payload);
const messageOwned = !(chat.last_message && chat.last_message.account_id !== 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' },
chat,
// Only play sounds for recipient messages
meta: !messageOwned && getSettings(getState()).getIn(['chats', 'sound']) && { sound: 'chat' },
});
});
break;
}