mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-13 07:48:37 +01: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
17
commands.js
17
commands.js
@ -1,5 +1,5 @@
|
|||||||
import * as irc from "./lib/irc.js";
|
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) {
|
function getActiveClient(app) {
|
||||||
let buf = app.state.buffers.get(app.state.activeBuffer);
|
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 = {
|
const join = {
|
||||||
usage: "<name>",
|
usage: "<name>",
|
||||||
description: "Join a channel",
|
description: "Join a channel",
|
||||||
@ -174,6 +184,7 @@ export default {
|
|||||||
description: "Request user statistics about the network",
|
description: "Request user statistics about the network",
|
||||||
execute: (app, args) => {
|
execute: (app, args) => {
|
||||||
getActiveClient(app).send({ command: "LUSERS", params: args });
|
getActiveClient(app).send({ command: "LUSERS", params: args });
|
||||||
|
markServerBufferUnread(app);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"me": {
|
"me": {
|
||||||
@ -203,6 +214,7 @@ export default {
|
|||||||
description: "Get the Message Of The Day",
|
description: "Get the Message Of The Day",
|
||||||
execute: (app, args) => {
|
execute: (app, args) => {
|
||||||
getActiveClient(app).send({ command: "MOTD", params: args });
|
getActiveClient(app).send({ command: "MOTD", params: args });
|
||||||
|
markServerBufferUnread(app);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"msg": {
|
"msg": {
|
||||||
@ -310,6 +322,7 @@ export default {
|
|||||||
params.push(args.slice(1).join(" "));
|
params.push(args.slice(1).join(" "));
|
||||||
}
|
}
|
||||||
getActiveClient(app).send({ command: "STATS", params });
|
getActiveClient(app).send({ command: "STATS", params });
|
||||||
|
markServerBufferUnread(app);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"topic": {
|
"topic": {
|
||||||
@ -341,6 +354,7 @@ export default {
|
|||||||
description: "Retrieve a list of users",
|
description: "Retrieve a list of users",
|
||||||
execute: (app, args) => {
|
execute: (app, args) => {
|
||||||
getActiveClient(app).send({ command: "WHO", params: args });
|
getActiveClient(app).send({ command: "WHO", params: args });
|
||||||
|
markServerBufferUnread(app);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"whois": {
|
"whois": {
|
||||||
@ -352,6 +366,7 @@ export default {
|
|||||||
throw new Error("Missing nick");
|
throw new Error("Missing nick");
|
||||||
}
|
}
|
||||||
getActiveClient(app).send({ command: "WHOIS", params: [nick] });
|
getActiveClient(app).send({ command: "WHOIS", params: [nick] });
|
||||||
|
markServerBufferUnread(app);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user