ssb: Show sync/stay connected options on the sidebar when relevant.

This commit is contained in:
2025-07-02 12:41:03 -04:00
parent db115ef1bd
commit 6e55b6b49e
3 changed files with 37 additions and 6 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🦀", "emoji": "🦀",
"previous": "&9egAArMLNHQzp1yniwnxD41e4T7qXWAfLNJdH4LrXS8=.sha256" "previous": "&Eg9WyDY1CmakDJYw0+fk0PDW1EOW3gS/Np10dAJZM7c=.sha256"
} }

View File

@ -601,9 +601,13 @@ class TfElement extends LitElement {
.channels_latest=${this.channels_latest} .channels_latest=${this.channels_latest}
.channels_unread=${this.channels_unread} .channels_unread=${this.channels_unread}
@channelsetunread=${this.channel_set_unread} @channelsetunread=${this.channel_set_unread}
@refresh=${this.refresh}
@toggle_stay_connected=${this.toggle_stay_connected}
.connections=${this.connections} .connections=${this.connections}
.private_messages=${this.private_messages} .private_messages=${this.private_messages}
.recent_reactions=${this.recent_reactions} .recent_reactions=${this.recent_reactions}
?is_administrator=${this.is_administrator}
?stay_connected=${this.stay_connected}
></tf-tab-news> ></tf-tab-news>
`; `;
} else if (this.tab === 'connections') { } else if (this.tab === 'connections') {

View File

@ -26,6 +26,8 @@ class TfTabNewsElement extends LitElement {
private_messages: {type: Array}, private_messages: {type: Array},
recent_reactions: {type: Array}, recent_reactions: {type: Array},
peer_exchange: {type: Boolean}, peer_exchange: {type: Boolean},
is_administrator: {type: Boolean},
stay_connected: {type: Boolean},
}; };
} }
@ -174,10 +176,6 @@ class TfTabNewsElement extends LitElement {
.map((x) => x[0]); .map((x) => x[0]);
} }
refresh() {
tfrpc.rpc.sync();
}
async enable_peer_exchange() { async enable_peer_exchange() {
await tfrpc.rpc.globalSettingsSet('peer_exchange', true); await tfrpc.rpc.globalSettingsSet('peer_exchange', true);
await this.check_peer_exchange(); await this.check_peer_exchange();
@ -196,6 +194,32 @@ class TfTabNewsElement extends LitElement {
> >
&times; &times;
</div> </div>
${this.is_administrator
? html`
<button
class="w3-bar-item w3-button"
@click=${() =>
this.dispatchEvent(
new Event('refresh', {bubbles: true, composed: true})
)}
>
<span style="width: 1.5em; height: 1.5em; padding: 8px">↻</span>
Sync now
</button>
<button
class="w3-bar-item w3-button w3-ripple"
@click=${() =>
this.dispatchEvent(
new Event('toggle_stay_connected', {
bubbles: true,
composed: true,
})
)}
>
${this.stay_connected ? '🔗 Online mode' : '⛓️‍💥 Passive mode'}
</button>
`
: undefined}
${this.hash.startsWith('##') && ${this.hash.startsWith('##') &&
this.channels.indexOf(this.hash.substring(2)) == -1 this.channels.indexOf(this.hash.substring(2)) == -1
? html` ? html`
@ -266,7 +290,10 @@ class TfTabNewsElement extends LitElement {
(this.connections?.some((x) => x.flags.one_shot) (this.connections?.some((x) => x.flags.one_shot)
? ' w3-spin' ? ' w3-spin'
: '')} : '')}
@click=${this.refresh} @click=${() =>
this.dispatchEvent(
new Event('refresh', {bubbles: true, composed: true})
)}
> >
↻ Sync now ↻ Sync now
</button> </button>