Primitive display of recent channels/tags and the same on messages.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4329 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-06-22 00:27:27 +00:00
parent f018c367ed
commit 6022001d66
5 changed files with 62 additions and 7 deletions

View File

@ -16,6 +16,7 @@ class TfElement extends LitElement {
following: {type: Array},
users: {type: Object},
ids: {type: Array},
tags: {type: Array},
};
}
@ -32,6 +33,7 @@ class TfElement extends LitElement {
this.following = [];
this.users = {};
this.loaded = false;
this.tags = [];
tfrpc.rpc.getBroadcasts().then(b => { self.broadcasts = b || []; });
tfrpc.rpc.getConnections().then(c => { self.connections = c || []; });
tfrpc.rpc.getHash().then(hash => self.set_hash(hash));
@ -253,12 +255,24 @@ class TfElement extends LitElement {
`;
}
async load_recent_tags() {
this.tags = await tfrpc.rpc.query(`
WITH recent AS (SELECT '#' || json_extract(content, '$.channel') AS tag
FROM messages
WHERE json_extract(content, '$.channel') IS NOT NULL
ORDER BY timestamp DESC LIMIT 100)
SELECT tag, COUNT(*) AS count FROM recent GROUP BY tag ORDER BY count DESC LIMIT 10
`, []);
}
async load() {
let whoami = this.whoami;
let tags = this.load_recent_tags();
let [following, users] = await this.following_deep([whoami], 2, {});
users = await this.fetch_about(following.sort(), users);
this.following = following;
this.users = users;
await tags;
console.log(`load finished ${whoami} => ${this.whoami}`);
this.whoami = whoami;
this.loaded = whoami;
@ -325,6 +339,7 @@ class TfElement extends LitElement {
return html`
${this.render_id_picker()}
${tabs}
${this.tags.map(x => html`<tf-tag tag=${x.tag} count=${x.count}></tf-tag>`)}
${contents}
`;
}