mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
components/app: make switchBuffer state changes atomic
Instead of calling App.setBufferState inside the App.setState callback invoked when the update is done, call State.updateBuffer.
This commit is contained in:
parent
4cb3abfa72
commit
e91b044134
1 changed files with 9 additions and 8 deletions
|
@ -402,19 +402,20 @@ export default class App extends Component {
|
|||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
return { activeBuffer: buf.id };
|
||||
|
||||
let prevReadReceipt = this.getReceipt(buf.name, ReceiptType.READ);
|
||||
// TODO: only mark as read if user scrolled at the bottom
|
||||
let update = State.updateBuffer(state, buf.id, {
|
||||
unread: Unread.NONE,
|
||||
prevReadReceipt,
|
||||
});
|
||||
|
||||
return { ...update, activeBuffer: buf.id };
|
||||
}, () => {
|
||||
if (!buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
let prevReadReceipt = this.getReceipt(buf.name, ReceiptType.READ);
|
||||
// TODO: only mark as read if user scrolled at the bottom
|
||||
this.setBufferState(buf.id, {
|
||||
unread: Unread.NONE,
|
||||
prevReadReceipt,
|
||||
});
|
||||
|
||||
if (this.buffer.current) {
|
||||
this.buffer.current.focus();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue