Audio notification on chat. Currently hardcoded on in store/settings

better-alerts
Curtis ROck 2020-09-05 16:50:33 -05:00
rodzic cf93733076
commit ca9be1ed05
1 zmienionych plików z 9 dodań i 44 usunięć

Wyświetl plik

@ -24,6 +24,7 @@ export const CHAT_READ_SUCCESS = 'CHAT_READ_SUCCESS';
export const CHAT_READ_FAIL = 'CHAT_READ_FAIL';
export const STREAMING_CHAT_UPDATE = 'STREAMING_CHAT_UPDATE';
export const CHATS_UPDATE_NOOP = 'CHATS_UPDATE_NOOP';
export function fetchChats() {
return (dispatch, getState) => {
@ -155,52 +156,16 @@ export function markChatRead(chatId, lastReadId) {
export function updateChatsQueue(chat) {
return (dispatch, getState) => {
if (chat.type === 'pleroma:chat_mention') return; // Drop chat notifications, handle them per-chat
const playSound = getSettings(getState()).getIn(['chats', 'sound']);
// const flashWindow = getSettings(getState()).getIn(['chats', 'flash']);
// const showAlert = getSettings(getState()).getIn(['notifications', 'alerts', chat.type]);
// const filters = getFilters(getState(), { contextType: 'notifications' });
// const playSound = getSettings(getState()).getIn(['notifications', 'sounds', chat.type]);
//
// let filtered = false;
//
// const isOnNotificationsPage = curPath === '/notifications';
//
// if (chat.type === 'mention') {
// const regex = regexFromFilters(filters);
// const searchIndex = chat.status.spoiler_text + '\n' + unescapeHTML(chat.status.content);
// filtered = regex && regex.test(searchIndex);
// }
//
// // Desktop notifications
// if (typeof window.Notification !== 'undefined' && showAlert && !filtered) {
// const title = new IntlMessageFormat(intlMessages[`notification.${chat.type}`], intlLocale).format({ name: chat.account.display_name.length > 0 ? chat.account.display_name : notification.account.username });
// const body = (chat.status && chat.status.spoiler_text.length > 0) ? chat.status.spoiler_text : unescapeHTML(chat.status ? chat.status.content : '');
//
// const notify = new Notification(title, { body, icon: chat.account.avatar, tag: chat.id });
//
// notify.addEventListener('click', () => {
// window.focus();
// notify.close();
// });
// }
// if (playSound && !filtered) {
// dispatch({
// type: CHATS_UPDATE_NOOP,
// meta: { sound: 'boop' },
// });
// }
if (playSound) {
dispatch({
type: CHATS_UPDATE_NOOP,
meta: { sound: 'chat' },
});
}
dispatch({ type: STREAMING_CHAT_UPDATE, chat: chat, me: getState().get('me') });
// if (isOnNotificationsPage) {
// dispatch({
// type: CHATS_UPDATE_QUEUE,
// chat,
// intlMessages,
// intlLocale,
// });
// } else {
// dispatch(updateChats(chat, intlMessages, intlLocale));
// }
};
};