fix: unread
This commit is contained in:
parent
029c7708fd
commit
7d342d4383
|
@ -77,14 +77,18 @@ const slice = createSlice({
|
||||||
extraReducers: {
|
extraReducers: {
|
||||||
[addMessage]: ({focus, unread}, {payload: {channel}}) => {
|
[addMessage]: ({focus, unread}, {payload: {channel}}) => {
|
||||||
if (focus !== channel) {
|
if (focus !== channel) {
|
||||||
unread[channel] += 1;
|
unread[channel] = (unread[channel] || 0) + 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[leave]: ({unread}, {payload: {channel}}) => {
|
[leave]: ({unread}, {payload: {channel}}) => {
|
||||||
delete unread[channel];
|
delete unread[channel];
|
||||||
},
|
},
|
||||||
[LOCATION_CHANGE]: (state, {payload: {location: {pathname}}}) => {
|
[LOCATION_CHANGE]: (state, {payload: {location: {pathname}}}) => {
|
||||||
|
const {unread} = state;
|
||||||
state.focus = pathname.match(/^\/chat\//) ? pathname.substr('/chat'.length) : '';
|
state.focus = pathname.match(/^\/chat\//) ? pathname.substr('/chat'.length) : '';
|
||||||
|
if (unread[state.focus]) {
|
||||||
|
delete unread[state.focus];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/* eslint-enable no-param-reassign */
|
/* eslint-enable no-param-reassign */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user