Variety of minor fixes I've been running with. SSB web interface changes. calloc overallocation fix. Use sqlAsync. Probably some other things.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4195 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-02-23 01:29:54 +00:00
parent b8b694864e
commit 8c9d687d50
6 changed files with 16 additions and 9 deletions

View File

@ -15,7 +15,7 @@ async function following(db, id) {
f = {users: [], sequence: 0, version: k_version}; f = {users: [], sequence: 0, version: k_version};
} }
f.users = new Set(f.users); f.users = new Set(f.users);
await ssb.sqlStream( await ssb.sqlAsync(
"SELECT "+ "SELECT "+
" sequence, "+ " sequence, "+
" json_extract(content, '$.contact') AS contact, "+ " json_extract(content, '$.contact') AS contact, "+
@ -73,7 +73,7 @@ async function getAbout(db, id) {
if (!f || f.version != k_version) { if (!f || f.version != k_version) {
f = {about: {}, sequence: 0, version: k_version}; f = {about: {}, sequence: 0, version: k_version};
} }
await ssb.sqlStream( await ssb.sqlAsync(
"SELECT "+ "SELECT "+
" sequence, "+ " sequence, "+
" content "+ " content "+
@ -109,7 +109,7 @@ async function getAbout(db, id) {
async function getSize(db, id) { async function getSize(db, id) {
let size = 0; let size = 0;
await ssb.sqlStream( await ssb.sqlAsync(
"SELECT (SUM(LENGTH(content)) + SUM(LENGTH(author)) + SUM(LENGTH(id))) AS size FROM messages WHERE author = ?1", "SELECT (SUM(LENGTH(content)) + SUM(LENGTH(author)) + SUM(LENGTH(id))) AS size FROM messages WHERE author = ?1",
[id], [id],
function (row) { function (row) {

View File

@ -133,7 +133,11 @@ class TfElement extends LitElement {
`, []))[0].max_row_id; `, []))[0].max_row_id;
let result = await this.following_deep_internal(ids, depth, blocking, cache.last_row_id, cache.following, max_row_id); let result = await this.following_deep_internal(ids, depth, blocking, cache.last_row_id, cache.following, max_row_id);
cache.last_row_id = max_row_id; cache.last_row_id = max_row_id;
await tfrpc.rpc.databaseSet('following', JSON.stringify(cache)); let store = JSON.stringify(cache);
/* 2023-02-20: Exceeding message size. */
if (store.length < 512 * 1024) {
await tfrpc.rpc.databaseSet('following', store);
}
return [result, cache.following]; return [result, cache.following];
} }

View File

@ -400,6 +400,11 @@ class TfMessageElement extends LitElement {
`; `;
} else if (content.type === 'pub') { } else if (content.type === 'pub') {
return small_frame(html` return small_frame(html`
<style>
span {
overflow-wrap: anywhere;
}
</style>
<span> <span>
<div> <div>
🍻 <tf-user .users=${this.users} id=${content.address.key}></tf-user> 🍻 <tf-user .users=${this.users} id=${content.address.key}></tf-user>

View File

@ -145,7 +145,7 @@ class TfNewsElement extends LitElement {
return recursive_sort(roots, true); return recursive_sort(roots, true);
} }
async load_and_render(messages) { load_and_render(messages) {
let messages_by_id = this.process_messages(messages); let messages_by_id = this.process_messages(messages);
let final_messages = this.finalize_messages(messages_by_id); let final_messages = this.finalize_messages(messages_by_id);
return html` return html`
@ -156,8 +156,7 @@ class TfNewsElement extends LitElement {
} }
render() { render() {
let messages = this.load_and_render(this.messages || []); return this.load_and_render(this.messages || []);
return html`${until(messages, html`<div>Loading placeholders...</div>`)}`;
} }
} }

View File

@ -704,7 +704,7 @@ async function blobHandler(request, response, blobId, uri) {
} catch { } catch {
} }
if (apps.delete(appName)) { if (apps.delete(appName)) {
database.set('apps', JSON.stringify([...apps])); database.set('apps', JSON.stringify([...apps].sort()));
} }
database.remove('path:' + appName); database.remove('path:' + appName);
} else { } else {

View File

@ -2031,7 +2031,6 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
{ {
tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t)); tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t));
memset(ssb, 0, sizeof(*ssb)); memset(ssb, 0, sizeof(*ssb));
ssb->verbose = true;
if (context) if (context)
{ {
ssb->context = context; ssb->context = context;