Trying to make the SSB client webapp tolerable. Middling success. Let me set some 'about' information. Tweak what information is shown where as I experiment. Mess with the feed logic.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3714 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-12-28 20:21:23 +00:00
parent 12ab2f4b85
commit 0f7472fa22
5 changed files with 63 additions and 30 deletions

View File

@@ -150,7 +150,7 @@ function fnv32a(value)
}
async function getRecentPostIds(db, id, ids, limit) {
const k_version = 7;
const k_version = 9;
var o = await db.get(id + ':recent_posts');
var recent = [];
var f = o ? JSON.parse(o) : o;
@@ -161,14 +161,15 @@ async function getRecentPostIds(db, id, ids, limit) {
await ssb.sqlStream(
"SELECT "+
" rowid, "+
" id "+
" id, "+
" timestamp "+
"FROM messages "+
"WHERE "+
" rowid > ? AND "+
" author IN (" + ids.map(x => '?').join(", ") + ") AND "+
" json_extract(content, '$.type') IN ('post', 'tildefriends-app') "+
"UNION SELECT MAX(rowid) as rowid, NULL FROM messages "+
"ORDER BY rowid DESC LIMIT ?",
"UNION SELECT MAX(rowid) as rowid, NULL, NULL FROM messages "+
"ORDER BY timestamp DESC LIMIT ?",
[].concat([f.rowid], ids, [limit + 1]),
function(row) {
if (row.id) {
@@ -240,7 +241,7 @@ async function ready() {
return refresh();
}
core.register('onBroadcastsChanged', async function() {
ssb.addEventListener('broadcasts', async function() {
await app.postMessage({broadcasts: await ssb.getBroadcasts()});
});
@@ -270,8 +271,8 @@ async function refresh() {
}
});
roots = roots.filter(function(root) {
return root && posts.every(post => post.id != root);
});
return root && posts.every(post => post.id != root);
});
return [].concat(posts, await getPosts(db, roots));
}).then(function(posts) {
return Promise.all(posts.map(x => app.postMessage({message: x})));
@@ -321,6 +322,8 @@ core.register('message', async function(m) {
} else if (m.message.refresh) {
await refresh();
}
} else if (m.event == 'focus' || m.event == 'blur') {
/* Shh. */
} else {
print(JSON.stringify(m));
}