{#if currentPageID && currentPage} {#if ServerID.is(currentPageID)} {@const server = currentPage as OverviewServer} {@const channel = currentSubPage as OverviewServer} {server!.name} {#if currentSubPage}

{server!.name} - {channel.name}

{:else}

{server!.name} - Server Info

{/if} {:else if UserID.is(currentPageID)} {@const friend = currentPage as OverviewUser} {friend!.username}

{friend!.username}

{:else if GroupID.is(currentPageID)} {@const group = currentPage as OverviewGroup}

{group!.name} ({group.members} member{group.members > 1 ? 's' : ''})

{/if} {#if ServerID.is(currentPageID) || GroupID.is(currentPageID)} {/if} {/if}
{#if currentPageID && currentPage && ServerID.is(currentPageID) && !currentSubPageID} {/if} {#if currentPageID && currentPage && ((ServerID.is(currentPageID) && ChannelID.is(currentSubPageID)) || UserID.is(currentPageID) || GroupID.is(currentPageID))}
{#each messages as message, i (message.id)} {#if i === 0 || messages[i - 1].authorId !== message.authorId}
{message.author.name}
{message.author.name} {formatTimestamp(message.timestamp)}
{message.content}
{:else}
{message.content}
{/if} {/each}
{ if (e.key == 'Enter') { let path = ''; if (ServerID.is(currentPageID) && ChannelID.is(currentSubPageID)) { path = '/api/messages/' + currentPageID + '/' + currentSubPageID; } else { path = '/api/messages/' + (currentPage && 'dmId' in currentPage ? currentPage.dmId : currentPageID); } let message = inputValue; inputValue = ''; const req = await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: message }) }); if (!req.ok) { console.error('Failed to send message'); } } }} placeholder="input box for messages (ignore how ugly it is right now please)" class="flex-1" />
{/if}
{#if currentPage && currentPageID && overview_data && members && !UserID.is(currentPageID)} {/if}