Module-ified the ssb app and started to integrate tfrpc.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3911 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-06-19 22:08:15 +00:00
parent af3e96c7e8
commit ab58f42f0c
8 changed files with 59 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
"use strict";
import * as tfrpc from '/tfrpc.js';
const k_posts_max = 40;
const k_votes_max = 20;
@@ -393,10 +393,17 @@ async function getPosts(db, ids) {
return posts;
}
async function ready() {
tfrpc.register(async function ready() {
g_ready = true;
return refresh(g_selected);
}
});
tfrpc.register(async function store_blob(blob) {
if (Array.isArray(blob)) {
blob = Uint8Array.from(blob);
}
return await ssb.blobStore(blob);
});
ssb.addEventListener('broadcasts', async function() {
await app.postMessage({broadcasts: await ssb.getBroadcasts()});
@@ -568,9 +575,7 @@ async function addAppSources(message) {
}
core.register('message', async function(m) {
if (m.message == 'ready') {
await ready();
} else if (m.message) {
if (m.message) {
if (m.message.connect) {
await ssb.connect(m.message.connect);
} else if (m.message.appendMessage) {