ssb: Proof of concept to try to stay connected to a handful of peers. #130
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 37m27s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 37m27s
This commit is contained in:
@ -23,6 +23,8 @@ class TfElement extends LitElement {
|
||||
url: {type: String},
|
||||
private_messages: {type: Array},
|
||||
recent_reactions: {type: Array},
|
||||
is_administrator: {type: Boolean},
|
||||
stay_connected: {type: Boolean},
|
||||
};
|
||||
}
|
||||
|
||||
@ -73,6 +75,10 @@ class TfElement extends LitElement {
|
||||
async initial_load() {
|
||||
let whoami = await tfrpc.rpc.getActiveIdentity();
|
||||
let ids = (await tfrpc.rpc.getIdentities()) || [];
|
||||
this.is_administrator = await tfrpc.rpc.isAdministrator();
|
||||
this.stay_connected =
|
||||
this.is_administrator &&
|
||||
(await tfrpc.rpc.globalSettingsGet('stay_connected'));
|
||||
this.url = await tfrpc.rpc.url();
|
||||
this.whoami = whoami ?? (ids.length ? ids[0] : undefined);
|
||||
this.guest = !this.whoami?.length;
|
||||
@ -658,6 +664,18 @@ class TfElement extends LitElement {
|
||||
tfrpc.rpc.sync();
|
||||
}
|
||||
|
||||
async toggle_stay_connected() {
|
||||
let stay_connected = await tfrpc.rpc.globalSettingsGet('stay_connected');
|
||||
let new_stay_connected = !this.stay_connected;
|
||||
try {
|
||||
if (new_stay_connected != stay_connected) {
|
||||
await tfrpc.rpc.globalSettingsSet('stay_connected', new_stay_connected);
|
||||
}
|
||||
} finally {
|
||||
this.stay_connected = await tfrpc.rpc.globalSettingsGet('stay_connected');
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let self = this;
|
||||
|
||||
@ -680,14 +698,26 @@ class TfElement extends LitElement {
|
||||
class="w3-bar w3-theme-l1"
|
||||
style="position: static; top: 0; z-index: 10"
|
||||
>
|
||||
<button
|
||||
class=${'w3-bar-item w3-button w3-circle w3-ripple' +
|
||||
(this.connections?.some((x) => x.flags.one_shot) ? ' w3-spin' : '')}
|
||||
style="width: 1.5em; height: 1.5em; padding: 8px"
|
||||
@click=${this.refresh}
|
||||
>
|
||||
↻
|
||||
</button>
|
||||
${this.is_administrator
|
||||
? html`
|
||||
<button
|
||||
class=${'w3-bar-item w3-button w3-circle w3-ripple' +
|
||||
(this.connections?.some((x) => x.flags.one_shot)
|
||||
? ' w3-spin'
|
||||
: '')}
|
||||
style="width: 1.5em; height: 1.5em; padding: 8px"
|
||||
@click=${this.refresh}
|
||||
>
|
||||
↻
|
||||
</button>
|
||||
<button
|
||||
class="w3-bar-item w3-button w3-ripple"
|
||||
@click=${this.toggle_stay_connected}
|
||||
>
|
||||
${this.stay_connected ? '🔗' : '⛓️💥'}
|
||||
</button>
|
||||
`
|
||||
: undefined}
|
||||
${Object.entries(k_tabs).map(
|
||||
([k, v]) => html`
|
||||
<button
|
||||
|
@ -686,7 +686,11 @@ class TfMessageElement extends LitElement {
|
||||
${x.action}
|
||||
${x.users.map(
|
||||
(y) => html`
|
||||
<tf-user id=${y} .users=${this.users} icon_only=true></tf-user>
|
||||
<tf-user
|
||||
id=${y}
|
||||
.users=${this.users}
|
||||
icon_only="true"
|
||||
></tf-user>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user