Fixed some problems linking messages with their threads in the UI.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3811 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-02-01 01:47:18 +00:00
parent bf7d5c34f6
commit c57b0a2f2f
4 changed files with 40 additions and 33 deletions

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&WCq6ssQedT5denXPXlz2BswPD6hmt++EmWIMIDUMurA=.sha256","index.md":"&5EeOHUkDadC+lJsDsKXbfrVDQdePyOHZ7KwaJtR5mrs=.sha256","todo.md":"&U6hrQ6cfJ6+Uvg+wA7ahpCQaM2XiYXKjZUOz2iZDSGM=.sha256","structure.md":"&T+CBfT9XP6ooKFvD1ZCI9hsutqsNIamfBxtAho0HtlU=.sha256","guide.md":"&SgnGL0+rjetY2o9A2+lVRbNvHIkqKwMnZr9gXWneIlc=.sha256","id_refactor.md":"&RCGnByvk25SuPQ5wywVwgOhAFIxOeoUm17sD24XSSZw=.sha256"}} {"type":"tildefriends-app","files":{"app.js":"&WCq6ssQedT5denXPXlz2BswPD6hmt++EmWIMIDUMurA=.sha256","index.md":"&5EeOHUkDadC+lJsDsKXbfrVDQdePyOHZ7KwaJtR5mrs=.sha256","todo.md":"&U6hrQ6cfJ6+Uvg+wA7ahpCQaM2XiYXKjZUOz2iZDSGM=.sha256","structure.md":"&T+CBfT9XP6ooKFvD1ZCI9hsutqsNIamfBxtAho0HtlU=.sha256","guide.md":"&SgnGL0+rjetY2o9A2+lVRbNvHIkqKwMnZr9gXWneIlc=.sha256","id_refactor.md":"&8yoYd14gX2Z3ppktVrPYf4qR78fuwAlvrtsWkSCkWUA=.sha256"}}

View File

@ -7,7 +7,7 @@
## Schema ## Schema
- separate table to discourage leakage - separate table to discourage leakage
- `CREATE TABLE identities (user TEXT, public TEXT, secret TEXT);' - `CREATE TABLE identities (user TEXT, public TEXT, secret TEXT);`
## API ## API
- `ssb.createIdentity()` -> `id` - `ssb.createIdentity()` -> `id`

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&iqkvaTLEbxeintzHb07jiFncdg3N1aS8h8ZNUzy7MZI=.sha256","index.html":"&ko7qv1Ihzmw8ibXr0RinyzNBc2xNzcGDQDPO9X3JAAQ=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&wyqn+8yC3O/m6LfZrR5RIfd6+g+rVCUaPCPT3FcQsPg=.sha256","tf.js":"&/yKh5E/PLaK/M3tivdldiEDnpeYQYyuLHWjjdM/QpxE=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}} {"type":"tildefriends-app","files":{"app.js":"&iqkvaTLEbxeintzHb07jiFncdg3N1aS8h8ZNUzy7MZI=.sha256","index.html":"&ko7qv1Ihzmw8ibXr0RinyzNBc2xNzcGDQDPO9X3JAAQ=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&wyqn+8yC3O/m6LfZrR5RIfd6+g+rVCUaPCPT3FcQsPg=.sha256","tf.js":"&XAGSA200wKbWaBG+aMWgoC+c2mleeAFiNbzaypDc6vU=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}}

View File

@ -3,6 +3,7 @@ var g_data = {
whoami: null, whoami: null,
connections: [], connections: [],
messages: [], messages: [],
messages_by_id: {},
users: {}, users: {},
broadcasts: [], broadcasts: [],
show_connect_dialog: false, show_connect_dialog: false,
@ -42,45 +43,43 @@ function processMessages() {
new_message.children = []; new_message.children = [];
var found = false; var found = false;
var root = JSON.parse(new_message.content).root; var root = JSON.parse(new_message.content).root;
/* If we had inserted a fake root, replace it if we see the real message. */
if (g_data.messages_by_id[new_message.id]) {
var old_message = g_data.messages_by_id[new_message.id];
new_message.children = old_message.children;
for (let child of new_message.children) {
child.parent = new_message;
}
if (old_message.parent) {
old_message.parent.children = old_message.parent.children.filter(x => x != old_message);
} else {
g_data.messages = g_data.messages.filter(x => x != old_message);
}
}
Vue.set(g_data.messages_by_id, new_message.id, new_message);
if (root) { if (root) {
for (let message of g_data.messages) { /* If we don't know of the message's root, add it. */
if (root == message.id) { if (!g_data.messages_by_id[root]) {
message.children.push(new_message);
message.children.sort((x, y) => x.timestamp - y.timestamp);
found = true;
}
}
if (!found) {
var fake_root = { var fake_root = {
id: root, id: root,
children: [new_message], children: [],
timestamp: new_message.timestamp, timestamp: new_message.timestamp,
content: '{}', content: '{}',
}; };
Vue.set(g_data.messages_by_id, root, fake_root);
g_data.messages.push(fake_root); g_data.messages.push(fake_root);
g_data.messages.sort((x, y) => y.timestamp - x.timestamp); g_data.messages.sort((x, y) => y.timestamp - x.timestamp);
found = true; found = true;
} }
} var message = g_data.messages_by_id[root];
var removed = {}; new_message.parent = message;
for (let message of g_data.messages) { message.children.push(new_message);
if (JSON.parse(message.content).root == new_message.id) { message.children.sort((x, y) => x.timestamp - y.timestamp);
new_message.children.push(message); } else {
new_message.children.sort((x, y) => x.timestamp - y.timestamp); /* This is just a new message with no root. Add it. */
removed[message.id] = true;
}
}
g_data.messages = g_data.messages.filter(x => !removed[x.id]);
if (!found) {
for (let message of g_data.messages) {
if (message.id == new_message.id) {
new_message.children = message.children;
Vue.set(g_data.messages, g_data.messages.indexOf(message), new_message);
found = true;
}
}
}
if (!found) {
g_data.messages.push(new_message); g_data.messages.push(new_message);
g_data.messages.sort((x, y) => y.timestamp - x.timestamp); g_data.messages.sort((x, y) => y.timestamp - x.timestamp);
} }
@ -136,6 +135,14 @@ function processMessages() {
g_data.load_time = (new Date() - g_load_start) / 1000; g_data.load_time = (new Date() - g_load_start) / 1000;
g_data.loading = false; g_data.loading = false;
g_data.times = event.data.times; g_data.times = event.data.times;
function dump(messages, indent) {
for (let m of messages) {
console.log(indent + m.id);
dump(m.children, indent + ' ');
}
}
dump(g_data.messages, '');
} else if (key == 'unread') { } else if (key == 'unread') {
g_data.unread += event.data.unread; g_data.unread += event.data.unread;
} else if (key == 'hash') { } else if (key == 'hash') {
@ -186,7 +193,7 @@ window.addEventListener('load', function() {
message.mentions = Object.values(g_data.mentions); message.mentions = Object.values(g_data.mentions);
} }
window.parent.postMessage({appendMessage: message}, '*'); window.parent.postMessage({appendMessage: message}, '*');
document.getElementById('post_text').value = ''; g_data.post_text = null;
Vue.set(g_data, 'mentions', {}); Vue.set(g_data, 'mentions', {});
g_data.reply_root = null; g_data.reply_root = null;
g_data.reply_branch = null; g_data.reply_branch = null;