publish: handle read notifications properly

This commit is contained in:
Isaac Visintainer 2020-03-10 14:40:32 -07:00
parent 0e9ea8c039
commit fd01162397
2 changed files with 16 additions and 1 deletions

View File

@ -54,6 +54,18 @@ export class Note extends Component {
{
window.api.fetchNote(this.props.ship, this.props.book, this.props.note);
}
if ((prevProps.book !== this.props.book) ||
(prevProps.note !== this.props.note) ||
(prevProps.ship !== this.props.ship)) {
let readAction = {
read: {
who: this.props.ship.slice(1),
book: this.props.book,
note: this.props.note,
}
}
window.api.action("publish", "publish-action", readAction);
}
}
onScroll() {

View File

@ -230,7 +230,10 @@ export class PrimaryReducer {
state.notebooks[host][book].notes &&
state.notebooks[host][book].notes[noteId])
{
state.notebooks[host][book].notes[noteId]["read"] = true;
if (!state.notebooks[host][book].notes[noteId]["read"]) {
state.notebooks[host][book].notes[noteId]["read"] = true;
state.notebooks[host][book]["num-unread"] -= 1;
}
}
}