mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Add support for draft/event-playback
This commit is contained in:
parent
651e255ddb
commit
34078d5da7
4 changed files with 65 additions and 34 deletions
|
@ -488,6 +488,7 @@ export default class App extends Component {
|
|||
|
||||
handleMessage(serverID, msg) {
|
||||
var client = this.clients.get(serverID);
|
||||
var chatHistoryBatch = irc.findBatchByType(msg, "chathistory");
|
||||
|
||||
this.setState((state) => State.handleMessage(state, msg, serverID, client));
|
||||
|
||||
|
@ -520,7 +521,9 @@ export default class App extends Component {
|
|||
if (client.isChannel(target)) {
|
||||
this.addMessage(serverID, target, msg);
|
||||
}
|
||||
if (!chatHistoryBatch) {
|
||||
this.handleMode(serverID, msg);
|
||||
}
|
||||
break;
|
||||
case "NOTICE":
|
||||
case "PRIVMSG":
|
||||
|
@ -559,7 +562,7 @@ export default class App extends Component {
|
|||
|
||||
this.addMessage(serverID, channel, msg);
|
||||
|
||||
if (client.isMyNick(msg.prefix.name)) {
|
||||
if (!chatHistoryBatch && client.isMyNick(msg.prefix.name)) {
|
||||
this.receipts.delete(channel);
|
||||
this.saveReceipts();
|
||||
}
|
||||
|
@ -570,6 +573,9 @@ export default class App extends Component {
|
|||
break;
|
||||
case "QUIT":
|
||||
var affectedBuffers = [];
|
||||
if (chatHistoryBatch) {
|
||||
affectedBuffers.push(chatHistoryBatch.params[0]);
|
||||
} else {
|
||||
this.setState((state) => {
|
||||
var buffers = new Map(state.buffers);
|
||||
state.buffers.forEach((buf) => {
|
||||
|
@ -587,12 +593,17 @@ export default class App extends Component {
|
|||
});
|
||||
return { buffers };
|
||||
});
|
||||
}
|
||||
|
||||
affectedBuffers.forEach((name) => this.addMessage(serverID, name, msg));
|
||||
break;
|
||||
case "NICK":
|
||||
var newNick = msg.params[0];
|
||||
|
||||
var affectedBuffers = [];
|
||||
if (chatHistoryBatch) {
|
||||
affectedBuffers.push(chatHistoryBatch.params[0]);
|
||||
} else {
|
||||
this.setState((state) => {
|
||||
var buffers = new Map(state.buffers);
|
||||
state.buffers.forEach((buf) => {
|
||||
|
@ -610,6 +621,8 @@ export default class App extends Component {
|
|||
});
|
||||
return { buffers };
|
||||
});
|
||||
}
|
||||
|
||||
affectedBuffers.forEach((name) => this.addMessage(serverID, name, msg));
|
||||
break;
|
||||
case "TOPIC":
|
||||
|
|
|
@ -13,6 +13,7 @@ const permanentCaps = [
|
|||
"setname",
|
||||
|
||||
"draft/chathistory",
|
||||
"draft/event-playback",
|
||||
|
||||
"soju.im/bouncer-networks",
|
||||
];
|
||||
|
@ -160,6 +161,7 @@ export default class Client extends EventTarget {
|
|||
msgBatch = this.batches.get(msg.tags["batch"]);
|
||||
if (msgBatch) {
|
||||
msgBatch.messages.push(msg);
|
||||
msg.batch = msgBatch;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
lib/irc.js
11
lib/irc.js
|
@ -533,3 +533,14 @@ export function parseMembershipModes(str) {
|
|||
}
|
||||
return memberships;
|
||||
}
|
||||
|
||||
export function findBatchByType(msg, type) {
|
||||
var batch = msg.batch;
|
||||
while (batch) {
|
||||
if (batch.type === type) {
|
||||
return batch;
|
||||
}
|
||||
batch = batch.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
5
state.js
5
state.js
|
@ -249,6 +249,11 @@ export const State = {
|
|||
return State.updateBuffer(state, { server: serverID, name }, updater);
|
||||
}
|
||||
|
||||
// Don't update our internal state if it's a chat history message
|
||||
if (irc.findBatchByType(msg, "chathistory")) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg.command) {
|
||||
case irc.RPL_MYINFO:
|
||||
// TODO: parse available modes
|
||||
|
|
Loading…
Reference in a new issue