Correctly show unread status in sidebar

This commit is contained in:
Logan Allen 2019-06-25 13:21:11 -07:00
parent 65aa84e5a0
commit 4173f80b67
2 changed files with 17 additions and 9 deletions

View File

@ -63,9 +63,23 @@ export class Root extends Component {
if (messages[cir].length === 0) {
unreads[cir] = false;
} else {
unreads[cir] =
state.configs[cir].red <
messages[cir][messages[cir].length - 1].num;
let host = `~${window.ship}`;
let circle = cir.split('/')[1];
let internalStation = host + '/hall-internal-' + circle;
if (internalStation in state.configs) {
console.log(state.configs[internalStation].red, messages[cir]);
unreads[cir] =
state.configs[internalStation].red <=
messages[cir][messages[cir].length - 1].num;
} else {
console.log(cir, messages[cir], state.configs[cir].red);
unreads[cir] =
state.configs[cir].red <=
messages[cir][messages[cir].length - 1].num;
}
}
} else {
unreads[cir] = false;

View File

@ -76,13 +76,7 @@ export class Sidebar extends Component {
return b.wen - a.wen;
})
.map((obj) => {
let host = `~${window.ship}`;
let circle = obj.cir.split('/')[1];
let unread = props.unreads[obj.cir];
if (host + '/hall-internal-' + circle in props.unreads) {
unread = props.unreads[host + '/hall-internal-' + circle];
}
return (
<SidebarItem