Make the ssb app use the global identity picker.

This commit is contained in:
2024-04-13 19:52:40 -04:00
parent 28d08e013f
commit 8007e71e1d
6 changed files with 37 additions and 81 deletions

View File

@ -52,13 +52,15 @@ class TfElement extends LitElement {
self.broadcasts = value;
} else if (name === 'connections') {
self.connections = value;
} else if (name === 'identity') {
self.whoami = value;
}
});
this.initial_load();
}
async initial_load() {
let whoami = await tfrpc.rpc.localStorageGet('whoami');
let whoami = await tfrpc.rpc.getActiveIdentity();
let ids = (await tfrpc.rpc.getIdentities()) || [];
this.whoami = whoami ?? (ids.length ? ids[0] : undefined);
this.ids = ids;
@ -193,29 +195,6 @@ class TfElement extends LitElement {
}
}
render_id_picker() {
return html`
<div style="display: flex; gap: 8px">
<tf-id-picker
id="picker"
style="flex: 1 1 auto"
selected=${this.whoami}
.ids=${this.ids}
.users=${this.users}
@change=${this._handle_whoami_changed}
></tf-id-picker>
<button
class="w3-button w3-theme-d1 w3-border"
style="flex: 0 0 auto"
@click=${this.create_identity}
id="create_identity"
>
Create Identity
</button>
</div>
`;
}
async load_recent_tags() {
let start = new Date();
this.tags = await tfrpc.rpc.query(
@ -380,7 +359,7 @@ class TfElement extends LitElement {
class="w3-theme-dark"
>
<div style="padding: 8px">
${this.render_id_picker()} ${tabs}
${tabs}
${this.tags.map(
(x) => html`<tf-tag tag=${x.tag} count=${x.count}></tf-tag>`
)}