Fighting with load. Not what I expected to be doing.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4046 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-11-17 00:30:58 +00:00
parent dae66424dc
commit 6b267e472e
9 changed files with 42 additions and 32 deletions

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&WEvJYebSMi5d2eXgUwJJmvR/Q4slFg3zHYB8Q2mXJII=.sha256","index.md":"&Pi0NTJn9/w76yIUKqRRuSvUPSpqkxdYynmjeOBbF3K8=.sha256","todo.md":"&ehX+cfsiYWwe3Pjg2QW7Gqa5bsQTFBehJVxQnlxv+P4=.sha256","structure.md":"&T+CBfT9XP6ooKFvD1ZCI9hsutqsNIamfBxtAho0HtlU=.sha256","guide.md":"&SgnGL0+rjetY2o9A2+lVRbNvHIkqKwMnZr9gXWneIlc=.sha256","ssb.md":"&ouqT3XzTGfBNpOP/uEdOw7K1F9BeLZgQCx24XTvhyXU=.sha256"}}
{"type":"tildefriends-app","files":{"app.js":"&WEvJYebSMi5d2eXgUwJJmvR/Q4slFg3zHYB8Q2mXJII=.sha256","index.md":"&Pi0NTJn9/w76yIUKqRRuSvUPSpqkxdYynmjeOBbF3K8=.sha256","todo.md":"&2bRnINVpgmK69S8tlSQJ+d6OxbtliDOVg7CmHHxLODg=.sha256","structure.md":"&T+CBfT9XP6ooKFvD1ZCI9hsutqsNIamfBxtAho0HtlU=.sha256","guide.md":"&SgnGL0+rjetY2o9A2+lVRbNvHIkqKwMnZr9gXWneIlc=.sha256","ssb.md":"&ouqT3XzTGfBNpOP/uEdOw7K1F9BeLZgQCx24XTvhyXU=.sha256"}}

View File

