Make the id picker refresh when you create an identity.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4029 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-11-10 00:03:39 +00:00
parent ae545e7b2b
commit 5ed9a77d38
5 changed files with 15 additions and 12 deletions

View File

@ -15,6 +15,7 @@ class TfElement extends LitElement {
loaded: {type: Boolean},
following: {type: Array},
users: {type: Object},
ids: {type: Array},
};
}
@ -125,7 +126,6 @@ class TfElement extends LitElement {
let result = await this.following_deep_internal(ids, depth, blocking, cache.last_row_id, cache.following, max_row_id);
cache.last_row_id = max_row_id;
await tfrpc.rpc.databaseSet('following', JSON.stringify(cache));
console.log(cache);
return [result, cache.following];
}
@ -222,14 +222,14 @@ class TfElement extends LitElement {
async create_identity() {
if (confirm("Are you sure you want to create a new identity?")) {
await tfrpc.rpc.createIdentity();
this.requestUpdate();
this.ids = (await tfrpc.rpc.getIdentities()) || [];
}
}
async render_id_picker() {
this._ids = this._ids || (await tfrpc.rpc.getIdentities()) || [];
this.ids = this.ids || (await tfrpc.rpc.getIdentities()) || [];
return html`
<tf-id-picker id="picker" selected=${this.whoami} .ids=${this._ids} @change=${this._handle_whoami_changed}></tf-id-picker>
<tf-id-picker id="picker" selected=${this.whoami} .ids=${this.ids} @change=${this._handle_whoami_changed}></tf-id-picker>
<button @click=${this.create_identity}>Create Identity</button>
`;
}
@ -285,18 +285,16 @@ class TfElement extends LitElement {
let self = this;
if (!this.loading && this.whoami && this.loaded !== this.whoami) {
console.log('loading', this.whoami);
this.loading = true;
this.following = [];
this.users = {};
this.load().finally(function() {
self.loading = false;
console.log('loaded');
});
}
let id_picker = html`
${guard([this.whoami], () => until(this.render_id_picker(), html`<div>Loading...</div>`))}
${guard([this.whoami, this.ids], () => until(this.render_id_picker(), html`<div>Loading...</div>`))}
`;
let tabs = html`
<div>