fix navigation in post focus

This commit is contained in:
ari melody 2024-06-29 16:19:34 +01:00
parent ce1dfc388f
commit 6c19a4f3c9
Signed by: ari
GPG key ID: CF99829C92678188
4 changed files with 10 additions and 7 deletions

View file

@ -6,6 +6,7 @@
import { Client } from '$lib/client/client.js'; import { Client } from '$lib/client/client.js';
import { play_sound } from '$lib/sound.js'; import { play_sound } from '$lib/sound.js';
import { getTimeline } from '$lib/timeline.js'; import { getTimeline } from '$lib/timeline.js';
import { goto } from '$app/navigation';
const VERSION = APP_VERSION; const VERSION = APP_VERSION;
@ -26,7 +27,7 @@
}); });
return; return;
} }
location = "/"; goto("/");
} }
function log_out() { function log_out() {

View file

@ -18,9 +18,8 @@
let post_context = undefined; let post_context = undefined;
let post = post_data; let post = post_data;
let is_boost = false; let is_boost = !!post_data.boost;
if (post_data.boost) { if (is_boost) {
is_boost = true;
post_context = post_data; post_context = post_data;
post = post_data.boost; post = post_data.boost;
} }
@ -28,6 +27,7 @@
function gotoPost() { function gotoPost() {
if (focused) return; if (focused) return;
if (event.key && event.key !== "Enter") return; if (event.key && event.key !== "Enter") return;
console.log(`/post/${post.id}`);
goto(`/post/${post.id}`); goto(`/post/${post.id}`);
} }

View file

@ -16,8 +16,8 @@
let aria_label = post.user.username + '; ' + post.text + '; ' + post.created_at; let aria_label = post.user.username + '; ' + post.text + '; ' + post.created_at;
function gotoPost() { function gotoPost() {
if (focused) return;
if (event.key && event.key !== "Enter") return; if (event.key && event.key !== "Enter") return;
console.log(`/post/${post.id}`);
goto(`/post/${post.id}`); goto(`/post/${post.id}`);
} }

View file

@ -3,8 +3,8 @@
import Post from '$lib/ui/post/Post.svelte'; import Post from '$lib/ui/post/Post.svelte';
export let data; export let data;
const main_post = data.posts[0]; $: main_post = data.posts[0];
const replies = data.posts.slice(1); $: replies = data.posts.slice(1);
</script> </script>
<div id="feed" role="feed"> <div id="feed" role="feed">
@ -13,11 +13,13 @@
<span>just a moment...</span> <span>just a moment...</span>
</div> </div>
{:else} {:else}
{#key data}
<Post post_data={main_post} focused /> <Post post_data={main_post} focused />
<br> <br>
{#each replies as post} {#each replies as post}
<Post post_data={post} /> <Post post_data={post} />
{/each} {/each}
{/key}
{/if} {/if}
</div> </div>