@ -1,9 +1,15 @@
# Tilde Friends TODO
[Back to index](#index)
## MVP3
- Sync status (problem feeds, messages/seconds stats, ...)
- app: wiki
- app: public blog
- app: build archive
- Content-Disposition: download
## MVP2
- initial: better empty news screen
- initial: doesn't refresh when create identity
- initial: remembered wrong user across login/logout
- initial: can't switch to account when there is only one
- initial: bad experience when following nobody
@ -17,7 +23,6 @@
- fix weird HTTP warnings
- ssb from child process?
- channels
- rooms
- image downsample
- placeholder/missing images
- connections 2.0
@ -30,6 +35,9 @@
- apps name characters
## Maybe Done
- get tarball under 5MB
- rooms
- initial: doesn't refresh when create identity
- tf account timeout why
- ssb don't overflow boxes
- jwt for session tokens

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&thMY1jFZO0Tt+d2o4vD6Lb/eMGH1+25styf00AukQmI=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&TxhFekB9ov7tf/fmkAg7x5797i27oLidhgxEfDKC0T0=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&9BDffV4HY9FqhL7XI4it+UQJB4cYwbDNsY3S1cxy2vw=.sha256","tf-app.js":"&fEqRRoyD6C7oNGcveWy02XRdymmTgAVwFHvkTC1xOjU=.sha256","tf-message.js":"&GPimOaVkY0hmNYxgQAwdMX+5FoGAvg500yWie9+4SVY=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&6RQUuxB3PkOhYEJr9+89Ptx7uijczjn0r035yCcQOQQ=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&ZGWHQZPTUl4QU5++WkGwGbyj+hxhQrTg9nLmZCrl/1g=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&SSHoFxBG2DiKUbfMNxiBjxqtAccQDSAEUTSN/IN/MlY=.sha256","tf-tab-connections.js":"&b1bFPkjIo+1iSpD1V63UWqI8+4tMOY6UYozMYEVXUKI=.sha256","tf-news.js":"&/Ij0SaBTohV2myuA1gQAPlgmyq/AmmvYIhSCm3wfmow=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256","commonmark-hashtag.js":"&H+V1OLA9GDdzycKclz276zAtSZLpT3rlNVa4+qQmp4o=.sha256"}}
{"type":"tildefriends-app","files":{"app.js":"&gxOJaVf/HdjVJVC9NvZ9n3/825OD1xMMHdF/dFQwe24=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&TxhFekB9ov7tf/fmkAg7x5797i27oLidhgxEfDKC0T0=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&maN8DUFrmRxW5nsVyOAMk5k1ekcz/pfzvSS99ac3jo8=.sha256","tf-app.js":"&awronXX2Bj0j0rVE95ICTuIB2QJw1nRwrIsj4n8WSqg=.sha256","tf-message.js":"&TVoVkeqbitaYYBSjqXrQqJOtjSmBRELHL/qoHQ69Qss=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&6RQUuxB3PkOhYEJr9+89Ptx7uijczjn0r035yCcQOQQ=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&ZGWHQZPTUl4QU5++WkGwGbyj+hxhQrTg9nLmZCrl/1g=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&/0fVDyHge4x+mIVvohMTUR+deoM96NdQ7nq5HbiVfUI=.sha256","tf-tab-connections.js":"&b1bFPkjIo+1iSpD1V63UWqI8+4tMOY6UYozMYEVXUKI=.sha256","tf-news.js":"&/Ij0SaBTohV2myuA1gQAPlgmyq/AmmvYIhSCm3wfmow=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256","commonmark-hashtag.js":"&H+V1OLA9GDdzycKclz276zAtSZLpT3rlNVa4+qQmp4o=.sha256"}}

View File

@ -34,7 +34,6 @@ tfrpc.register(async function connectionSendJson(id, message) {
return ssb.connectionSendJson(id, message);
});
tfrpc.register(async function createTunnel(portal, request_number, target) {
print('createTunnel', portal, request_number, target);
let t = ssb.createTunnel(portal, request_number, target);
return t;
});

View File

@ -48,6 +48,14 @@ class TfElement extends LitElement {
self.connections = value;
}
});
this.initial_load();
}
async initial_load() {
let whoami = await tfrpc.rpc.localStorageGet('whoami');
let ids = (await tfrpc.rpc.getIdentities()) || [];
this.whoami = whoami ?? (ids.length ? ids[0] : undefined);
this.ids = ids;
}
set_hash(hash) {
@ -212,9 +220,15 @@ class TfElement extends LitElement {
}
}
_handle_whoami_changed(event) {
if (this.whoami !== event.srcElement.selected) {
this.whoami = event.srcElement.selected;
async _handle_whoami_changed(event) {
let old_id = this.whoami;
let new_id = event.srcElement.selected;
console.log('received', new_id);
if (this.whoami !== new_id) {
console.log(event);
this.whoami = new_id;
console.log(`whoami ${old_id} => ${new_id}`);
await tfrpc.rpc.localStorageSet('whoami', new_id);
}
}
@ -225,10 +239,7 @@ class TfElement extends LitElement {
}
}
async render_id_picker() {
let whoami = await tfrpc.rpc.localStorageGet('whoami');
this.ids = this.ids || (await tfrpc.rpc.getIdentities()) || [];
this.whoami = whoami ?? (this.ids.length ? this.ids[0] : undefined);
render_id_picker() {
return html`
<tf-id-picker id="picker" selected=${this.whoami} .ids=${this.ids} @change=${this._handle_whoami_changed}></tf-id-picker>
<button @click=${this.create_identity}>Create Identity</button>
@ -241,6 +252,7 @@ class TfElement extends LitElement {
users = await this.fetch_about(following.sort(), users);
this.following = following;
this.users = users;
console.log(`load finished ${whoami} => ${this.whoami}`);
this.whoami = whoami;
this.loaded = whoami;
}
@ -286,17 +298,13 @@ class TfElement extends LitElement {
let self = this;
if (!this.loading && this.whoami && this.loaded !== this.whoami) {
console.log(`starting loading ${this.whoami} ${this.loaded}`);
this.loading = true;
this.following = [];
this.users = {};
this.load().finally(function() {
self.loading = false;
});
}
let id_picker = html`
${guard([this.whoami, this.ids], () => until(this.render_id_picker(), html`<div>Loading...</div>`))}
`;
let tabs = html`
<div>
<input type="button" value="News" ?disabled=${self.tab == 'news'} @click=${() => self.set_tab('news')}></input>
@ -311,7 +319,7 @@ class TfElement extends LitElement {
html`<div>Not logged in.</div>` :
this.render_tab();
return html`
${id_picker}
${this.render_id_picker()}
${tabs}
<!-- <input type="button" value="Fake News" @click=${this.add_fake_news}></input> -->
${contents}

View File

@ -2,8 +2,7 @@ import {LitElement, html} from './lit-all.min.js';
import * as tfrpc from '/static/tfrpc.js';
/*
** Provide a list of IDs, and this lets the user pick one
** and updates local storage remembering the active identity.
** Provide a list of IDs, and this lets the user pick one.
*/
class TfIdentityPickerElement extends LitElement {
static get properties() {
@ -19,23 +18,17 @@ class TfIdentityPickerElement extends LitElement {
this.ids = [];
}
_emit_change() {
let changed_event = new Event('change', {
srcElement: this,
});
this.dispatchEvent(changed_event);
}
changed(event) {
this.selected = event.srcElement.value;
tfrpc.rpc.localStorageSet('whoami', this.selected);
this._emit_change();
this.dispatchEvent(new Event('change', {
srcElement: this,
}));
}
render() {
return html`
<select @change=${this.changed} style="max-width: 100%">
${this.ids.map(id => html`<option ?selected=${id == this.selected}>${id}</option>`)}
${(this.ids ?? []).map(id => html`<option ?selected=${id == this.selected} value=${id}>${id}</option>`)}
</select>
`;
}

View File

@ -250,6 +250,7 @@ class TfMessageElement extends LitElement {
img {
max-width: 100%;
height: auto;
display: block;
}
</style>
<div style="border: 1px solid black; background-color: rgba(255, 255, 255, 0.1); margin-top: 8px; padding: 16px">

View File

@ -85,13 +85,14 @@ class TfTabNewsFeedElement extends LitElement {
if (!this.messages ||
this._messages_hash !== this.hash ||
this._messages_following !== this.following) {
console.log('loading messages');
console.log(`loading messages for ${this.whoami}`);
let self = this;
this.messages = [];
this._messages_hash = this.hash;
this._messages_following = this.following;
this.fetch_messages().then(function(messages) {
self.messages = messages;
console.log(`loading mesages done for ${self.whoami}`);
}).catch(function(error) {
alert(JSON.stringify(error, null, 2));
});

View File

@ -222,7 +222,7 @@ function handler(request, response) {
});
}
} else if (request.uri == "/login/logout") {
response.writeHead(303, {"Set-Cookie": "session=; path=/; secure; SameSite=Strict; expires=Thu, 01 Jan 1970 00:00:00 GMT", "Location": "/login" + (request.query ? "?" + request.query : "")});
response.writeHead(303, {"Set-Cookie": "session=; path=/; Secure; SameSite=Strict; expires=Thu, 01 Jan 1970 00:00:00 GMT", "Location": "/login" + (request.query ? "?" + request.query : "")});
response.end();
} else {
response.writeHead(200, {"Content-Type": "text/plain; charset=utf-8", "Connection": "close"});