Log direct messages and keep track of open direct message tabs
This commit is contained in:
parent
e97bb519ed
commit
8305dd561d
17 changed files with 655 additions and 304 deletions
|
@ -29,6 +29,13 @@ function loadState({ store }, env) {
|
|||
});
|
||||
}
|
||||
|
||||
if (env.openDMs) {
|
||||
store.dispatch({
|
||||
type: 'PRIVATE_CHATS',
|
||||
privateChats: env.openDMs
|
||||
});
|
||||
}
|
||||
|
||||
if (env.users) {
|
||||
store.dispatch({
|
||||
type: socketActions.USERS,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Cookie from 'js-cookie';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { getSelectedTab } from 'state/tab';
|
||||
import { isChannel, stringifyTab } from 'utils';
|
||||
import { stringifyTab } from 'utils';
|
||||
import { observe } from 'utils/observe';
|
||||
|
||||
const saveTab = debounce(
|
||||
|
@ -11,7 +11,7 @@ const saveTab = debounce(
|
|||
|
||||
export default function storage({ store }) {
|
||||
observe(store, getSelectedTab, tab => {
|
||||
if (isChannel(tab) || (tab.server && !tab.name)) {
|
||||
if (tab.server) {
|
||||
saveTab(tab);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,6 +26,7 @@ export const CLOSE_MODAL = 'CLOSE_MODAL';
|
|||
|
||||
export const CLOSE_PRIVATE_CHAT = 'CLOSE_PRIVATE_CHAT';
|
||||
export const OPEN_PRIVATE_CHAT = 'OPEN_PRIVATE_CHAT';
|
||||
export const PRIVATE_CHATS = 'PRIVATE_CHATS';
|
||||
|
||||
export const SEARCH_MESSAGES = 'SEARCH_MESSAGES';
|
||||
export const TOGGLE_SEARCH = 'TOGGLE_SEARCH';
|
||||
|
|
|
@ -30,6 +30,16 @@ export default createReducer(
|
|||
}
|
||||
},
|
||||
|
||||
[actions.PRIVATE_CHATS](state, { privateChats }) {
|
||||
privateChats.forEach(({ server, name }) => {
|
||||
if (!state[server]) {
|
||||
state[server] = [];
|
||||
}
|
||||
|
||||
state[server].push(name);
|
||||
});
|
||||
},
|
||||
|
||||
[actions.socket.PM](state, action) {
|
||||
if (action.from.indexOf('.') === -1) {
|
||||
open(state, action.server, action.from);
|
||||
|
@ -46,7 +56,11 @@ export function openPrivateChat(server, nick) {
|
|||
return {
|
||||
type: actions.OPEN_PRIVATE_CHAT,
|
||||
server,
|
||||
nick
|
||||
nick,
|
||||
socket: {
|
||||
type: 'open_dm',
|
||||
data: { server, name: nick }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,7 +69,11 @@ export function closePrivateChat(server, nick) {
|
|||
dispatch({
|
||||
type: actions.CLOSE_PRIVATE_CHAT,
|
||||
server,
|
||||
nick
|
||||
nick,
|
||||
socket: {
|
||||
type: 'close_dm',
|
||||
data: { server, name: nick }
|
||||
}
|
||||
});
|
||||
dispatch(updateSelection());
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue