mirror of
https://git.sr.ht/~emersion/gamja
synced 2025-02-17 20:40:17 -05:00
Mark server buffer as unread after server query command
When a command will print its reply in the server buffer, mark it as unread to make it more obvious where to look. Closes: https://todo.sr.ht/~emersion/gamja/53
This commit is contained in:
parent
61e35dd68a
commit
5507b3253b
1 changed files with 16 additions and 1 deletions
17
commands.js
17
commands.js
|
@ -1,5 +1,5 @@
|
|||
import * as irc from "./lib/irc.js";
|
||||
import { SERVER_BUFFER, BufferType } from "./state.js";
|
||||
import { SERVER_BUFFER, BufferType, Unread } from "./state.js";
|
||||
|
||||
function getActiveClient(app) {
|
||||
let buf = app.state.buffers.get(app.state.activeBuffer);
|
||||
|
@ -43,6 +43,16 @@ function setUserHostMode(app, args, mode) {
|
|||
});
|
||||
}
|
||||
|
||||
function markServerBufferUnread(app) {
|
||||
var activeBuffer = app.state.buffers.get(app.state.activeBuffer);
|
||||
if (!activeBuffer || activeBuffer.type === BufferType.SERVER) {
|
||||
return;
|
||||
}
|
||||
app.setBufferState({ server: activeBuffer.server }, (buf) => {
|
||||
return { unread: Unread.union(buf.unread, Unread.MESSAGE) };
|
||||
});
|
||||
}
|
||||
|
||||
const join = {
|
||||
usage: "<name>",
|
||||
description: "Join a channel",
|
||||
|
@ -174,6 +184,7 @@ export default {
|
|||
description: "Request user statistics about the network",
|
||||
execute: (app, args) => {
|
||||
getActiveClient(app).send({ command: "LUSERS", params: args });
|
||||
markServerBufferUnread(app);
|
||||
},
|
||||
},
|
||||
"me": {
|
||||
|
@ -203,6 +214,7 @@ export default {
|
|||
description: "Get the Message Of The Day",
|
||||
execute: (app, args) => {
|
||||
getActiveClient(app).send({ command: "MOTD", params: args });
|
||||
markServerBufferUnread(app);
|
||||
},
|
||||
},
|
||||
"msg": {
|
||||
|
@ -310,6 +322,7 @@ export default {
|
|||
params.push(args.slice(1).join(" "));
|
||||
}
|
||||
getActiveClient(app).send({ command: "STATS", params });
|
||||
markServerBufferUnread(app);
|
||||
},
|
||||
},
|
||||
"topic": {
|
||||
|
@ -341,6 +354,7 @@ export default {
|
|||
description: "Retrieve a list of users",
|
||||
execute: (app, args) => {
|
||||
getActiveClient(app).send({ command: "WHO", params: args });
|
||||
markServerBufferUnread(app);
|
||||
},
|
||||
},
|
||||
"whois": {
|
||||
|
@ -352,6 +366,7 @@ export default {
|
|||
throw new Error("Missing nick");
|
||||
}
|
||||
getActiveClient(app).send({ command: "WHOIS", params: [nick] });
|
||||
markServerBufferUnread(app);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue