From 0dd0b835ec6aa2ca8d1f7c6186ec87e8dd6a93ea Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 27 Nov 2023 17:26:02 +0000 Subject: [PATCH] wiki new message fix and sorting. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4650 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/wiki.json | 2 +- apps/wiki/app.js | 19 ------------------- apps/wiki/tf-collection.js | 2 +- apps/wiki/utils.js | 19 +++++++++++++++++++ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/wiki.json b/apps/wiki.json index 9f5f0c0b3..232b897d5 100644 --- a/apps/wiki.json +++ b/apps/wiki.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "📝", - "previous": "&2HYCsRnzXWQTE/oFrSARWDr/Uv7teWHqQASdSG68gfw=.sha256" + "previous": "&r+JXDhWclHwMbeZHYjueOnSPaYCAXUlnl1Gyjgw6TxM=.sha256" } \ No newline at end of file diff --git a/apps/wiki/app.js b/apps/wiki/app.js index 2c80098bf..245dded1f 100644 --- a/apps/wiki/app.js +++ b/apps/wiki/app.js @@ -48,25 +48,6 @@ tfrpc.register(async function get_blob(id) { return utf8Decode(await ssb.blobGet(id)); }); -let g_new_message_resolve; -let g_new_message_promise = new Promise(function(resolve, reject) { - g_new_message_resolve = resolve; -}); - -function new_message() { - return g_new_message_promise; -} - -ssb.addEventListener('message', function(id) { - let resolve = g_new_message_resolve; - g_new_message_promise = new Promise(function(resolve, reject) { - g_new_message_resolve = resolve; - }); - if (resolve) { - resolve(); - } -}); - core.register('message', async function message_handler(message) { if (message.event == 'hashChange') { g_hash = message.hash; diff --git a/apps/wiki/tf-collection.js b/apps/wiki/tf-collection.js index 71c6cefd6..1337602ee 100644 --- a/apps/wiki/tf-collection.js +++ b/apps/wiki/tf-collection.js @@ -68,7 +68,7 @@ class TfCollectionElement extends LitElement { diff --git a/apps/wiki/utils.js b/apps/wiki/utils.js index 66782822a..4e93c6a6b 100644 --- a/apps/wiki/utils.js +++ b/apps/wiki/utils.js @@ -39,6 +39,25 @@ async function process_message(whoami, collection, message, kind, parent) { return true; } +let g_new_message_resolve; +let g_new_message_promise = new Promise(function(resolve, reject) { + g_new_message_resolve = resolve; +}); + +function new_message() { + return g_new_message_promise; +} + +ssb.addEventListener('message', function(id) { + let resolve = g_new_message_resolve; + g_new_message_promise = new Promise(function(resolve, reject) { + g_new_message_resolve = resolve; + }); + if (resolve) { + resolve(); + } +}); + export async function collection(ids, kind, parent, max_rowid, data, include_private) { let whoami = await ssb.getIdentities(); data = data ?? {};