ssb: Only admins are offered the option to enable peer exchange.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m49s

This commit is contained in:
2025-06-14 20:27:19 -04:00
parent cadc27b7b5
commit e54312d3b8
3 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
"previous": "&M+oVNf65iZ1xz3Lzmq0k86SmIhRSX2q2SV4K9/dib1U=.sha256"
"previous": "&6gubt0zYLPpQepw+Cg/coZNek8Eem/BmHRP1G39IZcc=.sha256"
}

View File

@ -112,6 +112,9 @@ tfrpc.register(async function globalSettingsGet(key) {
tfrpc.register(async function globalSettingsSet(key, value) {
return core.globalSettingsSet(key, value);
});
tfrpc.register(function isAdministrator() {
return core.user?.credentials?.permissions?.administration;
});
core.register('onBroadcastsChanged', async function () {
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());

View File

@ -49,9 +49,7 @@ class TfTabNewsElement extends LitElement {
tfrpc.rpc.localStorageGet('drafts').then(function (d) {
self.drafts = JSON.parse(d || '{}');
});
tfrpc.rpc.globalSettingsGet('peer_exchange').then(function (value) {
self.peer_exchange = value;
});
this.check_peer_exchange();
}
connectedCallback() {
@ -64,6 +62,14 @@ class TfTabNewsElement extends LitElement {
document.body.removeEventListener('keypress', this.on_keypress.bind(this));
}
async check_peer_exchange() {
if (await tfrpc.rpc.isAdministrator()) {
this.peer_exchange = await tfrpc.rpc.globalSettingsGet('peer_exchange');
} else {
this.peer_exchange = undefined;
}
}
load_latest() {
let news = this.shadowRoot?.getElementById('news');
if (news) {
@ -174,7 +180,7 @@ class TfTabNewsElement extends LitElement {
async enable_peer_exchange() {
await tfrpc.rpc.globalSettingsSet('peer_exchange', true);
this.peer_exchange = await tfrpc.rpc.globalSettingsGet('peer_exchange');
await this.check_peer_exchange();
}
render_sidebar() {
@ -266,7 +272,7 @@ class TfTabNewsElement extends LitElement {
</button>
<button
class=${'w3-bar-item w3-button' +
(this.peer_exchange ? ' w3-hide' : '')}
(this.peer_exchange !== false ? ' w3-hide' : '')}
@click=${this.enable_peer_exchange}
>
Enable peer exchange