misc: more clearly indicate selected community
This commit is contained in:
1 parent
ea72f6697f
commit
ac504b8bce
4 files changed
+41
-40
No files matched your search
@@ -11,6 +11,7 @@
|
|||||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
|
||||||
export let edit = false
|
export let edit = false
|
||||||
|
|
||||||
@@ -19,15 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
export let editingPost: Post | undefined = undefined
|
export let editingPost: Post | undefined = undefined
|
||||||
|
|
||||||
export let passedCommunity:
|
export let passedCommunity: Community | undefined = undefined
|
||||||
| {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
| undefined = undefined
|
|
||||||
|
|
||||||
export let data: {
|
export let data: {
|
||||||
community: number | null
|
community: Community | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
@@ -59,7 +55,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (passedCommunity) {
|
if (passedCommunity) {
|
||||||
data.community = passedCommunity.id
|
data.community = passedCommunity
|
||||||
communitySearch = passedCommunity.name
|
communitySearch = passedCommunity.name
|
||||||
console.log(communitySearch)
|
console.log(communitySearch)
|
||||||
} else {
|
} else {
|
||||||
@@ -125,7 +121,7 @@
|
|||||||
: undefined
|
: undefined
|
||||||
data.url = image || data.url || undefined
|
data.url = image || data.url || undefined
|
||||||
const post = await client().createPost({
|
const post = await client().createPost({
|
||||||
community_id: data.community!,
|
community_id: data.community!.id,
|
||||||
name: data.title,
|
name: data.title,
|
||||||
body: data.body,
|
body: data.body,
|
||||||
url: data.url,
|
url: data.url,
|
||||||
@@ -213,25 +209,14 @@
|
|||||||
</h1>
|
</h1>
|
||||||
</slot>
|
</slot>
|
||||||
{#if !edit && data}
|
{#if !edit && data}
|
||||||
<div>
|
{#if !data.community}
|
||||||
<div class="flex flex-row">
|
|
||||||
<span class="block my-1 font-bold text-sm">
|
|
||||||
Community <span class="text-red-500">*</span>
|
|
||||||
</span>
|
|
||||||
{#if data.community}
|
|
||||||
<Icon
|
|
||||||
src={Check}
|
|
||||||
mini
|
|
||||||
size="20"
|
|
||||||
class="text-green-600 ml-auto inline"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
bind:q={communitySearch}
|
bind:q={communitySearch}
|
||||||
bind:items={communities}
|
bind:items={communities}
|
||||||
jwt={$profile?.jwt}
|
jwt={$profile?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
|
label="Community"
|
||||||
|
required
|
||||||
on:select={(e) => {
|
on:select={(e) => {
|
||||||
const c = e.detail
|
const c = e.detail
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@@ -239,11 +224,35 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data.community = c.id
|
communitySearch = ''
|
||||||
communitySearch = `${c.name}@${new URL(c.actor_id).hostname}`
|
|
||||||
|
data.community = c
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<span class="font-medium text-sm">Community</span>
|
||||||
|
<Button
|
||||||
|
class="w-full !bg-white dark:!bg-black h-[38px]"
|
||||||
|
on:click={() => (data.community = null)}
|
||||||
|
alignment="left"
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
url={data.community.icon}
|
||||||
|
alt={data.community.name}
|
||||||
|
width={24}
|
||||||
|
slot="prefix"
|
||||||
|
/>
|
||||||
|
<div class="flex flex-col gap-0">
|
||||||
|
<span class="text-xs">{data.community.name}</span>
|
||||||
|
<span class="text-[10px] leading-3">
|
||||||
|
{new URL(data.community.actor_id).hostname}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
|
|||||||
+3
-6
@@ -1,14 +1,11 @@
|
|||||||
|
import type { Community } from 'lemmy-js-client'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
interface SessionStorage {
|
interface SessionStorage {
|
||||||
lastSeenCommunity: // prettier-ignore
|
lastSeenCommunity: Community | undefined
|
||||||
{
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
} | undefined
|
|
||||||
postDraft:
|
postDraft:
|
||||||
| {
|
| {
|
||||||
community: number | null
|
community: Community | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
|
|||||||
@@ -28,13 +28,10 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (browser)
|
if (browser)
|
||||||
setSessionStorage('lastSeenCommunity', {
|
setSessionStorage(
|
||||||
id: data.community.community_view.community.id,
|
'lastSeenCommunity',
|
||||||
name: fullCommunityName(
|
data.community.community_view.community
|
||||||
data.community.community_view.community.name,
|
)
|
||||||
data.community.community_view.community.actor_id
|
|
||||||
),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
|||||||
@@ -161,8 +161,6 @@
|
|||||||
community={post.post_view.community}
|
community={post.post_view.community}
|
||||||
user={post.post_view.creator}
|
user={post.post_view.creator}
|
||||||
bind:subscribed={post.community_view.subscribed}
|
bind:subscribed={post.community_view.subscribed}
|
||||||
upvotes={post.post_view.counts.upvotes}
|
|
||||||
downvotes={post.post_view.counts.downvotes}
|
|
||||||
deleted={post.post_view.post.deleted}
|
deleted={post.post_view.post.deleted}
|
||||||
removed={post.post_view.post.removed}
|
removed={post.post_view.post.removed}
|
||||||
locked={post.post_view.post.locked}
|
locked={post.post_view.post.locked}
|
||||||
|
|||||||
Reference in new issue
Block a user