cleanup: delete unused files
This commit is contained in:
18 files changed
+55
-300
No files matched your search
@@ -82,7 +82,7 @@
|
|||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte'
|
import { fullCommunityName } from '$lib/util.svelte'
|
||||||
import type {
|
import type {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
import type { CommunityView } from '$lib/client/types'
|
import type { CommunityView } from '$lib/client/types'
|
||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
@@ -158,7 +158,9 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Subscribe {community}>
|
<Subscribe {community}>
|
||||||
{#snippet children({ subscribe, subscribing })}
|
{#snippet children({ subscribe, subscribing })}
|
||||||
{@const subscribed = isSubscribed(community.subscribed)}
|
{@const subscribed =
|
||||||
|
community.subscribed == 'Subscribed' ||
|
||||||
|
community.subscribed == 'Pending'}
|
||||||
<Button
|
<Button
|
||||||
disabled={subscribing || !profile.current?.jwt}
|
disabled={subscribing || !profile.current?.jwt}
|
||||||
loading={subscribing}
|
loading={subscribing}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { communityLink } from '$lib/lemmy/generic'
|
import { communityLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import type { Community } from '$lib/client/types'
|
import type { Community } from '$lib/client/types'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { PersonView, SiteView, Tagline } from '$lib/client/types'
|
import type { PersonView, SiteView, Tagline } from '$lib/client/types'
|
||||||
import { Badge } from 'mono-svelte'
|
import { Badge } from 'mono-svelte'
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import type { Person } from '$lib/client/types'
|
|
||||||
import { Button, Modal, toast } from 'mono-svelte'
|
|
||||||
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
open?: boolean
|
|
||||||
user: Person
|
|
||||||
}
|
|
||||||
|
|
||||||
let { open = $bindable(false), user }: Props = $props()
|
|
||||||
|
|
||||||
let message = $state('')
|
|
||||||
|
|
||||||
let loading = $state(false)
|
|
||||||
|
|
||||||
async function sendMessage() {
|
|
||||||
if (!profile.current?.jwt || message == '') return
|
|
||||||
|
|
||||||
loading = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
await getClient().createPrivateMessage({
|
|
||||||
content: message,
|
|
||||||
recipient_id: user.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
toast({
|
|
||||||
content: $t('toast.sentMessage'),
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
|
|
||||||
open = false
|
|
||||||
} catch (err) {
|
|
||||||
toast({
|
|
||||||
content: errorMessage(err as string),
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:open>
|
|
||||||
{#snippet customTitle()}
|
|
||||||
<h1 class="text-2xl font-bold">Message</h1>
|
|
||||||
{/snippet}
|
|
||||||
<form onsubmit={preventDefault(sendMessage)} class="flex flex-col gap-4">
|
|
||||||
<p class="inline-flex flex-row gap-2 items-center">
|
|
||||||
<Icon src={PaperAirplane} size="16" mini />
|
|
||||||
<UserLink avatar {user} />
|
|
||||||
</p>
|
|
||||||
<MarkdownEditor
|
|
||||||
bind:value={message}
|
|
||||||
label={$t('content.message')}
|
|
||||||
rows={4}
|
|
||||||
/>
|
|
||||||
<Button color="primary" size="lg" submit {loading} disabled={loading}>
|
|
||||||
{$t('common.send')}
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import type { PersonView } from '$lib/client/types'
|
import type { PersonView } from '$lib/client/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -21,16 +21,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if content != '-1'}
|
{#if content != '-1'}
|
||||||
<div class="flex flex-col {clazz}">
|
<dl class={['flex flex-col', clazz]}>
|
||||||
<span class="text-slate-600 dark:text-zinc-400 text-xs {labelClass}">
|
<dt class={['text-slate-600 dark:text-zinc-400 text-xs', labelClass]}>
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</dt>
|
||||||
<span class="text-base {contentClass}">
|
<dd class={['text-base', contentClass]}>
|
||||||
{#if formatted}
|
{#if formatted}
|
||||||
<FormattedNumber number={Number(content)} />
|
<FormattedNumber number={Number(content)} />
|
||||||
{:else}
|
{:else}
|
||||||
{content}
|
{content}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</dd>
|
||||||
</div>
|
</dl>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { communityLink } from '$lib/lemmy/generic'
|
import { communityLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { theme } from '$lib/ui/theme/theme.svelte'
|
import { theme } from '$lib/ui/theme/theme.svelte'
|
||||||
import { Badge, Option, Select } from 'mono-svelte'
|
import { Badge, Option, Select } from 'mono-svelte'
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { fullCommunityName } from '$lib/util.svelte'
|
|
||||||
import type { Community, Person } from '$lib/client/types'
|
|
||||||
|
|
||||||
export const communityLink = (community: Community, prefix: string = '') =>
|
|
||||||
`${prefix}/c/${fullCommunityName(community.name, community.actor_id)}`
|
|
||||||
|
|
||||||
export const userLink = (person: Person, prefix: string = '') =>
|
|
||||||
`${prefix}/u/${person.name}@${new URL(person.actor_id).hostname}`
|
|
||||||
@@ -36,19 +36,6 @@ export function addSubscription(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addAdmin(handle: string, added: boolean) {
|
|
||||||
const user = await client().resolveObject({
|
|
||||||
q: handle,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!user.person) throw new Error('No user found')
|
|
||||||
|
|
||||||
return await client().addAdmin({
|
|
||||||
added: added,
|
|
||||||
person_id: user.person.person.id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function hasFavorite(profile: ProfileInfo, id: number): boolean {
|
export function hasFavorite(profile: ProfileInfo, id: number): boolean {
|
||||||
return profile.favorites?.map((i) => i.id).includes(id) ?? false
|
return profile.favorites?.map((i) => i.id).includes(id) ?? false
|
||||||
}
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
interface Props {
|
|
||||||
defaultValue?: boolean
|
|
||||||
checked?: boolean | undefined
|
|
||||||
inlineDescription?: boolean
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
description?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
defaultValue = false,
|
|
||||||
checked = $bindable(defaultValue),
|
|
||||||
inlineDescription = false,
|
|
||||||
children,
|
|
||||||
description,
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<label
|
|
||||||
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
|
|
||||||
>
|
|
||||||
<input type="checkbox" bind:checked class="cursor-pointer" />
|
|
||||||
<div
|
|
||||||
class="inline-flex {inlineDescription
|
|
||||||
? 'flex-row'
|
|
||||||
: 'flex-col'} font-medium gap-1"
|
|
||||||
>
|
|
||||||
{@render children?.()}
|
|
||||||
{#if description}
|
|
||||||
<span class="font-normal text-slate-600 dark:text-zinc-400">
|
|
||||||
{@render description?.()}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
|
||||||
import Label from '../forms/Label.svelte'
|
|
||||||
import { generateID } from '../forms/helper.js'
|
|
||||||
import TextInput from './TextInput.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
accept?: string
|
|
||||||
files?: FileList | undefined | null
|
|
||||||
label?: string | undefined
|
|
||||||
id?: string
|
|
||||||
url?: string | undefined
|
|
||||||
customLabel?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
accept = 'image/*',
|
|
||||||
files = $bindable(),
|
|
||||||
label = undefined,
|
|
||||||
id = generateID(),
|
|
||||||
url = undefined,
|
|
||||||
customLabel,
|
|
||||||
}: Props = $props()
|
|
||||||
|
|
||||||
let dragover = $state(false)
|
|
||||||
|
|
||||||
let previewURL = $derived(files ? URL.createObjectURL(files[0]) : undefined)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex flex-col">
|
|
||||||
{#if customLabel || label}
|
|
||||||
<Label for={id} text={label} class="mb-1">
|
|
||||||
{@render customLabel?.()}
|
|
||||||
</Label>
|
|
||||||
{/if}
|
|
||||||
<label
|
|
||||||
class={[
|
|
||||||
'flex flex-col items-center justify-center px-8 py-4 mx-auto w-full rounded-xl',
|
|
||||||
'border border-slate-200 dark:border-zinc-800 border-dashed hover:border-slate-300 hover:dark:border-zinc-700',
|
|
||||||
'cursor-pointer min-h-36 transition-colors bg-white dark:bg-zinc-950',
|
|
||||||
dragover && 'border-sky-500 text-sky-500',
|
|
||||||
]}
|
|
||||||
ondrop={(event) => {
|
|
||||||
event.preventDefault()
|
|
||||||
files = event.dataTransfer?.files ?? null
|
|
||||||
}}
|
|
||||||
ondragover={(event) => {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
if (event.dataTransfer) {
|
|
||||||
event.dataTransfer.dropEffect = 'copy'
|
|
||||||
dragover = true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
ondragleave={(e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
dragover = false
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#if files}
|
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
|
||||||
<img
|
|
||||||
src={previewURL}
|
|
||||||
onload={() => {
|
|
||||||
if (previewURL) URL.revokeObjectURL(previewURL)
|
|
||||||
}}
|
|
||||||
class="w-full max-w-sm h-full rounded-lg"
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<Icon
|
|
||||||
src={DocumentPlus}
|
|
||||||
class="text-slate-400 dark:text-zinc-500"
|
|
||||||
size="36"
|
|
||||||
solid
|
|
||||||
/>
|
|
||||||
<p class="text-slate-600 dark:text-zinc-400 font-medium">Attach a file</p>
|
|
||||||
{/if}
|
|
||||||
<input type="file" bind:files {accept} class="hidden" />
|
|
||||||
</label>
|
|
||||||
{#if url != undefined}
|
|
||||||
<TextInput
|
|
||||||
class="rounded-t-none border-t-0 rounded-xl"
|
|
||||||
placeholder="https://example.com/img1.png"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -12,9 +12,7 @@ export { default as TextInput } from './forms/TextInput.svelte'
|
|||||||
export { default as TextArea } from './forms/TextArea.svelte'
|
export { default as TextArea } from './forms/TextArea.svelte'
|
||||||
export { default as Select } from './forms/select/Select.svelte'
|
export { default as Select } from './forms/select/Select.svelte'
|
||||||
export { default as Option } from './forms/select/Option.svelte'
|
export { default as Option } from './forms/select/Option.svelte'
|
||||||
export { default as ImageInput } from './forms/ImageInput.svelte'
|
|
||||||
|
|
||||||
export { default as Checkbox } from './forms/Checkbox.svelte'
|
|
||||||
export { default as Switch } from './forms/Switch.svelte'
|
export { default as Switch } from './forms/Switch.svelte'
|
||||||
|
|
||||||
export { default as Popover } from './popover/Popover.svelte'
|
export { default as Popover } from './popover/Popover.svelte'
|
||||||
|
|||||||
@@ -58,14 +58,12 @@ interface Settings {
|
|||||||
presets: Preset[]
|
presets: Preset[]
|
||||||
defaultRemoveAction: 'comment' | 'message' | null
|
defaultRemoveAction: 'comment' | 'message' | null
|
||||||
}
|
}
|
||||||
randomPlaceholders: boolean
|
|
||||||
modlogCardView: boolean | undefined
|
modlogCardView: boolean | undefined
|
||||||
debugInfo: boolean
|
debugInfo: boolean
|
||||||
expandImages: boolean
|
expandImages: boolean
|
||||||
|
|
||||||
font: 'inter' | 'system' | 'browser'
|
font: 'inter' | 'system' | 'browser'
|
||||||
leftAlign: boolean
|
leftAlign: boolean
|
||||||
hidePhoton: boolean
|
|
||||||
|
|
||||||
newWidth: boolean
|
newWidth: boolean
|
||||||
markPostsAsRead: boolean
|
markPostsAsRead: boolean
|
||||||
@@ -143,14 +141,12 @@ export const defaultSettings: Settings = {
|
|||||||
],
|
],
|
||||||
defaultRemoveAction: null,
|
defaultRemoveAction: null,
|
||||||
},
|
},
|
||||||
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? false,
|
|
||||||
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
|
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
|
||||||
debugInfo: toBool(env.PUBLIC_DEBUG_INFO) ?? false,
|
debugInfo: toBool(env.PUBLIC_DEBUG_INFO) ?? false,
|
||||||
expandImages: toBool(env.PUBLIC_EXPAND_IMAGES) ?? true,
|
expandImages: toBool(env.PUBLIC_EXPAND_IMAGES) ?? true,
|
||||||
view: (env.PUBLIC_VIEW as View) ?? 'compact',
|
view: (env.PUBLIC_VIEW as View) ?? 'compact',
|
||||||
font: (env.PUBLIC_FONT as 'inter') ?? 'inter',
|
font: (env.PUBLIC_FONT as 'inter') ?? 'inter',
|
||||||
leftAlign: toBool(env.PUBLIC_LEFT_ALIGN) ?? false,
|
leftAlign: toBool(env.PUBLIC_LEFT_ALIGN) ?? false,
|
||||||
hidePhoton: toBool(env.PUBLIC_REMOVE_CREDIT) ?? false,
|
|
||||||
newWidth: toBool(env.PUBLIC_LIMIT_LAYOUT_WIDTH) ?? true,
|
newWidth: toBool(env.PUBLIC_LIMIT_LAYOUT_WIDTH) ?? true,
|
||||||
markPostsAsRead: toBool(env.PUBLIC_MARK_POSTS_AS_READ) ?? true,
|
markPostsAsRead: toBool(env.PUBLIC_MARK_POSTS_AS_READ) ?? true,
|
||||||
openLinksInNewTab: false,
|
openLinksInNewTab: false,
|
||||||
|
|||||||
+9
-38
@@ -1,12 +1,9 @@
|
|||||||
|
import { browser } from '$app/environment'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import type { SubscribedType } from '$lib/client/types'
|
|
||||||
import { toast } from 'mono-svelte'
|
|
||||||
import { t } from './i18n/translations'
|
|
||||||
import { errorMessage } from './lemmy/error'
|
|
||||||
import { SvelteURL } from 'svelte/reactivity'
|
import { SvelteURL } from 'svelte/reactivity'
|
||||||
import { browser } from '$app/environment'
|
import { t } from './i18n/translations'
|
||||||
|
import type { Community, Person } from './client/types'
|
||||||
|
|
||||||
// Despite the name, this will round up
|
// Despite the name, this will round up
|
||||||
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
|
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
|
||||||
@@ -32,28 +29,7 @@ export const fullCommunityName = (name: string, actorId: string) =>
|
|||||||
`${name}@${new SvelteURL(actorId).hostname}`
|
`${name}@${new SvelteURL(actorId).hostname}`
|
||||||
|
|
||||||
export const placeholders = {
|
export const placeholders = {
|
||||||
url: ['https://example.com'],
|
|
||||||
post: [
|
|
||||||
'Does anybody read these placeholders?',
|
|
||||||
'Top 10 reasons why a meteor would help Earth',
|
|
||||||
'Title text',
|
|
||||||
'I took a picture of something idk',
|
|
||||||
],
|
|
||||||
body: ['bottom text', 'body text', 'body text'],
|
|
||||||
comment: [
|
|
||||||
'what?',
|
|
||||||
'new response just dropped',
|
|
||||||
'this comment placeholder is very important dont forget',
|
|
||||||
'existential crisis in progress',
|
|
||||||
'hello user i am a sentient placeholder. please dont type anything or i disappear forever. thanks',
|
|
||||||
],
|
|
||||||
get: (type: 'url' | 'post' | 'body' | 'comment') => {
|
get: (type: 'url' | 'post' | 'body' | 'comment') => {
|
||||||
if (settings.randomPlaceholders) {
|
|
||||||
return placeholders[type][
|
|
||||||
Math.floor(Math.random() * placeholders[type].length)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'post':
|
case 'post':
|
||||||
return t.get('placeholders.title')
|
return t.get('placeholders.title')
|
||||||
@@ -92,18 +68,11 @@ export function moveItem<T>(
|
|||||||
return newArray
|
return newArray
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeItem = <T>(array: T[], predicate: (item: T) => boolean) => {
|
|
||||||
array.splice(array.findIndex(predicate), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DOMAIN_REGEX =
|
export const DOMAIN_REGEX =
|
||||||
/^(http(s)?:\/\/)?((?!-)[A-Za-z0-9-]{1,63}\.)+[A-Za-z]{2,63}(:[0-9]{0,5})?$/g
|
/^(http(s)?:\/\/)?((?!-)[A-Za-z0-9-]{1,63}\.)+[A-Za-z]{2,63}(:[0-9]{0,5})?$/g
|
||||||
export const DOMAIN_REGEX_FORMS =
|
export const DOMAIN_REGEX_FORMS =
|
||||||
'(http(s)?://)?((?!-)[A-Za-z0-9]{1,63}.)+[A-Za-z]{2,63}(:[0-9]{0,5})?'
|
'(http(s)?://)?((?!-)[A-Za-z0-9]{1,63}.)+[A-Za-z]{2,63}(:[0-9]{0,5})?'
|
||||||
|
|
||||||
export const isSubscribed = (subscribed: SubscribedType) =>
|
|
||||||
subscribed == 'Pending' || subscribed == 'Subscribed'
|
|
||||||
|
|
||||||
export async function uploadImage(
|
export async function uploadImage(
|
||||||
image: File | null | undefined,
|
image: File | null | undefined,
|
||||||
instance: string,
|
instance: string,
|
||||||
@@ -136,10 +105,6 @@ export function canParseUrl(url: string): boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function instanceId(actorId: string) {
|
|
||||||
return new SvelteURL(actorId).hostname
|
|
||||||
}
|
|
||||||
|
|
||||||
export function escapeHtml(input: string): string {
|
export function escapeHtml(input: string): string {
|
||||||
return input
|
return input
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
@@ -214,3 +179,9 @@ export const isVideo = (url: string | undefined) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const communityLink = (community: Community, prefix: string = '') =>
|
||||||
|
`${prefix}/c/${fullCommunityName(community.name, community.actor_id)}`
|
||||||
|
|
||||||
|
export const userLink = (person: Person, prefix: string = '') =>
|
||||||
|
`${prefix}/u/${person.name}@${new SvelteURL(person.actor_id).hostname}`
|
||||||
@@ -1,22 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
|
import UserAutocomplete from '$lib/components/lemmy/user/UserAutocomplete.svelte'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import { Header } from '$lib/components/ui/layout'
|
import { Header } from '$lib/components/ui/layout'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { instance } from '$lib/instance.svelte.js'
|
import { errorMessage } from '$lib/lemmy/error.js'
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
import { Button, toast } from 'mono-svelte'
|
||||||
import { addAdmin } from '$lib/lemmy/user.js'
|
|
||||||
import { trycatch } from '$lib/util.svelte.js'
|
|
||||||
import { Button, TextInput, toast } from 'mono-svelte'
|
|
||||||
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
|
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data: pageData } = $props()
|
let { data: pageData } = $props()
|
||||||
let data = $state(pageData)
|
let data = $state(pageData)
|
||||||
|
|
||||||
let newAdmin: string = $state(''),
|
let newAdmin = $state<number>(),
|
||||||
adding: boolean = $state(false)
|
adding: boolean = $state(false)
|
||||||
|
|
||||||
async function removeAdmin(
|
async function removeAdmin(
|
||||||
@@ -31,19 +28,22 @@
|
|||||||
|
|
||||||
if (!profile.current?.jwt) return
|
if (!profile.current?.jwt) return
|
||||||
|
|
||||||
const result = await trycatch(() =>
|
try {
|
||||||
getClient().addAdmin({
|
const res = await client().addAdmin({
|
||||||
added: false,
|
added: false,
|
||||||
person_id: id,
|
person_id: id,
|
||||||
}),
|
})
|
||||||
)
|
|
||||||
|
|
||||||
if (result) {
|
data.site.admins = res.admins
|
||||||
data.site!.admins = result.admins
|
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.removeAdmin'),
|
content: $t('toast.removeAdmin'),
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
toast({
|
||||||
|
content: errorMessage(err as string),
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -75,32 +75,33 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<form
|
<form
|
||||||
class="flex flex-row gap-2 mt-auto w-full"
|
class="flex flex-row gap-2 mt-auto w-full"
|
||||||
onsubmit={preventDefault(() => {
|
onsubmit={async (e) => {
|
||||||
trycatch(async () => {
|
e.preventDefault()
|
||||||
if (!profile.current?.jwt || newAdmin == '') return
|
if (!profile.current?.jwt || !newAdmin) return
|
||||||
adding = true
|
adding = true
|
||||||
|
|
||||||
const r = await addAdmin(`${newAdmin}@${instance.data}`, true)
|
const res = await client().addAdmin({
|
||||||
if (!r) return
|
added: true,
|
||||||
|
person_id: newAdmin,
|
||||||
|
})
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
content: 'Successfully added that admin.',
|
content: 'Successfully added that admin.',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (data.site) data.site.admins = r.admins
|
if (data.site) data.site.admins = res.admins
|
||||||
|
|
||||||
newAdmin = ''
|
newAdmin = undefined
|
||||||
adding = false
|
adding = false
|
||||||
})
|
}}
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<TextInput
|
<div class="w-full">
|
||||||
bind:value={newAdmin}
|
<UserAutocomplete
|
||||||
placeholder="@user"
|
listing_type="All"
|
||||||
class="flex-1"
|
onselect={(p) => (newAdmin = p.id)}
|
||||||
pattern={'@[^ |]{1,}'}
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
loading={adding}
|
loading={adding}
|
||||||
disabled={adding}
|
disabled={adding}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { communityLink } from '$lib/lemmy/generic.js'
|
import { communityLink } from '$lib/util.svelte.js'
|
||||||
import { isCommentView } from '$lib/lemmy/item.js'
|
import { isCommentView } from '$lib/lemmy/item.js'
|
||||||
import { Option, Select } from 'mono-svelte'
|
import { Option, Select } from 'mono-svelte'
|
||||||
import { AdjustmentsHorizontal, Icon, PencilSquare } from 'svelte-hero-icons'
|
import { AdjustmentsHorizontal, Icon, PencilSquare } from 'svelte-hero-icons'
|
||||||
|
|||||||
Reference in new issue
Block a user