mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Add support for draft/read-marker
References: https://github.com/ircv3/ircv3-specifications/pull/489
This commit is contained in:
parent
839e46360e
commit
1428ec4d49
2 changed files with 34 additions and 10 deletions
|
@ -414,17 +414,14 @@ export default class App extends Component {
|
|||
}
|
||||
|
||||
sendReadReceipt(client, storedBuffer) {
|
||||
if (!client.caps.enabled.has("soju.im/read")) {
|
||||
if (!client.supportsReadMarker()) {
|
||||
return;
|
||||
}
|
||||
let readReceipt = storedBuffer.receipts[ReceiptType.READ];
|
||||
if (storedBuffer.name === "*" || !readReceipt) {
|
||||
return;
|
||||
}
|
||||
client.send({
|
||||
command: "READ",
|
||||
params: [storedBuffer.name, "timestamp="+readReceipt.time],
|
||||
});
|
||||
client.setReadMarker(storedBuffer.name, readReceipt.time);
|
||||
}
|
||||
|
||||
switchBuffer(id) {
|
||||
|
@ -870,6 +867,7 @@ export default class App extends Component {
|
|||
case "CHATHISTORY":
|
||||
case "ACK":
|
||||
case "BOUNCER":
|
||||
case "MARKREAD":
|
||||
case "READ":
|
||||
// Ignore these
|
||||
return [];
|
||||
|
@ -1020,6 +1018,7 @@ export default class App extends Component {
|
|||
this.autoOpenURL = null;
|
||||
}
|
||||
break;
|
||||
case "MARKREAD":
|
||||
case "READ":
|
||||
target = msg.params[0];
|
||||
let bound = msg.params[1];
|
||||
|
@ -1228,11 +1227,8 @@ export default class App extends Component {
|
|||
});
|
||||
client.monitor(target);
|
||||
|
||||
if (client.caps.enabled.has("soju.im/read")) {
|
||||
client.send({
|
||||
command: "READ",
|
||||
params: [target],
|
||||
});
|
||||
if (client.supportsReadMarker()) {
|
||||
client.fetchReadMarker(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1015,4 +1015,32 @@ export default class Client extends EventTarget {
|
|||
return { message: msg.params[2] };
|
||||
});
|
||||
}
|
||||
|
||||
supportsReadMarker() {
|
||||
return this.caps.enabled.has("draft/read-marker") || this.caps.enabled.has("soju.im/read");
|
||||
}
|
||||
|
||||
_markReadCmd() {
|
||||
if (this.caps.enabled.has("draft/read-marker")) {
|
||||
return "MARKREAD";
|
||||
} else if (this.caps.enabled.has("soju.im/read")) {
|
||||
return "READ";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
fetchReadMarker(target) {
|
||||
this.send({
|
||||
command: this._markReadCmd(),
|
||||
params: [target],
|
||||
});
|
||||
}
|
||||
|
||||
setReadMarker(target, t) {
|
||||
this.send({
|
||||
command: this._markReadCmd(),
|
||||
params: [target, "timestamp="+t],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue