ssb: Don't show 'Loading...' forever in the ssb app when not signed in. Direct to the login page.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 26m50s

This commit is contained in:
Cory McWilliams 2025-01-05 12:52:52 -05:00
parent 61ad405ad8
commit d1b7681efc
3 changed files with 19 additions and 2 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
"previous": "&pkSGa9BIj2iuPuR8xMQQWQpZk6htin+m8y2m7VTDgG4=.sha256"
"previous": "&20LHLqRX51iuC74SlJ+u76sH9cyptDyuR3/bkqE4yhA=.sha256"
}

View File

@ -106,6 +106,10 @@ tfrpc.register(async function getActiveIdentity() {
tfrpc.register(async function sync() {
return await ssb.sync();
});
tfrpc.register(async function url() {
return core.url;
});
core.register('onBroadcastsChanged', async function () {
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
});

View File

@ -18,6 +18,8 @@ class TfElement extends LitElement {
channels: {type: Array},
channels_unread: {type: Object},
channels_latest: {type: Object},
guest: {type: Boolean},
url: {type: String},
};
}
@ -66,7 +68,9 @@ class TfElement extends LitElement {
async initial_load() {
let whoami = await tfrpc.rpc.getActiveIdentity();
let ids = (await tfrpc.rpc.getIdentities()) || [];
this.url = await tfrpc.rpc.url();
this.whoami = whoami ?? (ids.length ? ids[0] : undefined);
this.guest = !this.whoami?.length;
this.ids = ids;
await this.load_channels();
}
@ -590,7 +594,16 @@ class TfElement extends LitElement {
</div>
`;
let contents =
!this.loaded || this.loading
this.guest ?
html`<div
class="w3-display-middle w3-panel w3-theme-l5 w3-card-4 w3-padding-large w3-round-xlarge w3-xlarge w3-container"
>
<p>🦀 Must be logged in to Tilde Friends to scuttle here. 🦀</p>
<footer class="w3-center">
<a class="w3-button w3-theme-d1" href=${`/login?return=${encodeURIComponent(this.url)}`}>Login</a>
</footer>
</div>`
: !this.loaded || this.loading
? html`<div
class="w3-display-middle w3-panel w3-theme-l5 w3-card-4 w3-padding-large w3-round-xlarge w3-xlarge"
>