Refactor
This commit is contained in:
parent
9103797de4
commit
76f8e02fb9
6 changed files with 12 additions and 15 deletions
|
@ -23,8 +23,7 @@ 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 STREAMING_CHAT_UPDATE = 'STREAMING_CHAT_UPDATE';
|
||||
export const CHATS_UPDATE_NOOP = 'CHATS_UPDATE_NOOP';
|
||||
export const CHAT_NOTIFICATION = 'CHAT_NOTIFICATION';
|
||||
|
||||
export function fetchChats() {
|
||||
return (dispatch, getState) => {
|
||||
|
@ -154,21 +153,19 @@ export function markChatRead(chatId, lastReadId) {
|
|||
};
|
||||
}
|
||||
|
||||
export function updateChatsQueue(chat) {
|
||||
export function chatsNotification(chat) {
|
||||
return (dispatch, getState) => {
|
||||
const playSound = getSettings(getState()).getIn(['chats', 'sound']);
|
||||
// const flashWindow = getSettings(getState()).getIn(['chats', 'flash']);
|
||||
// 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: CHATS_UPDATE_NOOP,
|
||||
type: CHAT_NOTIFICATION,
|
||||
meta: { sound: 'chat' },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
dispatch({ type: STREAMING_CHAT_UPDATE, chat: chat, me: getState().get('me') });
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,13 +7,13 @@ import {
|
|||
processTimelineUpdate,
|
||||
} from './timelines';
|
||||
import { updateNotificationsQueue, expandNotifications } from './notifications';
|
||||
import { updateChatsQueue } from './chats';
|
||||
import { chatsNotification } from './chats';
|
||||
import { updateConversations } from './conversations';
|
||||
import { fetchFilters } from './filters';
|
||||
import { getSettings } from 'soapbox/actions/settings';
|
||||
import messages from 'soapbox/locales/messages';
|
||||
|
||||
// export const STREAMING_CHAT_UPDATE = 'STREAMING_CHAT_UPDATE';
|
||||
export const STREAMING_CHAT_UPDATE = 'STREAMING_CHAT_UPDATE';
|
||||
|
||||
const validLocale = locale => Object.keys(messages).includes(locale);
|
||||
|
||||
|
@ -56,8 +56,8 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
|
|||
dispatch(fetchFilters());
|
||||
break;
|
||||
case 'pleroma:chat_update':
|
||||
dispatch(updateChatsQueue(JSON.parse(data.payload)));
|
||||
// dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload), me: getState().get('me') });
|
||||
dispatch(chatsNotification(JSON.parse(data.payload)));
|
||||
dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload), me: getState().get('me') });
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP,
|
||||
} from '../actions/importer';
|
||||
import { CHATS_FETCH_SUCCESS, CHAT_FETCH_SUCCESS } from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
import { normalizeAccount as normalizeAccount2 } from 'soapbox/actions/importer/normalizer';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
CHAT_MESSAGE_SEND_REQUEST,
|
||||
CHAT_MESSAGE_SEND_SUCCESS,
|
||||
} from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
CHAT_MESSAGE_SEND_REQUEST,
|
||||
CHAT_MESSAGE_SEND_SUCCESS,
|
||||
} from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
CHAT_READ_SUCCESS,
|
||||
CHAT_READ_REQUEST,
|
||||
} from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/chats';
|
||||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
import { normalizeChat } from 'soapbox/actions/importer/normalizer';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
|
|
Loading…
Reference in a new issue