diff --git a/src/routes/channels/[guildId]/SearchFilter.svelte b/src/routes/channels/[guildId]/SearchFilter.svelte index 12b01d99..e2394f8f 100644 --- a/src/routes/channels/[guildId]/SearchFilter.svelte +++ b/src/routes/channels/[guildId]/SearchFilter.svelte @@ -264,29 +264,46 @@ // return a.timestamp < b.timestamp; // }); - // add searchPrevMessage and searchNextMessage to all messages - for (let i = 0; i < channelMessages.length; i++) { - let message = channelMessages[i]; - let prevMessage = channelMessages[i - 1]; - let nextMessage = channelMessages[i + 1]; - if (prevMessage) { - message.searchPrevMessageChannelId = prevMessage.channelId; - } else { - message.searchPrevMessageChannelId = 'first'; - } - if (nextMessage) { - message.searchNextMessageChannelId = nextMessage.channelId; - } else { - message.searchNextMessageChannelId = 'last'; - } - } - found_messages_temp.push(...channelMessages); $searched = true; } + + found_messages_temp = found_messages_temp.sort((a, b) => { + console.log(a.id, b.id, BigInt(a.id) < BigInt(b.id)); + return BigInt(a.id) > BigInt(b.id) ? -1 : 1; + }); + + // loop through found messages and print channel name + for (let i = 0; i < found_messages_temp.length; i++) { + let message = found_messages_temp[i]; + let channel = guild.channels[message.channelId]?.name + // console.log('channel', channel); + console.log('id', message.id); + } + // add searchPrevMessage and searchNextMessage to all messages + for (let i = 0; i < found_messages_temp.length; i++) { + let message = found_messages_temp[i]; + let prevMessage = found_messages_temp[i - 1]; + let nextMessage = found_messages_temp[i + 1]; + if (prevMessage) { + message.searchPrevMessageChannelId = prevMessage.channelId; + } else { + message.searchPrevMessageChannelId = 'first'; + } + if (nextMessage) { + message.searchNextMessageChannelId = nextMessage.channelId; + } else { + message.searchNextMessageChannelId = 'last'; + } + } console.log('found messages', found_messages_temp); + + + + // set found messages $found_messages = found_messages_temp; + } console.log('----', guild.channels); diff --git a/src/routes/channels/[guildId]/[channelId]/+page.svelte b/src/routes/channels/[guildId]/[channelId]/+page.svelte index 184a1005..e6e8a21f 100644 --- a/src/routes/channels/[guildId]/[channelId]/+page.svelte +++ b/src/routes/channels/[guildId]/[channelId]/+page.svelte @@ -39,7 +39,7 @@ {/if} {/key} - +
diff --git a/src/routes/channels/[guildId]/[channelId]/Messages.svelte b/src/routes/channels/[guildId]/[channelId]/Messages.svelte index d85da0d4..61544633 100644 --- a/src/routes/channels/[guildId]/[channelId]/Messages.svelte +++ b/src/routes/channels/[guildId]/[channelId]/Messages.svelte @@ -16,7 +16,7 @@ {#key channelId} {#if messages} - + {:else}
No messages
{/if}