mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Keep closed buffers in store
This retains their delivery receipts. Closes: https://todo.sr.ht/~emersion/gamja/154
This commit is contained in:
parent
2f627eecad
commit
a0ed50a8e2
2 changed files with 28 additions and 13 deletions
|
@ -491,14 +491,13 @@ export default class App extends Component {
|
||||||
if (client.caps.enabled.has("draft/chathistory") && stored) {
|
if (client.caps.enabled.has("draft/chathistory") && stored) {
|
||||||
this.setBufferState({ server: serverID, name }, { unread: stored.unread });
|
this.setBufferState({ server: serverID, name }, { unread: stored.unread });
|
||||||
}
|
}
|
||||||
if (!stored) {
|
|
||||||
this.bufferStore.put({
|
this.bufferStore.put({
|
||||||
name,
|
name,
|
||||||
server: client.params,
|
server: client.params,
|
||||||
unread: Unread.NONE,
|
closed: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
createBuffer(serverID, name) {
|
createBuffer(serverID, name) {
|
||||||
let client = this.clients.get(serverID);
|
let client = this.clients.get(serverID);
|
||||||
|
@ -1029,7 +1028,7 @@ export default class App extends Component {
|
||||||
// Restore opened channel and user buffers
|
// Restore opened channel and user buffers
|
||||||
let join = [];
|
let join = [];
|
||||||
for (let buf of this.bufferStore.list(client.params)) {
|
for (let buf of this.bufferStore.list(client.params)) {
|
||||||
if (buf.name === "*") {
|
if (buf.name === "*" || buf.closed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,9 +1166,13 @@ export default class App extends Component {
|
||||||
notif.close();
|
notif.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let unread;
|
||||||
|
let closed = true;
|
||||||
this.setBufferState({ server: serverID, name: target }, (buf) => {
|
this.setBufferState({ server: serverID, name: target }, (buf) => {
|
||||||
|
closed = false;
|
||||||
|
|
||||||
// Re-compute unread status
|
// Re-compute unread status
|
||||||
let unread = Unread.NONE;
|
unread = Unread.NONE;
|
||||||
for (let i = buf.messages.length - 1; i >= 0; i--) {
|
for (let i = buf.messages.length - 1; i >= 0; i--) {
|
||||||
let msg = buf.messages[i];
|
let msg = buf.messages[i];
|
||||||
if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
|
if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
|
||||||
|
@ -1187,14 +1190,15 @@ export default class App extends Component {
|
||||||
unread = Unread.MESSAGE;
|
unread = Unread.MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { unread };
|
||||||
|
}, () => {
|
||||||
this.bufferStore.put({
|
this.bufferStore.put({
|
||||||
name: target,
|
name: target,
|
||||||
server: client.params,
|
server: client.params,
|
||||||
unread,
|
unread,
|
||||||
|
closed,
|
||||||
receipts: { [ReceiptType.READ]: readReceipt },
|
receipts: { [ReceiptType.READ]: readReceipt },
|
||||||
});
|
});
|
||||||
|
|
||||||
return { unread };
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1484,7 +1488,11 @@ export default class App extends Component {
|
||||||
|
|
||||||
client.unmonitor(buf.name);
|
client.unmonitor(buf.name);
|
||||||
|
|
||||||
this.bufferStore.delete({ name: buf.name, server: client.params });
|
this.bufferStore.put({
|
||||||
|
name: buf.name,
|
||||||
|
server: client.params,
|
||||||
|
closed: true,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
store.js
9
store.js
|
@ -85,7 +85,7 @@ export class Buffer {
|
||||||
let updated = !this.m.has(key);
|
let updated = !this.m.has(key);
|
||||||
let prev = this.m.get(key) || {};
|
let prev = this.m.get(key) || {};
|
||||||
|
|
||||||
let unread = prev.unread;
|
let unread = prev.unread || Unread.NONE;
|
||||||
if (buf.unread !== undefined && buf.unread !== prev.unread) {
|
if (buf.unread !== undefined && buf.unread !== prev.unread) {
|
||||||
unread = buf.unread;
|
unread = buf.unread;
|
||||||
updated = true;
|
updated = true;
|
||||||
|
@ -107,6 +107,12 @@ export class Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let closed = prev.closed || false;
|
||||||
|
if (buf.closed !== undefined && buf.closed !== prev.closed) {
|
||||||
|
closed = buf.closed;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +121,7 @@ export class Buffer {
|
||||||
name: buf.name,
|
name: buf.name,
|
||||||
unread,
|
unread,
|
||||||
receipts,
|
receipts,
|
||||||
|
closed,
|
||||||
server: {
|
server: {
|
||||||
bouncerNetwork: buf.server.bouncerNetwork,
|
bouncerNetwork: buf.server.bouncerNetwork,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue