mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 10:55:06 -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,13 +491,12 @@ export default class App extends Component {
|
|||
if (client.caps.enabled.has("draft/chathistory") && stored) {
|
||||
this.setBufferState({ server: serverID, name }, { unread: stored.unread });
|
||||
}
|
||||
if (!stored) {
|
||||
this.bufferStore.put({
|
||||
name,
|
||||
server: client.params,
|
||||
unread: Unread.NONE,
|
||||
});
|
||||
}
|
||||
|
||||
this.bufferStore.put({
|
||||
name,
|
||||
server: client.params,
|
||||
closed: false,
|
||||
});
|
||||
}
|
||||
|
||||
createBuffer(serverID, name) {
|
||||
|
@ -1029,7 +1028,7 @@ export default class App extends Component {
|
|||
// Restore opened channel and user buffers
|
||||
let join = [];
|
||||
for (let buf of this.bufferStore.list(client.params)) {
|
||||
if (buf.name === "*") {
|
||||
if (buf.name === "*" || buf.closed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1167,9 +1166,13 @@ export default class App extends Component {
|
|||
notif.close();
|
||||
}
|
||||
}
|
||||
let unread;
|
||||
let closed = true;
|
||||
this.setBufferState({ server: serverID, name: target }, (buf) => {
|
||||
closed = false;
|
||||
|
||||
// Re-compute unread status
|
||||
let unread = Unread.NONE;
|
||||
unread = Unread.NONE;
|
||||
for (let i = buf.messages.length - 1; i >= 0; i--) {
|
||||
let msg = buf.messages[i];
|
||||
if (msg.command !== "PRIVMSG" && msg.command !== "NOTICE") {
|
||||
|
@ -1187,14 +1190,15 @@ export default class App extends Component {
|
|||
unread = Unread.MESSAGE;
|
||||
}
|
||||
|
||||
return { unread };
|
||||
}, () => {
|
||||
this.bufferStore.put({
|
||||
name: target,
|
||||
server: client.params,
|
||||
unread,
|
||||
closed,
|
||||
receipts: { [ReceiptType.READ]: readReceipt },
|
||||
});
|
||||
|
||||
return { unread };
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -1484,7 +1488,11 @@ export default class App extends Component {
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
9
store.js
9
store.js
|
@ -85,7 +85,7 @@ export class Buffer {
|
|||
let updated = !this.m.has(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) {
|
||||
unread = buf.unread;
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
@ -115,6 +121,7 @@ export class Buffer {
|
|||
name: buf.name,
|
||||
unread,
|
||||
receipts,
|
||||
closed,
|
||||
server: {
|
||||
bouncerNetwork: buf.server.bouncerNetwork,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue