feat: [1/2]: add flairs
This commit is contained in:
1 parent
fda8e5fb37
commit
50c0b83511
15 files changed
+160
-96
No files matched your search
Vendored
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
// See https://kit.svelte.dev/docs/types#app
|
// See https://kit.svelte.dev/docs/types#app
|
||||||
|
|
||||||
import type { Action } from '$lib/components/ui/navbar/commands/actions.svelte'
|
import type { Action } from '$lib/components/ui/navbar/commands/actions.svelte'
|
||||||
import type { ComponentType } from 'svelte'
|
|
||||||
|
|
||||||
// for information about these interfaces
|
// for information about these interfaces
|
||||||
declare global {
|
declare global {
|
||||||
@@ -13,7 +12,7 @@ declare global {
|
|||||||
interface PageData {
|
interface PageData {
|
||||||
slots?: {
|
slots?: {
|
||||||
sidebar?: {
|
sidebar?: {
|
||||||
component?: ComponentType
|
component?: Component<Props, unknown, 'community_view'>
|
||||||
props?: any
|
props?: any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ export abstract class BaseClient {
|
|||||||
abstract setFlair?(form: types.SetPersonFlair): Promise<types.PersonView>
|
abstract setFlair?(form: types.SetPersonFlair): Promise<types.PersonView>
|
||||||
abstract getFeeds?(form: types.GetFeeds): Promise<types.GetFeedsResponse>
|
abstract getFeeds?(form: types.GetFeeds): Promise<types.GetFeedsResponse>
|
||||||
abstract getTopics?(form: types.GetTopics): Promise<types.GetTopicsResponse>
|
abstract getTopics?(form: types.GetTopics): Promise<types.GetTopicsResponse>
|
||||||
|
abstract assignFlair?(form: types.AssignFlair): Promise<types.PostView>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NullableFnArg<T, Fallback = never> = T extends (
|
export type NullableFnArg<T, Fallback = never> = T extends (
|
||||||
|
|||||||
@@ -1002,4 +1002,16 @@ export class PiefedClient implements BaseClient {
|
|||||||
topics: response.topics.map(toTopicView),
|
topics: response.topics.map(toTopicView),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async assignFlair(
|
||||||
|
params: NullableFnArg<BaseClient['assignFlair']>[0],
|
||||||
|
): NullableFnReturn<BaseClient['assignFlair']> {
|
||||||
|
const response = (
|
||||||
|
await this.#client.POST('/api/alpha/post/assign_flair', {
|
||||||
|
body: params,
|
||||||
|
})
|
||||||
|
).data!
|
||||||
|
|
||||||
|
return toPostView(response)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -263,6 +263,7 @@ export interface CommunityView {
|
|||||||
blocked: boolean
|
blocked: boolean
|
||||||
counts: CommunityAggregates
|
counts: CommunityAggregates
|
||||||
banned_from_community: boolean
|
banned_from_community: boolean
|
||||||
|
flair_list?: CommunityFlair[]
|
||||||
}
|
}
|
||||||
export type CommunityVisibility = 'Public' | 'LocalOnly'
|
export type CommunityVisibility = 'Public' | 'LocalOnly'
|
||||||
|
|
||||||
@@ -2057,3 +2058,8 @@ export interface TopicView {
|
|||||||
export interface GetTopicsResponse {
|
export interface GetTopicsResponse {
|
||||||
topics: TopicView[]
|
topics: TopicView[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AssignFlair {
|
||||||
|
post_id: number
|
||||||
|
flair_id_list: number[]
|
||||||
|
}
|
||||||
@@ -44,9 +44,10 @@
|
|||||||
sort: 'TopAll',
|
sort: 'TopAll',
|
||||||
})
|
})
|
||||||
|
|
||||||
return results.communities.map((c) => c.community)
|
return results.communities
|
||||||
}}
|
}}
|
||||||
extractName={(c) => `${c.title}@${new URL(c.actor_id).hostname}`}
|
extractName={(c) =>
|
||||||
|
`${c.community.name}@${new URL(c.community.actor_id).hostname}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
@@ -67,11 +68,15 @@
|
|||||||
{#snippet children({ item, select })}
|
{#snippet children({ item, select })}
|
||||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||||
<MenuButton onclick={() => select(item)}>
|
<MenuButton onclick={() => select(item)}>
|
||||||
<Avatar url={item.icon} alt={item.title} width={24} />
|
<Avatar
|
||||||
|
url={item.community.icon}
|
||||||
|
alt={item.community.title}
|
||||||
|
width={24}
|
||||||
|
/>
|
||||||
<div class="flex flex-col text-left">
|
<div class="flex flex-col text-left">
|
||||||
<span>{item.title}</span>
|
<span>{item.community.title}</span>
|
||||||
<span class="text-xs opacity-80">
|
<span class="text-xs opacity-80">
|
||||||
{new URL(item.actor_id).hostname}
|
{new URL(item.community.actor_id).hostname}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import { communityLink } from '$lib/util.svelte'
|
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import type { Community } from '$lib/client/types'
|
import type { Community } from '$lib/client/types'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
|
import { communityLink } from '$lib/util.svelte'
|
||||||
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||||
import type { HTMLAnchorAttributes } from 'svelte/elements'
|
import type { HTMLAnchorAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
@@ -39,17 +39,15 @@
|
|||||||
|
|
||||||
<a
|
<a
|
||||||
{...rest}
|
{...rest}
|
||||||
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {clazz}"
|
class={[
|
||||||
|
'items-center inline-flex flex-row gap-2 hover:underline max-w-full min-w-0',
|
||||||
|
clazz,
|
||||||
|
]}
|
||||||
href={communityLink(community)}
|
href={communityLink(community)}
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
{#if avatar && !badges.nsfw}
|
{#if avatar && !badges.nsfw}
|
||||||
<Avatar
|
<Avatar url={community.icon} alt={community.name} width={avatarSize} />
|
||||||
url={community.icon ??
|
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${community.name}`}
|
|
||||||
alt={community.name}
|
|
||||||
width={avatarSize}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if name}
|
{#if name}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
color: i.background_color,
|
color: i.background_color,
|
||||||
icon: null,
|
icon: null,
|
||||||
type: 'flair' as 'flair' | 'custom',
|
type: 'flair' as 'flair' | 'custom',
|
||||||
|
textColor: i.text_color,
|
||||||
})) ?? []),
|
})) ?? []),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,7 +428,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:global(.badge-tag-color) {
|
:global(.badge-tag-color) {
|
||||||
background-color: var(--tag-color) !important;
|
background-color: var(--tag-color, #fff) !important;
|
||||||
color: var(--tag-text-color, #000) !important;
|
color: var(--tag-text-color, #000) !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,5 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
// This file is genuinely atrocious. It was here since the start of Photon,
|
||||||
|
// 2 years ago. I'm very sorry about this. please don't think this is
|
||||||
|
// my peak of development.
|
||||||
|
|
||||||
|
import { client, site } from '$lib/client/lemmy.svelte'
|
||||||
|
import type {
|
||||||
|
CommunityView,
|
||||||
|
Post,
|
||||||
|
PostResponse,
|
||||||
|
PostView,
|
||||||
|
} from '$lib/client/types'
|
||||||
import ErrorContainer, {
|
import ErrorContainer, {
|
||||||
clearErrorScope,
|
clearErrorScope,
|
||||||
pushError,
|
pushError,
|
||||||
@@ -10,34 +20,36 @@
|
|||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { Header } from '$lib/components/ui/layout'
|
import { Header } from '$lib/components/ui/layout'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { client, site } from '$lib/client/lemmy.svelte'
|
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||||
import { placeholders } from '$lib/util.svelte.js'
|
import { placeholders } from '$lib/util.svelte.js'
|
||||||
import type { Community, Post, PostView } from '$lib/client/types'
|
|
||||||
import {
|
import {
|
||||||
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
Modal,
|
Material,
|
||||||
|
modal,
|
||||||
|
Option,
|
||||||
Select,
|
Select,
|
||||||
Spinner,
|
Spinner,
|
||||||
Switch,
|
Switch,
|
||||||
TextArea,
|
TextArea,
|
||||||
TextInput,
|
TextInput,
|
||||||
toast,
|
toast,
|
||||||
Option,
|
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
import {
|
import {
|
||||||
ArrowPath,
|
ArrowPath,
|
||||||
ChatBubbleBottomCenterText,
|
ChatBubbleBottomCenterText,
|
||||||
|
Check,
|
||||||
Icon,
|
Icon,
|
||||||
Language,
|
Language,
|
||||||
Link,
|
Link,
|
||||||
Photo,
|
Photo,
|
||||||
|
Plus,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
|
Tag,
|
||||||
XMark,
|
XMark,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { slide } from 'svelte/transition'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
edit?: boolean
|
edit?: boolean
|
||||||
@@ -45,9 +57,9 @@
|
|||||||
* The post to edit
|
* The post to edit
|
||||||
*/
|
*/
|
||||||
editingPost?: Post | undefined
|
editingPost?: Post | undefined
|
||||||
passedCommunity?: Community | undefined
|
passedCommunity?: CommunityView
|
||||||
passedData?: {
|
passedData?: {
|
||||||
community: Community | null
|
community: CommunityView | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
@@ -57,6 +69,7 @@
|
|||||||
loading: boolean
|
loading: boolean
|
||||||
alt_text?: string
|
alt_text?: string
|
||||||
language_id?: number | string
|
language_id?: number | string
|
||||||
|
flair_list: number[]
|
||||||
}
|
}
|
||||||
formtitle?: import('svelte').Snippet
|
formtitle?: import('svelte').Snippet
|
||||||
onsubmit?: (post: PostView) => void
|
onsubmit?: (post: PostView) => void
|
||||||
@@ -71,12 +84,9 @@
|
|||||||
title: '',
|
title: '',
|
||||||
body: '',
|
body: '',
|
||||||
image: null,
|
image: null,
|
||||||
thumbnail: undefined,
|
|
||||||
url: undefined,
|
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
alt_text: undefined,
|
flair_list: [],
|
||||||
language_id: undefined,
|
|
||||||
},
|
},
|
||||||
formtitle,
|
formtitle,
|
||||||
onsubmit,
|
onsubmit,
|
||||||
@@ -90,24 +100,14 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
let saveDraft = edit ? false : true
|
let saveDraft = edit ? false : true
|
||||||
let communitySearch = $state(passedCommunity?.name ?? '')
|
let communitySearch = $state(passedCommunity?.community.name ?? '')
|
||||||
|
|
||||||
let communities: Community[] = $state([])
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (editingPost) Object.assign(data, editingPost)
|
if (editingPost) Object.assign(data, editingPost)
|
||||||
|
|
||||||
if (passedCommunity) {
|
if (passedCommunity) {
|
||||||
data.community = passedCommunity
|
data.community = passedCommunity
|
||||||
communitySearch = passedCommunity.name
|
communitySearch = passedCommunity.community.name
|
||||||
} else {
|
|
||||||
const list = await client().listCommunities({
|
|
||||||
type_: 'All',
|
|
||||||
sort: 'Active',
|
|
||||||
limit: 40,
|
|
||||||
})
|
|
||||||
|
|
||||||
communities = list.communities.map((c) => c.community)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -139,12 +139,13 @@
|
|||||||
data.loading = true
|
data.loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let post: PostResponse
|
||||||
if (edit) {
|
if (edit) {
|
||||||
if (!editingPost) {
|
if (!editingPost) {
|
||||||
throw new Error('Post is being edited but editingPost is null')
|
throw new Error('Post is being edited but editingPost is null')
|
||||||
}
|
}
|
||||||
|
|
||||||
const post = await client().editPost({
|
post = await client().editPost({
|
||||||
name: data.title,
|
name: data.title,
|
||||||
body: data.body,
|
body: data.body,
|
||||||
url: data.url || undefined,
|
url: data.url || undefined,
|
||||||
@@ -156,11 +157,9 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!post) throw new Error('Failed to edit post')
|
if (!post) throw new Error('Failed to edit post')
|
||||||
|
|
||||||
onsubmit?.(post.post_view)
|
|
||||||
} else {
|
} else {
|
||||||
const post = await client().createPost({
|
post = await client().createPost({
|
||||||
community_id: data.community!.id,
|
community_id: data.community!.community.id,
|
||||||
name: data.title,
|
name: data.title,
|
||||||
body: data.body,
|
body: data.body,
|
||||||
url: data.url || undefined,
|
url: data.url || undefined,
|
||||||
@@ -173,8 +172,19 @@
|
|||||||
if (!post) throw new Error('Failed to upload post')
|
if (!post) throw new Error('Failed to upload post')
|
||||||
|
|
||||||
saveDraft = false
|
saveDraft = false
|
||||||
onsubmit?.(post.post_view)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.flair_list.length > 0) {
|
||||||
|
const piefed = client()
|
||||||
|
if (piefed.assignFlair) {
|
||||||
|
await piefed.assignFlair({
|
||||||
|
flair_id_list: data.flair_list,
|
||||||
|
post_id: post.post_view.post.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onsubmit?.(post.post_view)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
pushError({ message: errorMessage(err as string), scope: 'post-form' })
|
pushError({ message: errorMessage(err as string), scope: 'post-form' })
|
||||||
data.loading = false
|
data.loading = false
|
||||||
@@ -232,11 +242,13 @@
|
|||||||
title: '',
|
title: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
let addAltText = $state(false)
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
generation.generatable = canGenerateTitle(data.url)
|
generation.generatable = canGenerateTitle(data.url)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (data.community) data.flair_list = []
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if uploadingImage}
|
{#if uploadingImage}
|
||||||
@@ -248,22 +260,39 @@
|
|||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if addAltText}
|
{#snippet altText()}
|
||||||
<Modal title={$t('form.post.altText')} bind:open={addAltText}>
|
<TextArea bind:value={data.alt_text} />
|
||||||
<form
|
{/snippet}
|
||||||
onsubmit={(e) => {
|
|
||||||
e.preventDefault()
|
{#snippet flairs()}
|
||||||
addAltText = !addAltText
|
<Material color="uniform" class="flex flex-row gap-4 flex-wrap">
|
||||||
}}
|
{#if data.community?.flair_list}
|
||||||
class="space-y-4 w-full"
|
{#each data.community.flair_list as flair}
|
||||||
>
|
{@const selected = data.flair_list?.some((i) => i == flair.id)}
|
||||||
<TextArea bind:value={data.alt_text} />
|
<button
|
||||||
<Button size="lg" submit class="w-full">
|
class="rounded-full cursor-pointer hover:brightness-100"
|
||||||
{$t('common.back')}
|
style="background-color: {flair.background_color};"
|
||||||
</Button>
|
onclick={() => {
|
||||||
</form>
|
if (selected) {
|
||||||
</Modal>
|
const index = data.flair_list.findIndex((i) => i == flair.id)
|
||||||
{/if}
|
if (index != -1) data.flair_list.splice(index, 1)
|
||||||
|
} else data.flair_list.push(flair.id)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Badge
|
||||||
|
color={selected ? 'gray-subtle' : 'custom'}
|
||||||
|
class="ring-white/20"
|
||||||
|
>
|
||||||
|
{#snippet icon()}
|
||||||
|
<Icon src={selected ? Check : Plus} size="16" micro />
|
||||||
|
{/snippet}
|
||||||
|
{flair.flair_title}
|
||||||
|
</Badge>
|
||||||
|
</button>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</Material>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={(e) => {
|
onsubmit={(e) => {
|
||||||
@@ -282,11 +311,8 @@
|
|||||||
{#if !data.community}
|
{#if !data.community}
|
||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
bind:q={communitySearch}
|
bind:q={communitySearch}
|
||||||
items={communities}
|
|
||||||
jwt={profile.current?.jwt}
|
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
label={$t('form.post.community')}
|
label={$t('form.post.community')}
|
||||||
required
|
|
||||||
onselect={(e) => {
|
onselect={(e) => {
|
||||||
const c = e
|
const c = e
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@@ -311,15 +337,15 @@
|
|||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Avatar
|
<Avatar
|
||||||
url={data?.community?.icon}
|
url={data?.community?.community.icon}
|
||||||
alt={data.community?.name}
|
alt={data.community?.community.name}
|
||||||
width={24}
|
width={24}
|
||||||
/>
|
/>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<div class="flex flex-col gap-0">
|
<div class="flex flex-col gap-0">
|
||||||
<span class="text-sm">{data.community.name}</span>
|
<span class="text-sm">{data.community?.community.name}</span>
|
||||||
<span class="text-[10px] leading-3">
|
<span class="text-[10px] leading-3">
|
||||||
{new URL(data.community.actor_id).hostname}
|
{new URL(data.community.community.actor_id).hostname}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -349,13 +375,15 @@
|
|||||||
<div class="flex items-center gap-2 actions">
|
<div class="flex items-center gap-2 actions">
|
||||||
{#if data.url}
|
{#if data.url}
|
||||||
<Button
|
<Button
|
||||||
onclick={() => (addAltText = !addAltText)}
|
onclick={() =>
|
||||||
|
modal({ title: $t('form.post.altText'), snippet: altText })}
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="sm"
|
size="sm"
|
||||||
color={data.alt_text ? 'primary' : 'ghost'}
|
color={data.alt_text ? 'primary' : 'ghost'}
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
icon={ChatBubbleBottomCenterText}
|
icon={ChatBubbleBottomCenterText}
|
||||||
>{$t('form.post.altText')}
|
>
|
||||||
|
{$t('form.post.altText')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
@@ -399,8 +427,8 @@
|
|||||||
}}
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
icon={Link}
|
||||||
>
|
>
|
||||||
<Icon src={Link} size="16" micro />
|
|
||||||
{$t('form.post.addUrl')}
|
{$t('form.post.addUrl')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -410,23 +438,33 @@
|
|||||||
}}
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
icon={Photo}
|
||||||
>
|
>
|
||||||
<Icon src={Photo} size="16" micro />
|
|
||||||
{$t('form.post.uploadImage')}
|
{$t('form.post.uploadImage')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.language_id === undefined}
|
{#if data.language_id === undefined}
|
||||||
<Button size="sm" rounding="pill" onclick={() => (data.language_id = 0)}>
|
<Button
|
||||||
<Icon src={Language} size="16" micro />
|
size="sm"
|
||||||
|
rounding="pill"
|
||||||
|
onclick={() => (data.language_id = 0)}
|
||||||
|
icon={Language}
|
||||||
|
>
|
||||||
{$t('form.post.setLanguage')}
|
{$t('form.post.setLanguage')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if (data.community?.flair_list?.length ?? 0) > 0}
|
||||||
|
<Button
|
||||||
|
onclick={() => modal({ title: $t('form.post.flair'), snippet: flairs })}
|
||||||
|
size="sm"
|
||||||
|
rounding="pill"
|
||||||
|
icon={Tag}
|
||||||
|
color={(data.flair_list?.length ?? 0) > 0 ? 'primary' : 'secondary'}
|
||||||
|
>
|
||||||
|
{$t('form.post.flair')}
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if addAltText}
|
|
||||||
<div transition:slide={{ axis: 'y', duration: 150 }} class="w-full">
|
|
||||||
<TextInput label={$t('form.post.altText')} bind:value={data.alt_text} />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
<Switch bind:checked={data.nsfw}>{$t('form.post.nsfw')}</Switch>
|
<Switch bind:checked={data.nsfw}>{$t('form.post.nsfw')}</Switch>
|
||||||
{#if data.language_id !== undefined}
|
{#if data.language_id !== undefined}
|
||||||
{#if site.data}
|
{#if site.data}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="items-center flex flex-row gap-1 hover:underline max-w-full min-w-0 {clazz}"
|
class="items-center inline-flex flex-row gap-1 hover:underline max-w-full min-w-0 {clazz}"
|
||||||
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
||||||
data-sveltekit-preload-data="tap"
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -144,7 +144,8 @@
|
|||||||
"addUrl": "Add URL",
|
"addUrl": "Add URL",
|
||||||
"setLanguage": "Set language",
|
"setLanguage": "Set language",
|
||||||
"unset": "Unset",
|
"unset": "Unset",
|
||||||
"readMore": "Read more"
|
"readMore": "Read more",
|
||||||
|
"flair": "Add flair"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"displayName": "Display name",
|
"displayName": "Display name",
|
||||||
|
|||||||
@@ -140,7 +140,12 @@
|
|||||||
{:else if prefix}
|
{:else if prefix}
|
||||||
{@render prefix?.()}
|
{@render prefix?.()}
|
||||||
{:else if icon}
|
{:else if icon}
|
||||||
<Icon src={icon} size="16" mini />
|
<Icon
|
||||||
|
src={icon}
|
||||||
|
size="16"
|
||||||
|
mini
|
||||||
|
class={[color == 'secondary' && 'text-slate-600 dark:text-zinc-400']}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{@render suffix?.()}
|
{@render suffix?.()}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { type Snippet } from 'svelte'
|
import { type Snippet } from 'svelte'
|
||||||
import type { IconSource } from 'svelte-hero-icons'
|
import type { IconSource } from 'svelte-hero-icons'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
@@ -41,7 +42,7 @@ export const action = (action?: {
|
|||||||
}
|
}
|
||||||
: () => shownModal.set(undefined),
|
: () => shownModal.set(undefined),
|
||||||
type: action?.type ?? 'secondary',
|
type: action?.type ?? 'secondary',
|
||||||
content: action?.content || 'OK',
|
content: action?.content || t.get('common.back'),
|
||||||
close: action?.close ?? true,
|
close: action?.close ?? true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import type { Community } from '$lib/client/types'
|
import type { CommunityView } from '$lib/client/types'
|
||||||
|
|
||||||
interface SessionStorage {
|
interface SessionStorage {
|
||||||
lastSeenCommunity?: Community
|
lastSeenCommunity?: CommunityView
|
||||||
postDraft?: {
|
postDraft?: {
|
||||||
community: Community | null
|
community: CommunityView | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
image: FileList | null
|
image: FileList | null
|
||||||
|
|||||||
@@ -16,10 +16,7 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (browser)
|
if (browser)
|
||||||
setSessionStorage(
|
setSessionStorage('lastSeenCommunity', data.community.community_view)
|
||||||
'lastSeenCommunity',
|
|
||||||
data.community.community_view.community,
|
|
||||||
)
|
|
||||||
|
|
||||||
resumables.add({
|
resumables.add({
|
||||||
name: data.community.community_view.community.title,
|
name: data.community.community_view.community.title,
|
||||||
|
|||||||
Reference in new issue
Block a user