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

@ -1,7 +1,7 @@
{ {
"name": "@yusurko/vigil", "name": "@yusurko/vigil",
"private": true, "private": true,
"version": "0.1.0-dev36", "version": "0.1.0-dev37",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",

View file

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

View file

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

View file

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

View file

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