forked from cory/tildefriends
Fix some obvious things now that the RPC is slightly better.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3957 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -396,9 +396,10 @@ async function getPosts(db, ids) {
|
||||
|
||||
tfrpc.register(async function ready() {
|
||||
let identities = await ssb.getIdentities();
|
||||
let whoami = await app.localStorageGet('whoami');
|
||||
await tfrpc.rpc.set_identities(identities);
|
||||
g_ready = true;
|
||||
refresh_internal(g_whoami, g_selected, true);
|
||||
refresh_internal(whoami, g_selected, true);
|
||||
});
|
||||
|
||||
tfrpc.register(async function store_blob(blob) {
|
||||
@ -442,11 +443,10 @@ async function updateSequences(db) {
|
||||
}
|
||||
|
||||
async function refresh_internal(whoami, selected, force) {
|
||||
if (!g_ready) {
|
||||
return;
|
||||
}
|
||||
let hash = selected || undefined;
|
||||
if (whoami !== g_whoami || selected !== g_selected || force) {
|
||||
if (g_whoami !== whoami && whoami) {
|
||||
await app.localStorageSet('whoami', whoami);
|
||||
}
|
||||
g_whoami = whoami;
|
||||
g_selected = selected;
|
||||
} else {
|
||||
@ -455,12 +455,16 @@ async function refresh_internal(whoami, selected, force) {
|
||||
if (typeof(whoami) !== 'string') {
|
||||
return;
|
||||
}
|
||||
if (!g_ready) {
|
||||
return;
|
||||
}
|
||||
var timing = [];
|
||||
timing.push({name: 'start', time: new Date()});
|
||||
g_following_cache = {};
|
||||
g_following_deep_cache = {};
|
||||
await tfrpc.rpc.clear();
|
||||
await tfrpc.rpc.set_identities(await ssb.getIdentities());
|
||||
await tfrpc.rpc.set('selected', selected);
|
||||
var db = await database("ssb");
|
||||
g_sequence = {};
|
||||
try {
|
||||
@ -598,13 +602,8 @@ core.register('message', async function(m) {
|
||||
}
|
||||
} else if (m.event == 'hashChange') {
|
||||
let hash = m.hash.length > 1 ? m.hash.substring(1) : null;
|
||||
if (hash) {
|
||||
let parts = hash.split(':');
|
||||
let changed = g_whoami !== parts[0] || g_selected !== parts[1];
|
||||
g_whoami = parts[0];
|
||||
g_selected = parts[1];
|
||||
await refresh_internal(g_whoami, g_selected, changed);
|
||||
}
|
||||
let changed = g_selected !== hash;
|
||||
await refresh_internal(g_whoami, hash, changed);
|
||||
} else if (m.event == 'focus' || m.event == 'blur') {
|
||||
/* Shh. */
|
||||
} else {
|
||||
|
@ -110,7 +110,7 @@
|
||||
</md-card-actions>
|
||||
</md-card>
|
||||
|
||||
<md-button v-if="selected?.length" class="md-raised md-primary" style="margin: 1em" @click="selected = null">
|
||||
<md-button v-if="selected !== undefined" class="md-raised md-primary" style="margin: 1em" @click="selected = null">
|
||||
<md-icon>home</md-icon> Home
|
||||
</md-button>
|
||||
|
||||
|
@ -67,7 +67,7 @@ Vue.component('tf-message', {
|
||||
show_message: function() {
|
||||
window.parent.postMessage({
|
||||
action: 'setHash',
|
||||
hash: tf.g_data.whoami + ':' + this.message.id,
|
||||
hash: this.message.id,
|
||||
}, '*');
|
||||
},
|
||||
expand_image: function(event) {
|
||||
@ -89,7 +89,12 @@ Vue.component('tf-message', {
|
||||
img.style.objectFit = 'contain';
|
||||
img.style.width = '100%';
|
||||
div.appendChild(img);
|
||||
div.onclick = function() { document.body.removeChild(div); };
|
||||
function image_close(event) {
|
||||
document.body.removeChild(div);
|
||||
window.removeEventListener('keydown', image_close);
|
||||
}
|
||||
div.onclick = image_close;
|
||||
window.addEventListener('keydown', image_close);
|
||||
document.body.appendChild(div);
|
||||
},
|
||||
},
|
||||
|
@ -1,3 +1,5 @@
|
||||
import * as tf from './tf.js';
|
||||
|
||||
export function markdown(md) {
|
||||
var reader = new commonmark.Parser({safe: true});
|
||||
var writer = new commonmark.HtmlRenderer();
|
||||
|
@ -15,12 +15,12 @@ Vue.component('tf-user', {
|
||||
show_user: function() {
|
||||
window.parent.postMessage({
|
||||
action: 'setHash',
|
||||
hash: tf.g_data.whoami + ':' + this.id,
|
||||
hash: this.id,
|
||||
}, '*');
|
||||
},
|
||||
},
|
||||
template: `<md-chip :class="following ? 'md-accent' : ''">
|
||||
<a :href="'#' + whoami + ':' + id" style="color: #fff">{{users[id] && users[id].name ? users[id].name : id}}</a>
|
||||
<a :href="'#' + id" style="color: #fff">{{users[id] && users[id].name ? users[id].name : id}}</a>
|
||||
<md-tooltip v-if="users[id] && users[id].name">{{id}}</md-tooltip>
|
||||
</md-chip>`,
|
||||
});
|
@ -262,9 +262,7 @@ window.addEventListener('load', function() {
|
||||
}
|
||||
},
|
||||
set_hash() {
|
||||
let hash = this.whoami && this.selected ?
|
||||
this.whoami + ':' + this.selected :
|
||||
(this.whoami ? this.whoami : '#');
|
||||
let hash = this.selected ?? '#';
|
||||
window.parent.postMessage({
|
||||
action: 'setHash',
|
||||
hash: hash,
|
||||
|
Reference in New Issue
Block a user