fix: unread

This commit is contained in:
cha0s 2020-07-18 18:17:36 -05:00
parent 029c7708fd
commit 7d342d4383

View File

@ -77,14 +77,18 @@ const slice = createSlice({
extraReducers: {
[addMessage]: ({focus, unread}, {payload: {channel}}) => {
if (focus !== channel) {
unread[channel] += 1;
unread[channel] = (unread[channel] || 0) + 1;
}
},
[leave]: ({unread}, {payload: {channel}}) => {
delete unread[channel];
},
[LOCATION_CHANGE]: (state, {payload: {location: {pathname}}}) => {
const {unread} = state;
state.focus = pathname.match(/^\/chat\//) ? pathname.substr('/chat'.length) : '';
if (unread[state.focus]) {
delete unread[state.focus];
}
},
},
/* eslint-enable no-param-reassign */