feat: use last community in community form

This commit is contained in:
Xyphyn committed 2023-08-08 15:21:25 -07:00
1 parent d22d9b09fd
commit 6c7073fcfc
6 files changed
+70 -10

No files matched your search

+13 -1
View File
@@ -14,11 +14,23 @@
import Pageination from '$lib/components/ui/Pageination.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Sort from '$lib/components/lemmy/Sort.svelte'
import { searchParam } from '$lib/util.js'
import { fullCommunityName, searchParam } from '$lib/util.js'
import { onDestroy, onMount } from 'svelte'
import { setSessionStorage } from '$lib/session.js'
export let data
let sidebar: boolean = false
onMount(() => {
setSessionStorage('lastSeenCommunity', {
id: data.community.community.id,
name: fullCommunityName(
data.community.community.name,
data.community.community.actor_id
),
})
})
</script>
<svelte:head>
+9 -1
View File
@@ -4,12 +4,17 @@
import Card from '$lib/components/ui/Card.svelte'
import { profile } from '$lib/auth.js'
import { onMount } from 'svelte'
import { getSessionStorage } from '$lib/session.js'
onMount(() => {
if (!$profile?.jwt) {
goto('/login')
}
})
let community = getSessionStorage('lastSeenCommunity') as
| { id: number; name: string }
| undefined
</script>
<svelte:head>
@@ -17,5 +22,8 @@
</svelte:head>
<Card class="p-6 max-w-2xl mx-auto">
<PostForm on:submit={(e) => goto(`/post/${e.detail.post.id}`)} />
<PostForm
passedCommunity={community}
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
/>
</Card>