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

@ -3279,7 +3279,7 @@ void tf_ssb_notify_blob_stored(tf_ssb_t* ssb, const char* id)
ssb->blobs_stored++;
}
void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id)
void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id, JSValue message_keys)
{
tf_ssb_message_added_callback_node_t* next = NULL;
ssb->messages_stored++;
@ -3292,10 +3292,9 @@ void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id)
}
JSContext* context = ssb->context;
JSValue message_keys = tf_ssb_db_get_message_by_id(ssb, id, true);
JSValue message = JS_GetPropertyStr(context, message_keys, "value");
if (!JS_IsUndefined(message))
if (!JS_IsUndefined(message_keys))
{
JSValue message = JS_GetPropertyStr(context, message_keys, "value");
JSValue author = JS_GetPropertyStr(context, message, "author");
const char* author_string = JS_ToCString(context, author);
@ -3327,9 +3326,8 @@ void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id)
JS_FreeCString(context, author_string);
JS_FreeValue(context, author);
JS_FreeValue(context, message);
}
JS_FreeValue(context, message);
JS_FreeValue(context, message_keys);
}
void tf_ssb_add_blob_want_added_callback(tf_ssb_t* ssb, void (*callback)(tf_ssb_t* ssb, const char* id, void* user_data), void (*cleanup)(tf_ssb_t* ssb, void* user_data), void* user_data)