ssb: Only admins are offered the option to enable peer exchange.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m49s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m49s
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&M+oVNf65iZ1xz3Lzmq0k86SmIhRSX2q2SV4K9/dib1U=.sha256"
|
"previous": "&6gubt0zYLPpQepw+Cg/coZNek8Eem/BmHRP1G39IZcc=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,9 @@ tfrpc.register(async function globalSettingsGet(key) {
|
|||||||
tfrpc.register(async function globalSettingsSet(key, value) {
|
tfrpc.register(async function globalSettingsSet(key, value) {
|
||||||
return core.globalSettingsSet(key, value);
|
return core.globalSettingsSet(key, value);
|
||||||
});
|
});
|
||||||
|
tfrpc.register(function isAdministrator() {
|
||||||
|
return core.user?.credentials?.permissions?.administration;
|
||||||
|
});
|
||||||
|
|
||||||
core.register('onBroadcastsChanged', async function () {
|
core.register('onBroadcastsChanged', async function () {
|
||||||
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
|
||||||
|
@ -49,9 +49,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
tfrpc.rpc.localStorageGet('drafts').then(function (d) {
|
tfrpc.rpc.localStorageGet('drafts').then(function (d) {
|
||||||
self.drafts = JSON.parse(d || '{}');
|
self.drafts = JSON.parse(d || '{}');
|
||||||
});
|
});
|
||||||
tfrpc.rpc.globalSettingsGet('peer_exchange').then(function (value) {
|
this.check_peer_exchange();
|
||||||
self.peer_exchange = value;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
@ -64,6 +62,14 @@ class TfTabNewsElement extends LitElement {
|
|||||||
document.body.removeEventListener('keypress', this.on_keypress.bind(this));
|
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() {
|
load_latest() {
|
||||||
let news = this.shadowRoot?.getElementById('news');
|
let news = this.shadowRoot?.getElementById('news');
|
||||||
if (news) {
|
if (news) {
|
||||||
@ -174,7 +180,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
|
|
||||||
async enable_peer_exchange() {
|
async enable_peer_exchange() {
|
||||||
await tfrpc.rpc.globalSettingsSet('peer_exchange', true);
|
await tfrpc.rpc.globalSettingsSet('peer_exchange', true);
|
||||||
this.peer_exchange = await tfrpc.rpc.globalSettingsGet('peer_exchange');
|
await this.check_peer_exchange();
|
||||||
}
|
}
|
||||||
|
|
||||||
render_sidebar() {
|
render_sidebar() {
|
||||||
@ -266,7 +272,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class=${'w3-bar-item w3-button' +
|
class=${'w3-bar-item w3-button' +
|
||||||
(this.peer_exchange ? ' w3-hide' : '')}
|
(this.peer_exchange !== false ? ' w3-hide' : '')}
|
||||||
@click=${this.enable_peer_exchange}
|
@click=${this.enable_peer_exchange}
|
||||||
>
|
>
|
||||||
Enable peer exchange
|
Enable peer exchange
|
||||||
|
Reference in New Issue
Block a user