mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-28 18:26:19 -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) {
|
if (!buf) {
|
||||||
return;
|
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) {
|
if (!buf) {
|
||||||
return;
|
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) {
|
if (this.buffer.current) {
|
||||||
this.buffer.current.focus();
|
this.buffer.current.focus();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue