forked from cory/tildefriends
Redid lots of things about viewing an invidual user's feed, their profile, and following users.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3740 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const k_posts_max = 20;
|
||||
const k_votes_max = 20;
|
||||
|
||||
var g_ready = false;
|
||||
var g_selected = null;
|
||||
|
||||
var g_following_cache = {};
|
||||
@@ -240,6 +241,7 @@ async function getPosts(db, ids) {
|
||||
}
|
||||
|
||||
async function ready() {
|
||||
g_ready = true;
|
||||
return refresh(g_selected);
|
||||
}
|
||||
|
||||
@@ -267,6 +269,7 @@ async function refresh(selected) {
|
||||
}
|
||||
await Promise.all([
|
||||
app.postMessage({whoami: whoami}),
|
||||
app.postMessage({hash: selected && selected.length == 1 ? selected[0] : null}),
|
||||
ssb.getBroadcasts().then(broadcasts => app.postMessage({broadcasts: broadcasts})),
|
||||
ssb.connections().then(connections => app.postMessage({connections: connections})),
|
||||
core.apps().then(apps => app.postMessage({apps: apps})),
|
||||
@@ -293,6 +296,7 @@ async function refresh(selected) {
|
||||
];
|
||||
}))),
|
||||
]);
|
||||
await app.postMessage({ready: true});
|
||||
}
|
||||
|
||||
ssb.addEventListener('message', async function(id) {
|
||||
@@ -308,7 +312,6 @@ ssb.addEventListener('message', async function(id) {
|
||||
});
|
||||
|
||||
core.register('message', async function(m) {
|
||||
print(JSON.stringify(m));
|
||||
if (m.message == 'ready') {
|
||||
await ready();
|
||||
} else if (m.message) {
|
||||
@@ -321,9 +324,12 @@ core.register('message', async function(m) {
|
||||
}
|
||||
} else if (m.event == 'hashChange') {
|
||||
if (m.hash.length > 1) {
|
||||
refresh([m.hash.substring(1)]);
|
||||
g_selected = [m.hash.substring(1)];
|
||||
} else {
|
||||
refresh();
|
||||
g_selected = null;
|
||||
}
|
||||
if (g_ready) {
|
||||
await refresh(g_selected);
|
||||
}
|
||||
} else if (m.event == 'focus' || m.event == 'blur') {
|
||||
/* Shh. */
|
||||
|
Reference in New Issue
Block a user