Fallback to first server buffer in Alt+a keybind

Previously we switched to the server buffer for the current network.
This commit is contained in:
Simon Ser 2021-05-31 13:24:23 +02:00
parent ab11af3965
commit e76e71c968

View file

@ -1,4 +1,4 @@
import { ReceiptType, Unread, SERVER_BUFFER } from "./state.js"; import { ReceiptType, Unread, BufferType, SERVER_BUFFER } from "./state.js";
export const keybindings = [ export const keybindings = [
{ {
@ -28,14 +28,23 @@ export const keybindings = [
description: "Jump to next buffer with activity", description: "Jump to next buffer with activity",
execute: (app) => { execute: (app) => {
// TODO: order by priority, then by age // TODO: order by priority, then by age
var target = { name: SERVER_BUFFER }; var firstServerBuffer = null;
var target = null;
for (var buf of app.state.buffers.values()) { for (var buf of app.state.buffers.values()) {
if (!firstServerBuffer && buf.type === BufferType.SERVER) {
firstServerBuffer = buf;
}
if (buf.unread != Unread.NONE) { if (buf.unread != Unread.NONE) {
target = buf; target = buf;
break; break;
} }
} }
app.switchBuffer(target); if (!target) {
target = firstServerBuffer;
}
if (target) {
app.switchBuffer(target);
}
}, },
}, },
{ {