Add unread message separator

Closes: https://todo.sr.ht/~emersion/gamja/4
This commit is contained in:
Simon Ser
2020-09-03 11:51:52 +02:00
parent 0b03f9d767
commit 57ca2c44ad
3 changed files with 41 additions and 10 deletions
+8 -2
View File
@@ -223,8 +223,12 @@ export default class App extends Component {
}
switchBuffer(name) {
var lastReadReceipt = this.getReceipt(name, ReceiptType.READ);
// TODO: only mark as read if user scrolled at the bottom
this.setBufferState(name, { unread: Unread.NONE });
this.setBufferState(name, {
unread: Unread.NONE,
lastReadReceipt,
});
this.setState({ activeBuffer: name }, () => {
if (this.composer.current) {
this.composer.current.focus();
@@ -329,13 +333,15 @@ export default class App extends Component {
this.setBufferState(bufName, (buf, state) => {
// TODO: set unread if scrolled up
var unread = buf.unread;
var lastReadReceipt = buf.lastReadReceipt;
if (state.activeBuffer != buf.name) {
unread = Unread.union(unread, msgUnread);
} else {
this.setReceipt(bufName, ReceiptType.READ, msg);
lastReadReceipt = this.getReceipt(bufName, ReceiptType.READ);
}
var messages = insertMessage(buf.messages, msg);
return { messages, unread };
return { messages, unread, lastReadReceipt };
});
}