Restore opened user query buffers
Closes: https://todo.sr.ht/~emersion/gamja/93
This commit is contained in:
parent
4dd1fac002
commit
016ca27f2d
2 changed files with 86 additions and 2 deletions
|
@ -170,6 +170,7 @@ export default class App extends Component {
|
|||
this.saveReceipts = debounce(this.saveReceipts.bind(this), 500);
|
||||
|
||||
this.receipts = store.receipts.load();
|
||||
this.bufferStore = new store.Buffer();
|
||||
|
||||
configPromise.then((config) => {
|
||||
this.handleConfig(config);
|
||||
|
@ -264,13 +265,14 @@ export default class App extends Component {
|
|||
}
|
||||
|
||||
createBuffer(serverID, name) {
|
||||
let client = this.clients.get(serverID);
|
||||
let id = null;
|
||||
this.setState((state) => {
|
||||
let client = this.clients.get(serverID);
|
||||
let updated;
|
||||
[id, updated] = State.createBuffer(state, name, serverID, client);
|
||||
return updated;
|
||||
});
|
||||
this.bufferStore.put({ name, server: client.params });
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -540,6 +542,15 @@ export default class App extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
// Restore opened user query buffers
|
||||
for (let buf of this.bufferStore.load(client.params)) {
|
||||
if (buf.name === "*" || client.isChannel(buf.name)) {
|
||||
continue;
|
||||
}
|
||||
this.createBuffer(serverID, buf.name);
|
||||
client.who(buf.name);
|
||||
}
|
||||
|
||||
let lastReceipt = this.latestReceipt(ReceiptType.READ);
|
||||
if (lastReceipt && lastReceipt.time && client.enabledCaps["draft/chathistory"] && (!client.enabledCaps["soju.im/bouncer-networks"] || client.params.bouncerNetwork)) {
|
||||
let now = irc.formatDate(new Date());
|
||||
|
@ -869,9 +880,12 @@ export default class App extends Component {
|
|||
for (let serverID of this.clients.keys()) {
|
||||
this.close({ server: serverID, name: SERVER_BUFFER });
|
||||
}
|
||||
this.bufferStore.clear();
|
||||
} else {
|
||||
this.bufferStore.clear(client.params);
|
||||
}
|
||||
|
||||
// TODO: only clear local storage if this server is stored there
|
||||
// TODO: only clear autoconnect if this server is stored there
|
||||
if (buf.server == 1) {
|
||||
store.autoconnect.put(null);
|
||||
}
|
||||
|
@ -889,6 +903,8 @@ export default class App extends Component {
|
|||
|
||||
this.receipts.delete(buf.name);
|
||||
this.saveReceipts();
|
||||
|
||||
this.bufferStore.delete({ name: buf.name, server: client.params });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue