Remove DB work from tf_ssb_notify_message_added, which runs on the main thread.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4497 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-10-08 13:52:49 +00:00
parent 7fc23dc085
commit 0473eec0a2
3 changed files with 24 additions and 8 deletions

View File

@ -464,7 +464,25 @@ static void _tf_ssb_db_store_message_after_work(uv_work_t* work, int status)
if (store->out_stored)
{
tf_trace_begin(trace, "notify_message_added");
tf_ssb_notify_message_added(store->ssb, store->id);
JSContext* context = tf_ssb_get_context(store->ssb);
JSValue formatted = tf_ssb_format_message(
context,
store->previous,
store->author,
store->sequence,
store->timestamp,
"sha256",
store->content,
store->signature,
store->sequence_before_author);
JSValue message = JS_NewObject(context);
JS_SetPropertyStr(context, message, "key", JS_NewString(context, store->id));
JS_SetPropertyStr(context, message, "value", formatted);
char timestamp_string[256];
snprintf(timestamp_string, sizeof(timestamp_string), "%f", store->timestamp);
JS_SetPropertyStr(context, message, "timestamp", JS_NewString(context, timestamp_string));
tf_ssb_notify_message_added(store->ssb, store->id, message);
JS_FreeValue(context, message);
tf_trace_end(trace);
}
if (store->out_blob_wants)