From 6b267e472ef016b1ab73feb54f506bd679bb2b36 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 17 Nov 2022 00:30:58 +0000 Subject: [PATCH] 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 --- apps/cory/docs.json | 2 +- apps/cory/docs/todo.md | 12 +++++++++-- apps/cory/ssblit.json | 2 +- apps/cory/ssblit/app.js | 1 - apps/cory/ssblit/tf-app.js | 34 ++++++++++++++++++++------------ apps/cory/ssblit/tf-id-picker.js | 17 +++++----------- apps/cory/ssblit/tf-message.js | 1 + apps/cory/ssblit/tf-tab-news.js | 3 ++- core/auth.js | 2 +- 9 files changed, 42 insertions(+), 32 deletions(-) diff --git a/apps/cory/docs.json b/apps/cory/docs.json index 9c6a4e62..5fc37812 100644 --- a/apps/cory/docs.json +++ b/apps/cory/docs.json @@ -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"}} \ No newline at end of file +{"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"}} \ No newline at end of file diff --git a/apps/cory/docs/todo.md b/apps/cory/docs/todo.md index 8b627f8d..bf0b7688 100644 --- a/apps/cory/docs/todo.md +++ b/apps/cory/docs/todo.md @@ -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 diff --git a/apps/cory/ssblit.json b/apps/cory/ssblit.json index 44e597e9..e9e22846 100644 --- a/apps/cory/ssblit.json +++ b/apps/cory/ssblit.json @@ -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"}} \ No newline at end of file +{"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"}} \ No newline at end of file diff --git a/apps/cory/ssblit/app.js b/apps/cory/ssblit/app.js index 555d8b91..7a1ab57b 100644 --- a/apps/cory/ssblit/app.js +++ b/apps/cory/ssblit/app.js @@ -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; }); diff --git a/apps/cory/ssblit/tf-app.js b/apps/cory/ssblit/tf-app.js index 482f54e8..7c4c31de 100644 --- a/apps/cory/ssblit/tf-app.js +++ b/apps/cory/ssblit/tf-app.js @@ -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` @@ -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`
Loading...
`))} - `; let tabs = html`
self.set_tab('news')}> @@ -311,7 +319,7 @@ class TfElement extends LitElement { html`
Not logged in.
` : this.render_tab(); return html` - ${id_picker} + ${this.render_id_picker()} ${tabs} ${contents} diff --git a/apps/cory/ssblit/tf-id-picker.js b/apps/cory/ssblit/tf-id-picker.js index e297641d..953093b8 100644 --- a/apps/cory/ssblit/tf-id-picker.js +++ b/apps/cory/ssblit/tf-id-picker.js @@ -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` `; } diff --git a/apps/cory/ssblit/tf-message.js b/apps/cory/ssblit/tf-message.js index 97ba69b4..b22b3a21 100644 --- a/apps/cory/ssblit/tf-message.js +++ b/apps/cory/ssblit/tf-message.js @@ -250,6 +250,7 @@ class TfMessageElement extends LitElement { img { max-width: 100%; height: auto; + display: block; }
diff --git a/apps/cory/ssblit/tf-tab-news.js b/apps/cory/ssblit/tf-tab-news.js index 4c14c871..a369fcb0 100644 --- a/apps/cory/ssblit/tf-tab-news.js +++ b/apps/cory/ssblit/tf-tab-news.js @@ -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)); }); diff --git a/core/auth.js b/core/auth.js index 3502f242..28859d4b 100644 --- a/core/auth.js +++ b/core/auth.js @@ -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"});