cleanup + fix feed

This commit is contained in:
Yusur 2025-09-17 14:00:59 +02:00
parent 244f7e40ce
commit a13c7cbc22
5 changed files with 18 additions and 14 deletions

View file

@ -6,7 +6,7 @@
let { user } : {user: UserEntry} = $props();
let enable_search = $state(false);
</script>
@ -14,6 +14,7 @@ let { user } : {user: UserEntry} = $props();
<div class="metanav">
<ul>
<li>
{#if enable_search}
<form action="/search"
method="POST"
class="mini-search-bar nomobile">
@ -24,6 +25,9 @@ let { user } : {user: UserEntry} = $props();
<a href="/search" aria-label="Search" title="Search" class="mobileonly">
<RiSearchLine />
</a>
{:else}
<div style="flex:1"></div>
{/if}
</li>
{#if user}
<li>

View file

@ -48,8 +48,7 @@ export class Backend {
}
async fetch(url: string, options?: RequestInit) {
console.info(`fetch ${Backend.ENDPOINT_BASE}/${encodeURIComponent(url)}`)
return await fetch(`${Backend.ENDPOINT_BASE}/${encodeURIComponent(url)}`, options);
return await fetch(`${Backend.ENDPOINT_BASE}/${url.replace(/^\/+/, '')}`, options);
}
withEvent(event: any) {
@ -76,6 +75,7 @@ class EventBackend extends Backend {
}
async fetch(url: string, options?: RequestInit): Promise<Response> {
console.debug(`fetch ${Backend.ENDPOINT_BASE}/${url.replace(/^\/+/, '')}`);
return await this.event.fetch(`${Backend.ENDPOINT_BASE}/${url.replace(/^\/+/, '')}`, options);
}
}

View file

@ -7,22 +7,23 @@
let me = getMe();
let { data } : { data: { feed: PostEntry[] } } = $props();
let feed: PostEntry[] = $state([]);
let feed: PostEntry[] = $state(Array.prototype.slice.call(data.feed, 0));
let feedIndex = $state(0);
$effect(() => {
if (me && feed) {
feed.push(...data.feed.slice(feedIndex));
feedIndex += feed.length;
} else if (me) {
console.log('feed is', feed)
}
});
// $effect(() => {
// if (me && data?.feed) {
// feed.push(...data.feed.slice(feedIndex));
// feedIndex += feed.length;
// } else if (me) {
// console.log('data.feed is', data?.feed)
// }
// });
</script>
{#if me}
<SLayout title={appName()}>
<Feed posts={feed} />
{#snippet left()}
...
{/snippet}

View file

@ -16,7 +16,6 @@ export async function load(event) {
const respJ = await resp.json();
let { users } = respJ;
console.log(users);
if (users[id]) {
if (users[id].username) {
redirect(302, "/@" +users[id].username );