ssb: Get recent reactions up front so that we don't need to delay showing the dialog for them.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m33s

This commit is contained in:
2025-04-29 20:48:47 -04:00
parent 9d3a07c1cf
commit 2597f99ccf
7 changed files with 35 additions and 18 deletions

View File

@ -21,6 +21,7 @@ class TfElement extends LitElement {
guest: {type: Boolean},
url: {type: String},
private_messages: {type: Array},
recent_reactions: {type: Array},
};
}
@ -41,6 +42,7 @@ class TfElement extends LitElement {
this.channels_latest = {};
this.loading_latest = 0;
this.loading_latest_scheduled = 0;
this.recent_reactions = [];
tfrpc.rpc.getBroadcasts().then((b) => {
self.broadcasts = b || [];
});
@ -452,6 +454,19 @@ class TfElement extends LitElement {
return users;
}
async load_recent_reactions() {
this.recent_reactions = (await tfrpc.rpc.query(
`
SELECT DISTINCT content ->> '$.vote.expression' AS value
FROM messages
WHERE author = ? AND
content ->> '$.type' = 'vote'
ORDER BY timestamp DESC LIMIT 10
`,
[this.whoami]
)).map((x) => x.value);
}
async load() {
this.loading_latest = true;
try {
@ -469,6 +484,7 @@ class TfElement extends LitElement {
};
by_count.push({count: v.of, id: id});
}
let reactions = this.load_recent_reactions();
this.load_channels_latest(Object.keys(following));
this.channels_unread = JSON.parse(
(await tfrpc.rpc.databaseGet('unread')) ?? '{}'
@ -494,6 +510,7 @@ class TfElement extends LitElement {
console.log(
`load finished ${whoami} => ${this.whoami} in ${(new Date() - start_time) / 1000}`
);
await reactions;
this.whoami = whoami;
this.loaded = whoami;
} finally {
@ -551,6 +568,7 @@ class TfElement extends LitElement {
@channelsetunread=${this.channel_set_unread}
.connections=${this.connections}
.private_messages=${this.private_messages}
.recent_reactions=${this.recent_reactions}
></tf-tab-news>
`;
} else if (this.tab === 'connections') {