wiki new message fix and sorting.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4650 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-11-27 17:26:02 +00:00
parent d96e0a7497
commit 0dd0b835ec
4 changed files with 21 additions and 21 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "📝", "emoji": "📝",
"previous": "&2HYCsRnzXWQTE/oFrSARWDr/Uv7teWHqQASdSG68gfw=.sha256" "previous": "&r+JXDhWclHwMbeZHYjueOnSPaYCAXUlnl1Gyjgw6TxM=.sha256"
} }

View File

@ -48,25 +48,6 @@ tfrpc.register(async function get_blob(id) {
return utf8Decode(await ssb.blobGet(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) { core.register('message', async function message_handler(message) {
if (message.event == 'hashChange') { if (message.event == 'hashChange') {
g_hash = message.hash; g_hash = message.hash;

View File

@ -68,7 +68,7 @@ class TfCollectionElement extends LitElement {
<span style="display: inline-flex; flex-direction: row"> <span style="display: inline-flex; flex-direction: row">
<select @change=${this.on_selected} id="select" value=${this.selected_id}> <select @change=${this.on_selected} id="select" value=${this.selected_id}>
<option value="" ?selected=${this.selected_id === ''} disabled hidden>(select)</option> <option value="" ?selected=${this.selected_id === ''} disabled hidden>(select)</option>
${Object.values(this.collection ?? {}).map(x => html`<option value=${x.id} ?selected=${this.selected_id === x.id}>${x.name}</option>`)} ${Object.values(this.collection ?? {}).sort((x, y) => x.name.localeCompare(y.name)).map(x => html`<option value=${x.id} ?selected=${this.selected_id === x.id}>${x.name}</option>`)}
</select> </select>
<span ?hidden=${!this.is_renaming || !this.whoami}> <span ?hidden=${!this.is_renaming || !this.whoami}>
<span style="display: inline-flex; flex-direction: row; margin-left: 8px; margin-right: 8px"> <span style="display: inline-flex; flex-direction: row; margin-left: 8px; margin-right: 8px">

View File

@ -39,6 +39,25 @@ async function process_message(whoami, collection, message, kind, parent) {
return true; 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) { export async function collection(ids, kind, parent, max_rowid, data, include_private) {
let whoami = await ssb.getIdentities(); let whoami = await ssb.getIdentities();
data = data ?? {}; data = data ?? {};