Merge branch 'main' into listview-selfpost-thumbnail
This commit is contained in:
53 files changed
+2061
-441
No files matched your search
+14
-13
@@ -1,17 +1,6 @@
|
||||
{
|
||||
"name": "photon-lemmy",
|
||||
"version": "1.30.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"test": "vitest",
|
||||
"preview": "vite preview",
|
||||
"start": "node build/index.js",
|
||||
"bunstart": "bun build/index.js",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"version": "1.31.0",
|
||||
"devDependencies": {
|
||||
"@catdadcode/svelte-adapter-bun": "^0.5.7",
|
||||
"@dicebear/core": "^8.0.1",
|
||||
@@ -22,6 +11,7 @@
|
||||
"@sveltejs/kit": "latest",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||
"@tailwindcss/container-queries": "^0.1.1",
|
||||
"@tanstack/svelte-virtual": "^3.8.1",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@types/markdown-it-container": "^2.0.6",
|
||||
"@types/nprogress": "^0.2.0",
|
||||
@@ -40,7 +30,7 @@
|
||||
"svelte": "latest",
|
||||
"svelte-check": "^3.0.1",
|
||||
"svelte-hero-icons": "^5.0.0",
|
||||
"svelte-tiny-virtual-list": "^2.0.5",
|
||||
"svelte-infinite-scroll": "^2.0.1",
|
||||
"sveltekit-i18n": "^2.4.2",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tslib": "^2.4.1",
|
||||
@@ -50,5 +40,16 @@
|
||||
"vitest": "^1.0.0",
|
||||
"workbox-window": "^7.0.0"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"test": "vitest",
|
||||
"preview": "vite preview",
|
||||
"start": "node build/index.js",
|
||||
"bunstart": "bun build/index.js",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
+86
-130
@@ -4,7 +4,8 @@ import {
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { client, getClient, site } from '$lib/lemmy.js'
|
||||
import { client, getClient } from '$lib/lemmy.js'
|
||||
import { site } from './lemmy'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { instanceToURL, moveItem } from '$lib/util.js'
|
||||
import {
|
||||
@@ -13,7 +14,7 @@ import {
|
||||
type MyUserInfo,
|
||||
type Community,
|
||||
} from 'lemmy-js-client'
|
||||
import { get, writable } from 'svelte/store'
|
||||
import { derived, get, writable, type Writable } from 'svelte/store'
|
||||
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
|
||||
import { browser } from '$app/environment'
|
||||
import { env } from '$env/dynamic/public'
|
||||
@@ -57,12 +58,12 @@ interface ProfileData {
|
||||
defaultInstance?: string
|
||||
}
|
||||
|
||||
interface PersonData extends MyUserInfo {
|
||||
notifications: {
|
||||
inbox: number
|
||||
reports: number
|
||||
applications: number
|
||||
}
|
||||
interface PersonData extends MyUserInfo {}
|
||||
|
||||
interface Notifications {
|
||||
inbox: number
|
||||
reports: number
|
||||
applications: number
|
||||
}
|
||||
|
||||
const getCookie = (key: string): string | undefined => {
|
||||
@@ -91,19 +92,77 @@ export let profileData = writable<ProfileData>(
|
||||
}
|
||||
)
|
||||
|
||||
// stupid hack to get dev server working
|
||||
// why does this always happen to me
|
||||
let fetchingUser = false
|
||||
|
||||
let initialInstance = get(profileData).defaultInstance
|
||||
export let profile = derived<Writable<ProfileData>, Profile>(
|
||||
profileData,
|
||||
(pd) => {
|
||||
const profile =
|
||||
pd.profiles.find((p) => p.id == pd.profile) ?? getDefaultProfile()
|
||||
|
||||
if (profile?.jwt) {
|
||||
if (!profile.user && !fetchingUser) {
|
||||
site.set(undefined)
|
||||
|
||||
fetchingUser = true
|
||||
|
||||
notifications.set({ applications: 0, inbox: 0, reports: 0 })
|
||||
|
||||
userFromJwt(profile.jwt, profile.instance)
|
||||
.then((res) => {
|
||||
if (!res?.user)
|
||||
toast({
|
||||
content: 'Your login has expired. Re-login to fix this issue.',
|
||||
type: 'warning',
|
||||
})
|
||||
|
||||
site.set(res?.site)
|
||||
|
||||
profile.user = res?.user
|
||||
profile.avatar = res?.user.local_user_view.person.avatar
|
||||
|
||||
checkInbox()
|
||||
|
||||
fetchingUser = false
|
||||
})
|
||||
.catch((e) => {
|
||||
fetchingUser = false
|
||||
toast({ content: e, type: 'error' })
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (browser) {
|
||||
site.set(undefined)
|
||||
client({ instanceURL: profile.instance })
|
||||
.getSite()
|
||||
.then((res) => site.set(res))
|
||||
}
|
||||
}
|
||||
|
||||
instance.set(profile.instance)
|
||||
|
||||
return profile
|
||||
}
|
||||
)
|
||||
|
||||
export let notifications = writable<Notifications>({
|
||||
applications: 0,
|
||||
inbox: 0,
|
||||
reports: 0,
|
||||
})
|
||||
|
||||
profileData.subscribe(async (pd) => {
|
||||
setFromStorage('profileData', pd)
|
||||
const serialized: ProfileData = {
|
||||
...pd,
|
||||
profiles: pd.profiles.map((p) => serializeUser(p)),
|
||||
}
|
||||
|
||||
if (pd.profile == -1 && initialInstance != pd.defaultInstance) {
|
||||
initialInstance = get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL
|
||||
setFromStorage('profileData', serialized)
|
||||
|
||||
if (serialized.profile == -1) {
|
||||
instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL)
|
||||
}
|
||||
if (pd.profiles.length == 0) {
|
||||
if (serialized.profiles.length == 0) {
|
||||
profileData.update((pd) => ({
|
||||
...pd,
|
||||
profiles: [
|
||||
@@ -145,43 +204,6 @@ if (
|
||||
}
|
||||
}
|
||||
|
||||
export let profile = writable<Profile | undefined>(getProfile())
|
||||
|
||||
profile.subscribe(async (p) => {
|
||||
if (p?.id == -1) {
|
||||
instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL)
|
||||
}
|
||||
if (!p) return
|
||||
|
||||
instance.set(p.instance)
|
||||
// fetch the user because p.user is undefined
|
||||
if (p?.jwt && !p?.user) {
|
||||
const user = await userFromJwt(p.jwt, p.instance)
|
||||
.then((user) => {
|
||||
if (!user?.user)
|
||||
toast({
|
||||
content: 'Your login has expired. Re-login to fix this issue.',
|
||||
type: 'warning',
|
||||
})
|
||||
site.set(user?.site)
|
||||
|
||||
return user
|
||||
})
|
||||
.catch((err) => {
|
||||
toast({ content: err as any, type: 'error' })
|
||||
})
|
||||
|
||||
if (!user?.user) return
|
||||
|
||||
profile.update(() => ({
|
||||
...p,
|
||||
user: user!.user,
|
||||
username: user?.user.local_user_view.person.name,
|
||||
avatar: user?.user.local_user_view.person.avatar,
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
export async function setUser(jwt: string, inst: string, username: string) {
|
||||
try {
|
||||
new URL(instanceToURL(inst))
|
||||
@@ -217,11 +239,6 @@ export async function setUser(jwt: string, inst: string, username: string) {
|
||||
avatar: user.user.local_user_view.person.avatar,
|
||||
}
|
||||
|
||||
profile.set({
|
||||
...newProfile,
|
||||
user: user!.user,
|
||||
})
|
||||
|
||||
return {
|
||||
profile: id,
|
||||
profiles: [newProfile, ...pd.profiles],
|
||||
@@ -261,32 +278,12 @@ async function userFromJwt(
|
||||
if (!myUser) return undefined
|
||||
|
||||
return {
|
||||
user: {
|
||||
notifications: {
|
||||
applications: 0,
|
||||
inbox: 0,
|
||||
reports: 0,
|
||||
},
|
||||
...myUser,
|
||||
},
|
||||
user: myUser,
|
||||
site: site,
|
||||
}
|
||||
}
|
||||
|
||||
function getProfile() {
|
||||
const id = get(profileData).profile
|
||||
|
||||
if (id == -1) {
|
||||
return getDefaultProfile()
|
||||
}
|
||||
|
||||
const pd = get(profileData)
|
||||
|
||||
return pd.profiles.find((p) => p.id == id)
|
||||
}
|
||||
|
||||
export function resetProfile() {
|
||||
profile.set(getDefaultProfile())
|
||||
profileData.update((p) => ({ ...p, profile: -1 }))
|
||||
}
|
||||
|
||||
@@ -308,10 +305,12 @@ export function deleteProfile(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
const serializeUser = (user: Profile): Profile => ({
|
||||
...user,
|
||||
user: undefined,
|
||||
})
|
||||
function serializeUser(user: Profile): Profile {
|
||||
return {
|
||||
...user,
|
||||
user: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
instance.subscribe(async (i) => {
|
||||
try {
|
||||
@@ -324,35 +323,8 @@ instance.subscribe(async (i) => {
|
||||
})
|
||||
|
||||
export async function setUserID(id: number) {
|
||||
const pd = get(profileData)
|
||||
if (id == -1) {
|
||||
resetProfile()
|
||||
instance.set(DEFAULT_INSTANCE_URL)
|
||||
return
|
||||
}
|
||||
|
||||
let prof = pd.profiles.find((p) => p.id == id)
|
||||
|
||||
if (!prof) return profile.update(() => getDefaultProfile())
|
||||
prof = serializeUser(prof)
|
||||
|
||||
profileData.update((p) => ({ ...p, profile: id }))
|
||||
|
||||
if (prof?.jwt) {
|
||||
const user = await userFromJwt(prof.jwt, prof.instance)
|
||||
.then((u) => u)
|
||||
.catch((err) => {
|
||||
toast({ content: err as any, type: 'error' })
|
||||
})
|
||||
instance.set(prof.instance)
|
||||
prof.user = user?.user
|
||||
prof.avatar = user?.user.local_user_view.person.avatar
|
||||
site.set(user?.site)
|
||||
}
|
||||
|
||||
profile.update(() => prof ?? getDefaultProfile())
|
||||
|
||||
return prof
|
||||
return get(profile)
|
||||
}
|
||||
|
||||
export function moveProfile(id: number, up: boolean) {
|
||||
@@ -369,11 +341,7 @@ export function moveProfile(id: number, up: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
const getNotificationCount = async (
|
||||
jwt: string,
|
||||
mod: boolean,
|
||||
admin: boolean
|
||||
) => {
|
||||
async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
|
||||
const unreads = await getClient().getUnreadCount()
|
||||
|
||||
let reports: number = 0
|
||||
@@ -419,26 +387,14 @@ async function checkInbox() {
|
||||
const notifs = await getNotificationCount(
|
||||
jwt,
|
||||
amModOfAny(user) ?? false,
|
||||
isAdmin(user)
|
||||
user ? isAdmin(user) : false
|
||||
)
|
||||
|
||||
user.notifications = {
|
||||
notifications.set({
|
||||
inbox: notifs.unreads,
|
||||
applications: notifs.applications,
|
||||
reports: notifs.reports,
|
||||
}
|
||||
|
||||
profile.update((p) => ({
|
||||
...p!,
|
||||
user: user,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
setInterval(checkInbox, 4 * 60 * 1000)
|
||||
|
||||
let prevId: number | undefined = -2
|
||||
profile.subscribe((p) => {
|
||||
if (p?.id == prevId || !p?.user) return
|
||||
prevId = p?.id
|
||||
if (p.id != -1) checkInbox()
|
||||
})
|
||||
@@ -16,6 +16,7 @@
|
||||
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {$$props.class ||
|
||||
''}"
|
||||
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
||||
data-sveltekit-preload-data="tap"
|
||||
>
|
||||
{#if avatar}
|
||||
<Avatar
|
||||
@@ -28,7 +29,7 @@
|
||||
|
||||
{#if name}
|
||||
<span class="flex gap-0 items-center max-w-full min-w-0 flex-shrink">
|
||||
<span class="font-medium">{community.title}</span>
|
||||
<span class="font-medium username-text">{community.title}</span>
|
||||
{#if showInstance}
|
||||
<span
|
||||
class="text-slate-500 dark:text-zinc-500 font-normal
|
||||
@@ -47,5 +48,12 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.username-text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -5,7 +5,10 @@
|
||||
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import PostMeta, {
|
||||
parseTags,
|
||||
type Tag,
|
||||
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { Badge, Material, toast } from 'mono-svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
|
||||
@@ -34,6 +37,10 @@
|
||||
export let view = $userSettings.view
|
||||
|
||||
$: type = mediaType(post.post.url, view)
|
||||
|
||||
$: tags = parseTags(post.post.name)
|
||||
$: rule = getTagRule(tags.tags)
|
||||
|
||||
$: hideTitle =
|
||||
$userSettings.posts.deduplicateEmbed &&
|
||||
post.post.embed_title == post.post.name &&
|
||||
@@ -45,6 +52,19 @@
|
||||
post.post.embed_description == post.post.body &&
|
||||
view != 'compact'
|
||||
|
||||
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
|
||||
const tagContent = tags.map((t) => t.content.toLowerCase())
|
||||
|
||||
let rule: 'blur' | 'hide' | undefined
|
||||
tagContent.forEach((tag) => {
|
||||
if ($userSettings.tagRules?.[tag])
|
||||
rule = $userSettings.tagRules?.[tag] ?? rule
|
||||
if (rule == 'hide') return rule
|
||||
})
|
||||
|
||||
return rule
|
||||
}
|
||||
|
||||
function onClick(e: any) {
|
||||
const event = e as MouseEvent
|
||||
const parent = document.getElementById(post.post.id.toString())
|
||||
@@ -55,11 +75,16 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
This is the sole component for displaying posts.
|
||||
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
|
||||
-->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<Material
|
||||
color={view != 'card' ? 'none' : 'distinct'}
|
||||
class="relative max-w-full min-w-0 w-full group cursor-pointer
|
||||
class="post relative max-w-full min-w-0 w-full group cursor-pointer
|
||||
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
|
||||
? 'py-4 list-type'
|
||||
: view == 'list'
|
||||
@@ -70,9 +95,11 @@
|
||||
on:click={(e) => {
|
||||
onClick(e)
|
||||
}}
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
<PostMeta
|
||||
community={hideCommunity ? undefined : post.community}
|
||||
community={post.community}
|
||||
showCommunity={!hideCommunity}
|
||||
user={post.creator}
|
||||
published={publishedToDate(post.post.published)}
|
||||
badges={{
|
||||
@@ -91,9 +118,10 @@
|
||||
? 'Subscribed'
|
||||
: 'NotSubscribed'}
|
||||
id={post.post.id}
|
||||
title={hideTitle ? undefined : post.post.name}
|
||||
title={hideTitle ? undefined : tags?.title ? tags.title : post.post.name}
|
||||
read={post.read}
|
||||
style="grid-area: meta;"
|
||||
tags={tags?.tags}
|
||||
>
|
||||
<slot name="badges" slot="badges" />
|
||||
</PostMeta>
|
||||
@@ -102,12 +130,19 @@
|
||||
style="grid-area:embed;"
|
||||
class={view == 'list' || view == 'compact' ? '' : 'contents'}
|
||||
>
|
||||
<PostMedia bind:post={post.post} {view} {type} />
|
||||
{#if rule != 'hide'}
|
||||
<PostMedia
|
||||
bind:post={post.post}
|
||||
blur={rule == 'blur' ? true : undefined}
|
||||
{view}
|
||||
{type}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{#if view == 'list' || view == 'compact'}
|
||||
<PostMediaCompact
|
||||
bind:post={post.post}
|
||||
bind:type={type}
|
||||
bind:type
|
||||
class="{$userSettings.leftAlign
|
||||
? 'mr-2'
|
||||
: 'ml-2'} flex-shrink no-list-margin"
|
||||
@@ -115,7 +150,7 @@
|
||||
/>
|
||||
{/if}
|
||||
{/key}
|
||||
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody}
|
||||
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody && rule != 'hide'}
|
||||
<PostBody body={post.post.body} {view} style="grid-area: body" />
|
||||
{/if}
|
||||
{#if actions}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import { t } from '$lib/translations'
|
||||
import { slide } from 'svelte/transition'
|
||||
import { feature } from '$lib/version'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let edit = false
|
||||
|
||||
@@ -140,7 +141,7 @@
|
||||
community_id: data.community!.id,
|
||||
name: data.title,
|
||||
body: data.body,
|
||||
url: data.url,
|
||||
url: data.url || undefined,
|
||||
nsfw: data.nsfw,
|
||||
custom_thumbnail: data.thumbnail,
|
||||
alt_text: data.alt_text,
|
||||
@@ -228,9 +229,9 @@
|
||||
|
||||
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
|
||||
<slot name="formtitle">
|
||||
<h1 class="font-bold text-xl">
|
||||
<Header class="font-bold text-xl">
|
||||
{edit ? $t('form.post.edit') : $t('form.post.create')}
|
||||
</h1>
|
||||
</Header>
|
||||
</slot>
|
||||
{#if !edit && data}
|
||||
{#if !data.community}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
||||
import { Material } from 'mono-svelte'
|
||||
import { Button, Material } from 'mono-svelte'
|
||||
import { Icon, Link as LinkIcon } from 'svelte-hero-icons'
|
||||
import { optimizeImageURL } from './helpers'
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
$: richURL = parseURL(url)
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
For embed-type posts. Displays embed card or a compact link.
|
||||
-->
|
||||
{#if embed_title && !compact}
|
||||
<Material color="distinct" class="flex flex-row gap-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
@@ -60,12 +64,15 @@
|
||||
{/if}
|
||||
</Material>
|
||||
{:else}
|
||||
<Link
|
||||
<Button
|
||||
href={url}
|
||||
target="_blank"
|
||||
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-sm"
|
||||
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-xs overflow-hidden w-max max-w-full"
|
||||
size="sm"
|
||||
color="ghost"
|
||||
rounding="pill"
|
||||
>
|
||||
<Icon src={LinkIcon} size="14" mini slot="icon" class="flex-shrink-0" />
|
||||
<Icon src={LinkIcon} size="14" mini slot="prefix" class="flex-shrink-0" />
|
||||
{#if richURL}
|
||||
<div class="flex max-w-full overflow-hidden">
|
||||
{richURL.hostname}
|
||||
@@ -76,7 +83,7 @@
|
||||
{:else}
|
||||
{url}
|
||||
{/if}
|
||||
</Link>
|
||||
</Button>
|
||||
{#if thumbnail_url && !compact}
|
||||
<a href={url} target="_blank">
|
||||
<img
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
<script lang="ts" context="module">
|
||||
export interface Tag {
|
||||
content: string
|
||||
color?: string
|
||||
icon?: IconSource
|
||||
}
|
||||
|
||||
export const textToTag: Map<string, Tag> = new Map<string, Tag>([
|
||||
['OC', { content: 'OC', color: '#03A8F240' }],
|
||||
['NSFL', { content: 'NSFL', color: '#ff000040' }],
|
||||
['CW', { content: 'CW', color: '#ff000040' }],
|
||||
])
|
||||
|
||||
export const parseTags = (
|
||||
title?: string
|
||||
): { tags: Tag[]; title?: string } => {
|
||||
if (!title) return { tags: [] }
|
||||
|
||||
let extracted: Tag[] = []
|
||||
|
||||
title = title.replace(/\[(.*?)\]/g, (match, content) => {
|
||||
extracted.push(
|
||||
textToTag.get(content) ?? {
|
||||
content: content,
|
||||
}
|
||||
)
|
||||
return ''
|
||||
})
|
||||
|
||||
return {
|
||||
tags: extracted,
|
||||
title: title,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
@@ -13,6 +49,7 @@
|
||||
LockClosed,
|
||||
Megaphone,
|
||||
Plus,
|
||||
Tag,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
@@ -22,8 +59,10 @@
|
||||
import { userSettings } from '$lib/settings'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import type { IconSource } from 'svelte-hero-icons'
|
||||
|
||||
export let community: Community | undefined = undefined
|
||||
export let showCommunity: boolean = true
|
||||
export let subscribed: SubscribedType | undefined = undefined
|
||||
|
||||
export let user: Person | undefined = undefined
|
||||
@@ -43,15 +82,29 @@
|
||||
moderator: false,
|
||||
admin: false,
|
||||
}
|
||||
|
||||
export let tags: Tag[] = []
|
||||
|
||||
$: {
|
||||
if (title && tags.length == 0) {
|
||||
const result = parseTags(title)
|
||||
tags = result.tags
|
||||
title = result.title
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
This component will build two different things: a post's meta block and the title.
|
||||
-->
|
||||
<div
|
||||
class="grid w-full meta {community
|
||||
? 'grid-rows-2'
|
||||
: 'grid-rows-1'} text-xs min-w-0 max-w-full"
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
{#if community}
|
||||
{#if showCommunity && community}
|
||||
<Subscribe let:subscribe let:subscribing>
|
||||
<button
|
||||
on:click={async () => {
|
||||
@@ -74,8 +127,8 @@
|
||||
class="absolute w-3.5 h-3.5 {subscribed == 'NotSubscribed'
|
||||
? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black'
|
||||
: 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border
|
||||
ring-slate-50 dark:ring-zinc-950
|
||||
-bottom-1 right-1 grid place-items-center transition-all"
|
||||
ring-slate-50 dark:ring-zinc-950 grid place-items-center transition-all
|
||||
right-0 -translate-x-1 -translate-y-2"
|
||||
>
|
||||
<Icon
|
||||
src={subscribed == 'NotSubscribed' ? Plus : Check}
|
||||
@@ -87,19 +140,19 @@
|
||||
</button>
|
||||
</Subscribe>
|
||||
{/if}
|
||||
{#if community}
|
||||
{#if showCommunity && community}
|
||||
<CommunityLink
|
||||
{community}
|
||||
style="grid-area: community;"
|
||||
class="flex-shrink"
|
||||
class="flex-shrink self-end"
|
||||
/>
|
||||
{/if}
|
||||
<span
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center"
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center self-start"
|
||||
style="grid-area: stats;"
|
||||
>
|
||||
{#if user}
|
||||
<UserLink avatarSize={20} {user} avatar={!community}>
|
||||
<UserLink avatarSize={20} {user} avatar={!showCommunity}>
|
||||
<svelte:fragment slot="badges">
|
||||
{#if badges.moderator}
|
||||
<ShieldIcon filled width={14} class="text-green-500" />
|
||||
@@ -115,9 +168,29 @@
|
||||
{/if}
|
||||
</span>
|
||||
<div
|
||||
class="flex flex-row items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges"
|
||||
class="flex flex-row justify-end items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges ml-2"
|
||||
style="grid-area: badges;"
|
||||
>
|
||||
{#if tags}
|
||||
{#each tags as tag}
|
||||
<a
|
||||
class="hover:brightness-110"
|
||||
href="/search?community={community?.id}&q=[{tag.content}]&type=Posts"
|
||||
style={tag.color ? `--tag-color: ${tag.color};` : ''}
|
||||
>
|
||||
<Badge class={tag.color ? 'badge-tag-color' : ''}>
|
||||
<svelte:fragment slot="icon">
|
||||
{#if tag.icon}
|
||||
<Icon src={tag.icon} micro size="14" />
|
||||
{:else}
|
||||
<Icon src={Tag} micro size="14" />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
{tag.content}
|
||||
</Badge>
|
||||
</a>
|
||||
{/each}
|
||||
{/if}
|
||||
{#if badges.nsfw}
|
||||
<Badge label={$t('post.badges.nsfw')} color="red-subtle" allowIconOnly>
|
||||
<Icon src={ExclamationTriangle} size="14" micro slot="icon" />
|
||||
@@ -180,9 +253,12 @@
|
||||
class:text-slate-600={$userSettings.markReadPosts && read}
|
||||
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
|
||||
style="grid-area: title;"
|
||||
data-sveltekit-preload-data="tap"
|
||||
>
|
||||
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown>
|
||||
</a>
|
||||
{:else}
|
||||
<div style="grid-area: title; margin: 0;"></div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
@@ -193,6 +269,10 @@
|
||||
'avatar stats badges';
|
||||
gap: 0;
|
||||
grid-template-rows: auto auto;
|
||||
grid-template-columns: auto 1fr auto;
|
||||
grid-template-columns: max-content minmax(0, auto) auto;
|
||||
}
|
||||
|
||||
:global(.badge-tag-color) {
|
||||
background-color: var(--tag-color) !important;
|
||||
}
|
||||
</style>
|
||||
+12
-9
@@ -7,6 +7,11 @@
|
||||
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
import { browser } from '$app/environment'
|
||||
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
|
||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||
import { afterNavigate, beforeNavigate } from '$app/navigation'
|
||||
import { _posts } from '../../../../../routes/+page.svelte'
|
||||
|
||||
type PostViewWithCrossposts = PostView & {
|
||||
withCrossposts: true
|
||||
@@ -98,16 +103,16 @@
|
||||
</Placeholder>
|
||||
</div>
|
||||
{:else}
|
||||
{#each combinedPosts as post, index (post.post.id)}
|
||||
{#each combinedPosts as post, index}
|
||||
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
|
||||
<li
|
||||
in:fly|global={{
|
||||
y: -8,
|
||||
duration: index < 4 ? 500 : 0,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: index < 4 ? index * 100 : 0,
|
||||
delay: 100 + index * 20,
|
||||
}}
|
||||
class="relative"
|
||||
class="relative post-container"
|
||||
>
|
||||
<Post
|
||||
hideCommunity={community}
|
||||
@@ -116,12 +121,9 @@
|
||||
? 'compact'
|
||||
: $userSettings.view}
|
||||
{post}
|
||||
class="transition-all duration-250 {post.withCrossposts &&
|
||||
viewPost != post.post.id
|
||||
? ''
|
||||
: ''}"
|
||||
class="transition-all duration-250"
|
||||
on:hide={() => {
|
||||
combinedPosts = combinedPosts.toSpliced(index, 1)
|
||||
posts = posts.toSpliced(index, 1)
|
||||
}}
|
||||
>
|
||||
<svelte:fragment slot="badges">
|
||||
@@ -175,4 +177,5 @@
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
<slot />
|
||||
</ul>
|
||||
@@ -0,0 +1,222 @@
|
||||
<script lang="ts">
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { PostView } from 'lemmy-js-client'
|
||||
import { Badge, Button } from 'mono-svelte'
|
||||
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
import { browser } from '$app/environment'
|
||||
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
|
||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||
import { afterNavigate, beforeNavigate } from '$app/navigation'
|
||||
import { _posts } from '../../../../../routes/+page.svelte'
|
||||
|
||||
type PostViewWithCrossposts = PostView & {
|
||||
withCrossposts: true
|
||||
crossposts: PostView[]
|
||||
}
|
||||
type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
|
||||
|
||||
export let posts: PostView[]
|
||||
export let community: boolean = false
|
||||
|
||||
const addCrosspostProperty = (
|
||||
post: PostView,
|
||||
crossposts: PostView[]
|
||||
): PostViewWithCrossposts => ({
|
||||
...post,
|
||||
crossposts: crossposts,
|
||||
withCrossposts: true,
|
||||
})
|
||||
|
||||
const combineCrossposts = (
|
||||
posts: PostView[]
|
||||
): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => {
|
||||
const urlMap = new Map<
|
||||
string,
|
||||
PostViewWithCrossposts | PostViewWithoutCrossposts
|
||||
>()
|
||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||
const seenUrls = new Set<string>()
|
||||
|
||||
posts?.forEach((post) => {
|
||||
if (
|
||||
!post ||
|
||||
($userSettings.hidePosts.deleted && post.post.deleted) ||
|
||||
($userSettings.hidePosts.removed && post.post.removed)
|
||||
)
|
||||
return
|
||||
if (!post?.post?.url) {
|
||||
results.push(post)
|
||||
return
|
||||
}
|
||||
|
||||
let existing = urlMap.get(post.post.url)
|
||||
if (existing) {
|
||||
existing.withCrossposts = true
|
||||
if (existing.withCrossposts) {
|
||||
existing.crossposts = [...(existing.crossposts || []), post]
|
||||
}
|
||||
|
||||
urlMap.set(post.post.url, existing)
|
||||
} else {
|
||||
urlMap.set(post.post.url, post)
|
||||
results.push(post)
|
||||
}
|
||||
seenUrls.add(post.post.url)
|
||||
})
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// $: combinedPosts = combineCrossposts(posts)
|
||||
|
||||
let viewPost: number = -1
|
||||
|
||||
const virtualizer = createWindowVirtualizer({
|
||||
count: posts.length,
|
||||
estimateSize: () => 150,
|
||||
})
|
||||
|
||||
$: if (posts.length)
|
||||
$virtualizer.setOptions({
|
||||
count: posts.length,
|
||||
})
|
||||
|
||||
let virtualItemEls: HTMLElement[] = []
|
||||
|
||||
$: items = $virtualizer.getVirtualItems()
|
||||
$: {
|
||||
if (virtualItemEls.length)
|
||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||
}
|
||||
|
||||
afterNavigate(() => {
|
||||
$virtualizer.scrollToIndex($_posts?.lastSeen)
|
||||
})
|
||||
</script>
|
||||
|
||||
<ul
|
||||
class="flex flex-col list-none {$userSettings.view == 'card'
|
||||
? 'gap-3 md:gap-4'
|
||||
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||
style={$userSettings.leftAlign
|
||||
? `--template-areas:
|
||||
'media meta'
|
||||
'media title'
|
||||
'media body'
|
||||
'embed embed'
|
||||
'actions actions'; --template-columns: auto 1fr;`
|
||||
: ``}
|
||||
>
|
||||
{#if posts?.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
<Placeholder
|
||||
icon={ArchiveBox}
|
||||
title="No posts"
|
||||
description="There are no posts that match this filter."
|
||||
>
|
||||
<Button href="/communities">
|
||||
<Icon src={Plus} size="16" mini slot="prefix" />
|
||||
<span>Follow some communities</span>
|
||||
</Button>
|
||||
</Placeholder>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- {#each combinedPosts as post, index} -->
|
||||
<!-- {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} -->
|
||||
<div
|
||||
style="position:relative; height: {browser
|
||||
? `${$virtualizer.getTotalSize()}px`
|
||||
: '100%'}; width: 100%;"
|
||||
>
|
||||
<div
|
||||
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items[0]
|
||||
? items[0].start
|
||||
: 0}px);"
|
||||
class="divide-y divide-slate-200 dark:divide-zinc-800"
|
||||
id="feed"
|
||||
>
|
||||
{#each items as row, index (row.index)}
|
||||
<li
|
||||
in:fly|global={{
|
||||
y: -8,
|
||||
duration: 300,
|
||||
opacity: 0,
|
||||
delay: 50 + index * 20,
|
||||
}}
|
||||
bind:this={virtualItemEls[index]}
|
||||
data-index={row.index}
|
||||
class="relative post-container"
|
||||
>
|
||||
<Post
|
||||
hideCommunity={community}
|
||||
view={(posts[row.index].post.featured_community ||
|
||||
posts[row.index].post.featured_local) &&
|
||||
$userSettings.posts.compactFeatured
|
||||
? 'compact'
|
||||
: $userSettings.view}
|
||||
post={posts[row.index]}
|
||||
class="transition-all duration-250"
|
||||
on:hide={() => {
|
||||
posts = posts.toSpliced(row.index, 1)
|
||||
}}
|
||||
>
|
||||
<svelte:fragment slot="badges">
|
||||
<!-- {#if posts[index].withCrossposts}
|
||||
<button
|
||||
on:click={() => {
|
||||
if (viewPost == posts[index].post.id) viewPost = -1
|
||||
else viewPost = posts[index].post.id
|
||||
}}
|
||||
>
|
||||
<Badge
|
||||
class="z-10 backdrop-blur-xl hover:brightness-110 cursor-pointer transition-all"
|
||||
color="gray-subtle"
|
||||
>
|
||||
{#if viewPost == posts[index].post.id}
|
||||
<Icon mini src={Minus} size="14" />
|
||||
{:else}
|
||||
<Icon mini src={Plus} size="14" />
|
||||
{/if}
|
||||
{posts[index].crossposts.length} crosspost{posts[index]
|
||||
.crossposts.length == 1
|
||||
? ''
|
||||
: 's'}
|
||||
</Badge>
|
||||
</button>{/if} -->
|
||||
</svelte:fragment>
|
||||
</Post>
|
||||
<!-- {#if posts[index].withCrossposts && viewPost == posts[index].post.id}
|
||||
<div
|
||||
transition:slide|global={{
|
||||
axis: 'y',
|
||||
duration: 500,
|
||||
easing: expoOut,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
class="text-sm flex flex-row gap-2 items-center"
|
||||
class:my-4={$userSettings.view == 'card'}
|
||||
>
|
||||
Crossposts <hr class="w-full dark:border-zinc-800" />
|
||||
{posts[index].crossposts.length}
|
||||
</span>
|
||||
{#each posts[index].crossposts as crosspost, index}
|
||||
<div class="w-full transition-all mb-4">
|
||||
<Post post={crosspost} view={$userSettings.view} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if} -->
|
||||
</li>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<!-- {/if} -->
|
||||
<!-- {/each} -->
|
||||
{/if}
|
||||
<slot />
|
||||
</ul>
|
||||
@@ -12,18 +12,19 @@ export const bestImageURL = (
|
||||
compact: boolean = true,
|
||||
width: number = 1024
|
||||
) => {
|
||||
if (width > 1024) {
|
||||
if (post.url) return `${post.url}?format=webp`
|
||||
else if (post.thumbnail_url) return `${post.thumbnail_url}?format=webp`
|
||||
}
|
||||
let fetchWidth =
|
||||
width > 1024
|
||||
? // -1 disables a small thumbnail
|
||||
-1
|
||||
: // set width to 512 if compact
|
||||
compact
|
||||
? 512
|
||||
: // otherwise, just use the original width
|
||||
width
|
||||
|
||||
if (compact && post.thumbnail_url)
|
||||
return `${post.thumbnail_url}?thumbnail=256&format=webp`
|
||||
else if (compact && post.url) return `${post.url}?thumbnail=256&format=webp`
|
||||
|
||||
if (post.url) return `${post.url}?thumbnail=${width}&format=webp`
|
||||
else if (post.thumbnail_url)
|
||||
return `${post.thumbnail_url}?thumbnail=${width}&format=webp`
|
||||
if (post.thumbnail_url)
|
||||
return optimizeImageURL(post.thumbnail_url, fetchWidth)
|
||||
else if (post.url) return optimizeImageURL(post.url, fetchWidth)
|
||||
|
||||
return post.url ?? ''
|
||||
}
|
||||
@@ -34,11 +35,16 @@ export const optimizeImageURL = (
|
||||
): string => {
|
||||
try {
|
||||
const url = new URL(urlStr)
|
||||
|
||||
url.searchParams.append('format', 'webp')
|
||||
url.searchParams.append(
|
||||
'thumbnail',
|
||||
findClosestNumber([128, 256, 512, 1024], width).toString()
|
||||
)
|
||||
|
||||
if (width > 0) {
|
||||
url.searchParams.append(
|
||||
'thumbnail',
|
||||
findClosestNumber([128, 256, 512, 728, 1024, 1536], width).toString()
|
||||
)
|
||||
}
|
||||
|
||||
return url.toString()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
@@ -92,6 +92,10 @@
|
||||
$: embedUrl = urlToEmbed(url)
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
Displays a video file or embedded video iframe.
|
||||
-->
|
||||
{#if opened}
|
||||
{#if type == 'video'}
|
||||
<!-- svelte-ignore a11y-media-has-caption -->
|
||||
|
||||
@@ -19,10 +19,17 @@
|
||||
export let post: Post
|
||||
export let type: MediaType = 'none'
|
||||
export let opened: boolean | undefined = undefined
|
||||
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
|
||||
|
||||
let showAltText = false
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
This component will show either
|
||||
- A media item (pictures, videos) (large form factor posts only)
|
||||
- Embed link/card.
|
||||
-->
|
||||
{#if type == 'image'}
|
||||
{#if view == 'card' || view == 'cozy'}
|
||||
<!--disabled preloads here since most people will hover over every image while scrolling-->
|
||||
@@ -39,9 +46,9 @@
|
||||
>
|
||||
<!-- svelte-ignore a11y-missing-attribute -->
|
||||
<img
|
||||
src={bestImageURL(post, false, 256)}
|
||||
src={bestImageURL(post, false, 64)}
|
||||
loading="lazy"
|
||||
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-xl opacity-50"
|
||||
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-xl opacity-40"
|
||||
/>
|
||||
<picture class="max-h-[inherit]">
|
||||
<source
|
||||
@@ -68,7 +75,7 @@
|
||||
transition-opacity duration-300 object-contain mx-auto"
|
||||
width={512}
|
||||
height={300}
|
||||
class:blur-3xl={post.nsfw && $userSettings.nsfwBlur}
|
||||
class:blur-3xl={blur}
|
||||
alt={post.alt_text ?? ''}
|
||||
/>
|
||||
</picture>
|
||||
|
||||
@@ -16,14 +16,43 @@
|
||||
export let type: MediaType = 'none'
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
{#if post.alt_text}
|
||||
<Popover
|
||||
openOnHover
|
||||
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
||||
<!--
|
||||
@component
|
||||
Thumbnails for compact and list view posts.
|
||||
-->
|
||||
<div
|
||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||
style={$$props.style ?? ''}
|
||||
>
|
||||
{#if post.alt_text}
|
||||
<Popover
|
||||
openOnHover
|
||||
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
|
||||
>
|
||||
<Material
|
||||
slot="target"
|
||||
padding="none"
|
||||
rounding="full"
|
||||
elevation="high"
|
||||
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
|
||||
>
|
||||
ALT
|
||||
</Material>
|
||||
<div class="max-w-sm">
|
||||
{post.alt_text}
|
||||
</div>
|
||||
</Popover>
|
||||
{/if}
|
||||
<svelte:element
|
||||
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
|
||||
href={postLink(post)}
|
||||
on:click={() => {
|
||||
if (type == 'image') {
|
||||
showImage(bestImageURL(post, false, 2048))
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<Material
|
||||
slot="target"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
class="items-center flex flex-row gap-1 hover:underline max-w-full min-w-0 {$$props.class ??
|
||||
''}"
|
||||
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
||||
data-sveltekit-preload-data="tap"
|
||||
>
|
||||
{#if avatar}
|
||||
<Avatar
|
||||
@@ -32,7 +33,7 @@
|
||||
class="flex gap-0 items-center flex-shrink max-w-full min-w-0"
|
||||
class:ml-0.5={avatar}
|
||||
>
|
||||
<span class:font-medium={showInstance}>
|
||||
<span class:font-medium={showInstance} class="username-text">
|
||||
{$userSettings.displayNames ? user.display_name || user.name : user.name}
|
||||
</span>
|
||||
{#if showInstance}
|
||||
@@ -62,6 +63,14 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.username-text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -3,7 +3,7 @@
|
||||
import { createAvatar } from '@dicebear/core'
|
||||
import * as initials from '@dicebear/initials'
|
||||
|
||||
const sizes = [48, 64, 128, 256, 512]
|
||||
const sizes = [16, 32, 48, 64, 128, 256, 512]
|
||||
|
||||
export let url: string | undefined
|
||||
export let alt: string = ''
|
||||
|
||||
@@ -68,7 +68,11 @@
|
||||
|
||||
<svelte:window bind:innerWidth={screenWidth} />
|
||||
|
||||
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
|
||||
<div
|
||||
{...$$restProps}
|
||||
class="shell {$$props.class}"
|
||||
style={colorsToVars($colors)}
|
||||
>
|
||||
<slot />
|
||||
<div
|
||||
class="
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
<h1 class="text-3xl font-bold flex items-center gap-2 {$$props.class ?? ''}">
|
||||
<script lang="ts">
|
||||
import { userSettings } from '$lib/settings'
|
||||
</script>
|
||||
|
||||
<h1
|
||||
class="text-3xl font-bold flex items-center gap-2 {$userSettings.font ==
|
||||
'satoshi/nunito'
|
||||
? 'font-display'
|
||||
: ''} {$$props.class ?? ''}"
|
||||
>
|
||||
<slot />
|
||||
</h1>
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { profile, profileData } from '$lib/auth.js'
|
||||
import { notifications, profile, profileData } from '$lib/auth.js'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import {
|
||||
@@ -112,7 +112,7 @@
|
||||
class="relative"
|
||||
isSelectedFilter={(path) => path.startsWith('/admin')}
|
||||
>
|
||||
{#if ($profile?.user?.notifications.applications ?? 0) > 0}
|
||||
{#if ($notifications.applications ?? 0) > 0}
|
||||
<div
|
||||
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
|
||||
/>
|
||||
@@ -125,7 +125,7 @@
|
||||
label={$t('nav.moderation')}
|
||||
class="relative"
|
||||
>
|
||||
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
|
||||
{#if ($notifications.reports ?? 0) > 0}
|
||||
<div
|
||||
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth'
|
||||
import { notifications, profile } from '$lib/auth'
|
||||
|
||||
import {
|
||||
Badge,
|
||||
@@ -73,7 +73,7 @@
|
||||
alt={$profile.user.local_user_view.person.name}
|
||||
/>
|
||||
</div>
|
||||
{#if $profile.user.notifications.inbox > 0}
|
||||
{#if $notifications.inbox > 0}
|
||||
<div
|
||||
class="rounded-full w-2 h-2 bg-red-500 absolute top-0 left-0 z-10"
|
||||
/>
|
||||
@@ -104,9 +104,9 @@
|
||||
<MenuButton link href="/inbox">
|
||||
<Icon src={Inbox} mini width={16} slot="prefix" />
|
||||
{$t('profile.inbox')}
|
||||
{#if $profile.user.notifications.inbox > 0}
|
||||
{#if $notifications.inbox > 0}
|
||||
<Badge color="red-subtle" class="text-xs ml-auto font-bold !py-0.5">
|
||||
{$profile.user.notifications.inbox}
|
||||
{$notifications.inbox}
|
||||
</Badge>
|
||||
{/if}
|
||||
</MenuButton>
|
||||
|
||||
@@ -13,6 +13,9 @@ import {
|
||||
ServerStack,
|
||||
PencilSquare,
|
||||
MapPin,
|
||||
Fire,
|
||||
ArrowTrendingUp,
|
||||
Star,
|
||||
} from 'svelte-hero-icons'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
@@ -38,6 +41,22 @@ export const defaultLinks: Link[] = [
|
||||
url: '/?type=Subscribed',
|
||||
label: t.get('filter.location.subscribed'),
|
||||
},
|
||||
{
|
||||
url: '/?type=All&sort=Hot',
|
||||
label: t.get('filter.sort.hot'),
|
||||
},
|
||||
{
|
||||
url: '/?type=All&sort=Active',
|
||||
label: t.get('filter.sort.active'),
|
||||
},
|
||||
{
|
||||
url: '/?type=All&sort=TopDay',
|
||||
label: t.get('filter.sort.top.time.day'),
|
||||
},
|
||||
{
|
||||
url: '/?type=All&sort=New',
|
||||
label: t.get('filter.sort.new'),
|
||||
},
|
||||
{
|
||||
url: '/communities',
|
||||
label: t.get('nav.communities'),
|
||||
@@ -74,6 +93,14 @@ export const iconOfLink = (url: string): IconSource => {
|
||||
return Newspaper
|
||||
case '/?type=Local':
|
||||
return MapPin
|
||||
case '/?type=All&sort=Hot':
|
||||
return Fire
|
||||
case '/?type=All&sort=Active':
|
||||
return ArrowTrendingUp
|
||||
case '/?type=All&sort=TopDay':
|
||||
return ChartBar
|
||||
case '/?type=All&sort=New':
|
||||
return Star
|
||||
case '/communities':
|
||||
return GlobeAlt
|
||||
case '/search':
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
UserCircle,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import { profile, profileData } from '$lib/auth.js'
|
||||
import { notifications, profile, profileData } from '$lib/auth.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
||||
@@ -70,12 +70,12 @@
|
||||
<SidebarButton icon={Inbox} href="/inbox">
|
||||
<span slot="label" class="flex items-center gap-2">
|
||||
{$t('profile.inbox')}
|
||||
{#if $profile?.user?.notifications.inbox}
|
||||
{#if $notifications.inbox}
|
||||
<Badge
|
||||
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
|
||||
color="red-subtle"
|
||||
>
|
||||
{$profile?.user?.notifications.inbox}
|
||||
{$notifications.inbox}
|
||||
</Badge>
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
+30
-3
@@ -473,7 +473,8 @@
|
||||
},
|
||||
"message": {
|
||||
"success": "Success",
|
||||
"error": "Error"
|
||||
"error": "Error",
|
||||
"retry": "Retry"
|
||||
},
|
||||
"toast": {
|
||||
"noComments": "The API returned no comments.",
|
||||
@@ -528,7 +529,9 @@
|
||||
"waitApplication": "Wait for your registration application to be accepted before logging in.",
|
||||
"blockUser": "Blocked that user.",
|
||||
"unblockUser": "Unblocked that user.",
|
||||
"purgeUser": "Purged that user."
|
||||
"purgeUser": "Purged that user.",
|
||||
"settingsImport": "Successfully imported settings",
|
||||
"settingsImportWarning": "The imported settings don't seem valid. Are you sure you want to import this?"
|
||||
},
|
||||
"settings": {
|
||||
"title": "Settings",
|
||||
@@ -536,6 +539,9 @@
|
||||
"desktop": "Desktop",
|
||||
"tablet": "Tablet",
|
||||
"mobile": "Mobile",
|
||||
"export": "Export",
|
||||
"import": "Import",
|
||||
"reset": "Reset",
|
||||
"navigation": {
|
||||
"title": "Navigation",
|
||||
"dockPos": {
|
||||
@@ -580,8 +586,15 @@
|
||||
"de": "German",
|
||||
"fi": "Finnish",
|
||||
"pt": "Portuguese",
|
||||
"zh": "Chinese",
|
||||
"zh-Hans": "Chinese (Simplified)",
|
||||
"zh-Hant": "Chinese (Traditional)",
|
||||
"auto": "Auto",
|
||||
"credits": "Credits"
|
||||
"credits": "Credits",
|
||||
"useRtl": {
|
||||
"title": "Use RTL layout",
|
||||
"description": "Use an RTL layout for RTL languages."
|
||||
}
|
||||
},
|
||||
"view": {
|
||||
"title": "Post style",
|
||||
@@ -594,6 +607,10 @@
|
||||
"title": "Default sort",
|
||||
"description": "The default sorting to use in feeds."
|
||||
},
|
||||
"infiniteScroll": {
|
||||
"title": "Infinite scroll",
|
||||
"description": "New posts are added as you scroll down, without having to click 'next'."
|
||||
},
|
||||
"postsInNewTab": {
|
||||
"title": "Open posts in new tab",
|
||||
"description": "Open posts in a separate tab instead of the current."
|
||||
@@ -632,6 +649,16 @@
|
||||
"title": "Translation",
|
||||
"description": "The LibreTranslate instance to use for translation.",
|
||||
"instance": "Domain"
|
||||
},
|
||||
"titleTags": {
|
||||
"title": "Parse tags in title",
|
||||
"description": "Take text in [brackets] and turn it into tags that you can click to search for.",
|
||||
"rules": {
|
||||
"title": "Rules",
|
||||
"blur": "Blur",
|
||||
"hide": "Hide",
|
||||
"show": "Show"
|
||||
}
|
||||
}
|
||||
},
|
||||
"embeds": {
|
||||
|
||||
+15
-3
@@ -115,7 +115,7 @@
|
||||
"slurFilter": "Kielletyt sanat (regex)",
|
||||
"federation": "Federointi päällä",
|
||||
"captcha": {
|
||||
"enabled": "Päällä"
|
||||
"enabled": "CAPTCHA Päällä"
|
||||
},
|
||||
"emailAdminsOnApplication": "Lähetä ylläpitäjille sähköposti-ilmoitus hakemuksista",
|
||||
"federationDebug": "Federoinnin vianetsintätila"
|
||||
@@ -357,7 +357,8 @@
|
||||
"generateTitle": "Hae otsikko",
|
||||
"create": "Luo julkaisu",
|
||||
"edit": "Muokkaa julkaisua",
|
||||
"url": "URL"
|
||||
"url": "URL",
|
||||
"altText": "Vaihtoehtoinen teksti"
|
||||
},
|
||||
"profile": {
|
||||
"2fa": {
|
||||
@@ -601,6 +602,10 @@
|
||||
"placeholders": {
|
||||
"title": "Satunnaiset paikkamerkit",
|
||||
"description": "Näytä satunnaisia paikkamerkkejä tyhjillä tekstikentillä."
|
||||
},
|
||||
"colorscheme": {
|
||||
"title": "Väritila",
|
||||
"description": "Valitse väritila."
|
||||
}
|
||||
},
|
||||
"title": "Asetukset",
|
||||
@@ -620,6 +625,10 @@
|
||||
"on": "Päällä",
|
||||
"off": "Pois päältä",
|
||||
"adaptive": "Mukautuva"
|
||||
},
|
||||
"pins": {
|
||||
"title": "Kiinnitykset",
|
||||
"description": "Lisää kiinnityksiä sivupalkkiin napsauttamalla kuvaketta. Napsauta oikealla poistaaksesi sen."
|
||||
}
|
||||
},
|
||||
"lemmy": {
|
||||
@@ -688,6 +697,9 @@
|
||||
"description": "Näytä vianetsintätiedot"
|
||||
},
|
||||
"title": "Muut"
|
||||
}
|
||||
},
|
||||
"desktop": "Työpöytä",
|
||||
"tablet": "Tabletti",
|
||||
"mobile": "Mobiili"
|
||||
}
|
||||
}
|
||||
+72
-6
@@ -117,7 +117,8 @@
|
||||
"generateTitle": "Generate le Titre",
|
||||
"uploadImage": "Ajouter une Image",
|
||||
"url": "URL",
|
||||
"nsfw": "NSFW"
|
||||
"nsfw": "NSFW",
|
||||
"altText": "Équivalent textuel"
|
||||
},
|
||||
"profile": {
|
||||
"displayName": "Nom affiché",
|
||||
@@ -171,7 +172,8 @@
|
||||
"footer": "{{users:number}} En ligne {{users; 1:user; default:users;}}"
|
||||
},
|
||||
"legal": {
|
||||
"noLegal": "Cet instance n'a aucune information legale."
|
||||
"noLegal": "Cet instance n'a aucune information legale.",
|
||||
"title": "Légal"
|
||||
},
|
||||
"profile": {
|
||||
"user": "Utilisateur",
|
||||
@@ -258,7 +260,7 @@
|
||||
"federation": "Federation activée",
|
||||
"federationDebug": "mode de débogage de federation",
|
||||
"captcha": {
|
||||
"enabled": "Activé"
|
||||
"enabled": "CAPTCHA Activé"
|
||||
},
|
||||
"title": "Configuration"
|
||||
},
|
||||
@@ -290,7 +292,7 @@
|
||||
"title": "Administrateurs",
|
||||
"empty": {
|
||||
"title": "Aucun administrateurs",
|
||||
"description": "Il n'y a aucun administrateur de serveur, je sais pas comment vous avez fait cela."
|
||||
"description": "Il n'y a aucun administrateur de serveur, je ne sais pas comment vous avez reussi a faire cela."
|
||||
}
|
||||
},
|
||||
"federation": {
|
||||
@@ -303,7 +305,12 @@
|
||||
"allow": "Whitelister",
|
||||
"allowplaceholder": "Whitelister une instance",
|
||||
"emptyBlock": {
|
||||
"title": "Aucune instances blocqués"
|
||||
"title": "Aucune instances bloqués",
|
||||
"description": "Le bloc d'une instance cachera toutes nouvelles soumissions de cette instance."
|
||||
},
|
||||
"emptyAllow": {
|
||||
"title": "Aucunes instances sur la liste blanche",
|
||||
"description": "Mettre une instance sur la liste blanche bloquera toutes les autres instances."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -334,7 +341,32 @@
|
||||
},
|
||||
"instances": "Instances",
|
||||
"translators": "Traducteurs",
|
||||
"createCommunity": "Créer une communauté"
|
||||
"createCommunity": "Créer une communauté",
|
||||
"modlog": "Journal de modération",
|
||||
"verifyEmail": {
|
||||
"message": "Votre email a été verifié, vous pouvez maintenant fermer cette fenêtre.",
|
||||
"error": "La vérification de l'email a échouée."
|
||||
},
|
||||
"passwordChange": {
|
||||
"title": "Changer le mot de passe",
|
||||
"description": "Choisissez votre nouveaux mot de passe.",
|
||||
"instance": "Sur quelle instance est hostée votre compte?"
|
||||
},
|
||||
"resetLogin": {
|
||||
"title": "Réinitialiser le mot de passe",
|
||||
"description": "Mettez l'email de vôtre compte, et un lien de réinitialision de mot de passe sera envoyé. Si vôtre compte n'a pas de email, vous devez contacter les administrateurs de votre instance."
|
||||
},
|
||||
"theme": {
|
||||
"import": "Importer",
|
||||
"export": "Exporter",
|
||||
"reset": "Réinitialiser",
|
||||
"accent": "Couleur d'accentuation",
|
||||
"resetWarning": {
|
||||
"title": "Réinitialiser les paramètres d'apparence",
|
||||
"description": "Ceci remettera a zéro toute la configuration de l'apparence, il est conseillé de l'exporter d'abord."
|
||||
},
|
||||
"title": "Apparence"
|
||||
}
|
||||
},
|
||||
"verifyEmail": {
|
||||
"message": "Votre e-mail est maintenant vérifié. Vous pouvez maintenant fermer cette fenetre.",
|
||||
@@ -353,7 +385,41 @@
|
||||
"app": {
|
||||
"lang": {
|
||||
"": "Dont translate the below!"
|
||||
},
|
||||
"theming": {
|
||||
"link": "Configuration d'apparence"
|
||||
}
|
||||
}
|
||||
},
|
||||
"comment": {
|
||||
"reply": "Répondre",
|
||||
"actions": {
|
||||
"link": "Copier le lien"
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"report": "Créer un signalement",
|
||||
"ban": {
|
||||
"banning": "Bannir l'utilisateur",
|
||||
"deleteData": "Suprimmer les données",
|
||||
"warning": "Cette option supprimera TOUTES les publications de cet utilisateur.",
|
||||
"expires": "Expire (UTC)",
|
||||
"banFromCommunity": "Ban d'une communauté"
|
||||
}
|
||||
},
|
||||
"cards": {
|
||||
"site": {
|
||||
"stats": "Statistiques",
|
||||
"admins": "Administrateurs"
|
||||
},
|
||||
"community": {
|
||||
"members": "Membres",
|
||||
"moderators": "Modérateurs",
|
||||
"subscribe": "S'abonner",
|
||||
"subscribed": "Abonné",
|
||||
"modlog": "Journal de modération",
|
||||
"block": "Bloquer",
|
||||
"unblock": "Débloquer"
|
||||
}
|
||||
}
|
||||
}
|
||||
+310
-1
@@ -1 +1,310 @@
|
||||
{}
|
||||
{
|
||||
"filter": {
|
||||
"unread": "לא נקרא",
|
||||
"location": {
|
||||
"label": "מיקום",
|
||||
"all": "הכל",
|
||||
"local": "מקומי",
|
||||
"subscribed": "רשום",
|
||||
"moderator": "מנהל",
|
||||
"global": "גלובלי"
|
||||
},
|
||||
"sort": {
|
||||
"label": "מיון",
|
||||
"active": "פעיל",
|
||||
"hot": "חם",
|
||||
"top": {
|
||||
"time": {
|
||||
"label": "זמן",
|
||||
"all": "הכל",
|
||||
"9months": "9 חודשים",
|
||||
"6months": "6 חודשים",
|
||||
"3months": "3 חודשים",
|
||||
"month": "חודש",
|
||||
"week": "שבוע",
|
||||
"day": "יום",
|
||||
"12hours": "12 שעות",
|
||||
"6hours": "6 שעות",
|
||||
"hour": "שעה"
|
||||
},
|
||||
"label": "הטובים ביותר"
|
||||
},
|
||||
"new": "חדש",
|
||||
"old": "ישן",
|
||||
"controversial": "שנוי במחלוקת",
|
||||
"mostcomments": "תגובות",
|
||||
"newcomments": "תגובות חדשות",
|
||||
"scaled": "מטפסים"
|
||||
},
|
||||
"view": {
|
||||
"label": "פריסה",
|
||||
"cozy": "נוח",
|
||||
"list": "רשימה",
|
||||
"compact": "דחוס",
|
||||
"legacy": "ישן"
|
||||
},
|
||||
"type": "סוג",
|
||||
"filter": "סינון",
|
||||
"inbox": {
|
||||
"messages": "הודעות",
|
||||
"replies": "תגובות",
|
||||
"mentions": "אזכורים"
|
||||
}
|
||||
},
|
||||
"form": {
|
||||
"profile": {
|
||||
"showBots": "הצגת בוטים",
|
||||
"2fa": {
|
||||
"paste": "נא להדביק את זה באפליקציית ה-authenticator שלך.",
|
||||
"totp": "TOTP",
|
||||
"2fa": "2FA"
|
||||
},
|
||||
"displayName": "כינוי",
|
||||
"bio": "אודות",
|
||||
"avatar": "תמונת פרופיל",
|
||||
"banner": "באנר",
|
||||
"email": "אימייל",
|
||||
"matrix": "משתמש Matrix",
|
||||
"showNSFW": "הצגת תוכן למבוגרים",
|
||||
"bot": "חשבון בוט",
|
||||
"currentPassword": "סיסמה נוכחית",
|
||||
"newPassword": "סיסמה חדשה",
|
||||
"verifyNewPassword": "אימות סיסמה חדשה",
|
||||
"deleteAccount": {
|
||||
"label": "מחיקת חשבון",
|
||||
"deleteContent": "מחיקת תוכן",
|
||||
"warning": "פעולה זו תמחק את כל התוכן שלך."
|
||||
},
|
||||
"scores": "הצגת הצבעות",
|
||||
"showRead": "תצוגת פוסטים שנקראו"
|
||||
},
|
||||
"confirmPassword": "אישור סיסמה",
|
||||
"post": {
|
||||
"title": "כותרת",
|
||||
"altText": "טקסט חלופי",
|
||||
"create": "יצירת פוסט",
|
||||
"edit": "עריכת פוסט",
|
||||
"community": "קהילה",
|
||||
"url": "קישור",
|
||||
"body": "גוף",
|
||||
"nsfw": "תוכן למבוגרים",
|
||||
"generateTitle": "יצירת כותרת",
|
||||
"uploadImage": "העלאת תמונה"
|
||||
},
|
||||
"signup": {
|
||||
"application": {
|
||||
"info": "כדי להצטרף לשרת זה, חובה למלא את בקשת ההצטרפות ולחכות לקבלה. ישלח אימייל כאשר בקשתך התקבלה.",
|
||||
"label": "בקשה להצטרפות"
|
||||
},
|
||||
"title": "הרשמה",
|
||||
"description": "נא לבחור שרת שמעניין אותך, או לכתוב קישור באופן ידני.",
|
||||
"chooseInstance": "בחירת שרת",
|
||||
"closed": {
|
||||
"title": "רישומים סגורים",
|
||||
"description": "בשרת זה הרישומים סגורים. נא למצוא שרת אחר.",
|
||||
"anotherInstance": "מציאת שרת אחר"
|
||||
},
|
||||
"info": "השרת הוא היכן שחשבונך שמור, אך עדיין ניתן לגשת לתוכן משרתים נוספים."
|
||||
},
|
||||
"email": "אימייל",
|
||||
"description": "תיאור",
|
||||
"username": "שם משתמש",
|
||||
"name": "שם",
|
||||
"password": "סיסמה",
|
||||
"2fa": "קוד 2FA",
|
||||
"forgotpassword": "שכחתי את הסיסמה",
|
||||
"submit": "שליחה",
|
||||
"edit": "עריכה",
|
||||
"preview": "תצוגה מקדימה",
|
||||
"instance": "קישור לשרת",
|
||||
"setup": "הגדרה"
|
||||
},
|
||||
"profile": {
|
||||
"profile": "פרופיל",
|
||||
"inbox": "דואר נכנס",
|
||||
"saved": "שמורים",
|
||||
"subscribed": "רשומים"
|
||||
},
|
||||
"routes": {
|
||||
"frontpage": {
|
||||
"footer": "{{users:number}} {{users; 1:משתמש; default:משתמשים;}} {{users; 1:פעיל; default:פעילים;}}",
|
||||
"title": "דף הבית"
|
||||
},
|
||||
"modlog": "יומן הנהלה",
|
||||
"instances": "שרתים",
|
||||
"legal": {
|
||||
"title": "משפטי",
|
||||
"noLegal": "לשרת זה אין מידע משפטי."
|
||||
},
|
||||
"profile": {
|
||||
"user": "משתמש",
|
||||
"settings": "הגדרות",
|
||||
"credentials": "אימות",
|
||||
"moderates": "מנהל/ת",
|
||||
"favorites": "אהובים"
|
||||
},
|
||||
"translators": "מתרגמים",
|
||||
"accounts": "חשבונות",
|
||||
"communities": "קהילות",
|
||||
"search": {
|
||||
"title": "חיפוש",
|
||||
"noResults": {
|
||||
"title": "אין תוצאות",
|
||||
"description": "אין תוצאות שתואמות את מילות המפתח שלך. מומלץ לעדכן את חיפושך.",
|
||||
"alt": "חיפוש ברחבי הפדיורס"
|
||||
},
|
||||
"query": "חיפוש"
|
||||
},
|
||||
"admin": {
|
||||
"config": {
|
||||
"captcha": {
|
||||
"enabled": "CAPTCHA מופעלת"
|
||||
},
|
||||
"federation": "פדרציה מופעלת",
|
||||
"title": "הגדרות",
|
||||
"sidebar": "סרגל צידי",
|
||||
"icon": "סמל",
|
||||
"banner": "באנר",
|
||||
"downvotesEnabled": "הפעלת הצבעות נגד",
|
||||
"nsfwEnabled": "הפעלת תוכן למבוגרים",
|
||||
"registration": {
|
||||
"label": "מצב רישום",
|
||||
"open": "פתוח",
|
||||
"application": "חייב בקשה",
|
||||
"closed": "סגור"
|
||||
},
|
||||
"applicationQuestion": "שאלת בקשה",
|
||||
"adminCommunityOnly": "רק מנהלים גבוהים יכולים ליצור קהילות",
|
||||
"requireVerifyEmail": "חייב אימות על ידי אימייל",
|
||||
"emailAdminsOnApplication": "שליחות אימייל למנהלים גבוהים בעת קבלת בקשות חדשות",
|
||||
"emailAdminsOnReport": "שליחת אימייל למנהלים גבוהים בעת קבלת דיווחים חדשים",
|
||||
"listingType": {
|
||||
"label": "סוג רישום",
|
||||
"all": "הכל",
|
||||
"local": "מקומי"
|
||||
},
|
||||
"private": "שרת פרטי",
|
||||
"slurFilter": "סינון קללות regex",
|
||||
"federationDebug": "מצב דיבוג פדרציה",
|
||||
"hideModlogModNames": "הסתרת שמות מנהלים ביומן ההנהלה"
|
||||
},
|
||||
"title": "מנהל גבוה",
|
||||
"applications": {
|
||||
"title": "בקשות",
|
||||
"empty": {
|
||||
"title": "אין בקשות חדשות",
|
||||
"description": "בקשות להצטרפות השרת יופיעו פה."
|
||||
},
|
||||
"application": "בקשה",
|
||||
"approved": "מאושרת",
|
||||
"denied": "נדחתה",
|
||||
"user": "משתמש",
|
||||
"deny": "לדחות",
|
||||
"approve": "לאשר",
|
||||
"reason": "סיבה",
|
||||
"modalTitle": "דחיית בקשה"
|
||||
},
|
||||
"taglines": {
|
||||
"title": "שורות תיוג",
|
||||
"add": "הוספת שורת תיוג",
|
||||
"empty": {
|
||||
"title": "אין שורות תיוג",
|
||||
"description": "שורת תיוג אקראית תופיע על כרטיס האתר כאשר משתמשים יבקרו בשרתך."
|
||||
}
|
||||
},
|
||||
"team": {
|
||||
"title": "מנהלים גבוהים",
|
||||
"empty": {
|
||||
"title": "אין מנהלים גבוהים",
|
||||
"description": "איכשהו אין מנהלים גבוהים לאתר זה. איך??"
|
||||
}
|
||||
},
|
||||
"federation": {
|
||||
"title": "פדרציה",
|
||||
"csv": "העלאת CSV",
|
||||
"block": "חסימה",
|
||||
"blockplaceholder": "חסימת שרת...",
|
||||
"blocked": "שרתים חסומים",
|
||||
"allowed": "שרתים מורשים"
|
||||
}
|
||||
},
|
||||
"saved": "שמורים",
|
||||
"createPost": "יצירת פוסט",
|
||||
"createCommunity": "יצירת קהילה",
|
||||
"post": {
|
||||
"commentCount": "תגובות",
|
||||
"addComment": "הוספת תגובה",
|
||||
"scrollToTop": "גלילה לתחילת העמוד",
|
||||
"instanceWarning": "הפוסט הזה מבוקש משרת השונה משל חשבונך. פעולות רבות יכשלו.",
|
||||
"remoteView": "תצוגה מרחוק",
|
||||
"localView": "תצוגה מקומית",
|
||||
"thread": {
|
||||
"single": "מוצג שרשור בודד.",
|
||||
"allComments": "כל התגובות",
|
||||
"part": "מוצג חלק משרשור",
|
||||
"context": "תצוגת הקשר"
|
||||
},
|
||||
"crosspostCount": "פוסטים משותפים"
|
||||
},
|
||||
"inbox": {
|
||||
"title": "דואר נכנס",
|
||||
"markAsRead": "סימון הכל כנקרא",
|
||||
"empty": {
|
||||
"title": "אין הודעות חדשות",
|
||||
"description": "הודעות, תגובות, ואזכורים יופיעו פה."
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"title": "מנהל",
|
||||
"empty": {
|
||||
"title": "אין דיווחים חדשים",
|
||||
"description": "כאשר תוכן מדווח, ניתן לפעול בנידון כאן."
|
||||
},
|
||||
"reason": "סיבה",
|
||||
"resolve": "פתירה",
|
||||
"unresolve": "הסרת פתירה"
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
"home": "בית",
|
||||
"admin": "מנהל גבוה",
|
||||
"moderation": "מנהל",
|
||||
"communities": "קהילות",
|
||||
"search": "חיפוש",
|
||||
"create": {
|
||||
"label": "יצירה",
|
||||
"community": "קהילה",
|
||||
"logingate": "חובה עליך להתחבר כדי ליצור תוכן.",
|
||||
"post": "פוסט"
|
||||
},
|
||||
"menu": {
|
||||
"label": "פרופיל",
|
||||
"app": "אפליקציה",
|
||||
"settings": "הגדרות",
|
||||
"colorscheme": {
|
||||
"label": "צבעים",
|
||||
"system": "מערכת",
|
||||
"dark": "כהה",
|
||||
"light": "בהיר"
|
||||
},
|
||||
"theme": "סגנון",
|
||||
"about": "אודות",
|
||||
"source": "מקור",
|
||||
"donate": "תרומה",
|
||||
"instance": "שרת"
|
||||
}
|
||||
},
|
||||
"account": {
|
||||
"login": "התחברות",
|
||||
"logout": "התנתקות",
|
||||
"signup": "הרשמה",
|
||||
"accounts": "חשבונות",
|
||||
"changeinstance": "שינוי שרת",
|
||||
"resetColor": "איפוס צבעים",
|
||||
"addGuest": "הוספת אורח",
|
||||
"moveUp": "הזזה למעלה",
|
||||
"moveDown": "הזזה למטה",
|
||||
"guest": "אורח",
|
||||
"versionGate": "הגרסה הזו של Photon תומכת בשרתים המריצים {{version}} או גרסה עדכנית יותר."
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -0,0 +1,228 @@
|
||||
{
|
||||
"form": {
|
||||
"profile": {
|
||||
"email": "Email",
|
||||
"displayName": "顯示名稱",
|
||||
"bio": "個人簡介",
|
||||
"avatar": "大頭貼",
|
||||
"banner": "背景橫幅",
|
||||
"showNSFW": "顯示限制級(NSFW)內容",
|
||||
"scores": "顯示讚數",
|
||||
"bot": "機器人帳號",
|
||||
"showBots": "顯示機器人貼文",
|
||||
"showRead": "顯示已讀貼文",
|
||||
"currentPassword": "當前密碼",
|
||||
"newPassword": "新密碼",
|
||||
"verifyNewPassword": "確認密碼"
|
||||
},
|
||||
"username": "使用者名稱",
|
||||
"name": "名稱",
|
||||
"instance": "站點網址",
|
||||
"password": "密碼",
|
||||
"confirmPassword": "確認密碼",
|
||||
"2fa": "2FA兩步驗證碼",
|
||||
"forgotpassword": "忘記密碼",
|
||||
"submit": "送出",
|
||||
"edit": "編輯",
|
||||
"preview": "預覽",
|
||||
"post": {
|
||||
"create": "發文",
|
||||
"edit": "編輯貼文",
|
||||
"community": "社群",
|
||||
"title": "標題",
|
||||
"url": "網址",
|
||||
"body": "內文",
|
||||
"nsfw": "限制級(NSFW)",
|
||||
"generateTitle": "代入標題",
|
||||
"uploadImage": "上傳影像",
|
||||
"altText": "替代文字"
|
||||
},
|
||||
"signup": {
|
||||
"title": "註冊"
|
||||
}
|
||||
},
|
||||
"routes": {
|
||||
"createPost": "發文",
|
||||
"saved": "保存",
|
||||
"createCommunity": "創建社群",
|
||||
"post": {
|
||||
"crosspostCount": "轉貼",
|
||||
"commentCount": "留言",
|
||||
"addComment": "新增留言"
|
||||
},
|
||||
"verifyEmail": {
|
||||
"message": "您的電子郵件已通過驗證。您現在可以關閉此視窗。",
|
||||
"error": "無法驗證您的電子郵件。"
|
||||
},
|
||||
"passwordChange": {
|
||||
"title": "更改密碼",
|
||||
"description": "選擇您的新密碼。",
|
||||
"instance": "您的帳戶託管在哪個實例上?"
|
||||
},
|
||||
"resetLogin": {
|
||||
"title": "重置密碼",
|
||||
"description": "輸入您帳戶的電子郵件,將發送密碼重設連結。如果您的帳戶沒有電子郵件,請聯繫您的實例管理員。"
|
||||
},
|
||||
"theme": {
|
||||
"title": "主題",
|
||||
"import": "匯入",
|
||||
"export": "匯出",
|
||||
"reset": "重設"
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"back": "往前",
|
||||
"next": "往後",
|
||||
"refresh": "重整"
|
||||
},
|
||||
"profile": {
|
||||
"profile": "個人資料",
|
||||
"inbox": "信箱",
|
||||
"saved": "保存",
|
||||
"subscribed": "訂閱"
|
||||
},
|
||||
"nav": {
|
||||
"home": "首頁",
|
||||
"admin": "設定",
|
||||
"moderation": "管理",
|
||||
"communities": "探索",
|
||||
"search": "搜尋",
|
||||
"create": {
|
||||
"label": "新增",
|
||||
"post": "貼文",
|
||||
"community": "社群",
|
||||
"logingate": "你需要登入,才能發文."
|
||||
},
|
||||
"menu": {
|
||||
"label": "個人資料",
|
||||
"app": "App",
|
||||
"settings": "設定",
|
||||
"colorscheme": {
|
||||
"label": "主題",
|
||||
"system": "系統",
|
||||
"dark": "暗黑",
|
||||
"light": "光亮"
|
||||
},
|
||||
"theme": "主題",
|
||||
"about": "關於",
|
||||
"source": "來源",
|
||||
"instance": "站點"
|
||||
}
|
||||
},
|
||||
"account": {
|
||||
"login": "登入",
|
||||
"logout": "登出",
|
||||
"signup": "註冊",
|
||||
"accounts": "帳號",
|
||||
"changeinstance": "變更站點",
|
||||
"resetColor": "重設顏色",
|
||||
"addGuest": "新增遊客",
|
||||
"moveUp": "往上",
|
||||
"moveDown": "往下",
|
||||
"guest": "遊客"
|
||||
},
|
||||
"filter": {
|
||||
"location": {
|
||||
"label": "範圍",
|
||||
"all": "所有",
|
||||
"local": "本站",
|
||||
"subscribed": "已訂閱",
|
||||
"moderator": "管理的",
|
||||
"global": "全部"
|
||||
},
|
||||
"sort": {
|
||||
"label": "排序",
|
||||
"active": "活躍",
|
||||
"hot": "熱門",
|
||||
"top": {
|
||||
"label": "最佳",
|
||||
"time": {
|
||||
"label": "時間",
|
||||
"all": "所有",
|
||||
"9months": "9月以來",
|
||||
"6months": "6月以來",
|
||||
"3months": "3月以來",
|
||||
"month": "這月以來",
|
||||
"week": "這周",
|
||||
"day": "日",
|
||||
"12hours": "12小時",
|
||||
"6hours": "6小時",
|
||||
"hour": "這小時"
|
||||
}
|
||||
},
|
||||
"new": "最新",
|
||||
"old": "最舊",
|
||||
"controversial": "最有爭議",
|
||||
"scaled": "各版熱門",
|
||||
"mostcomments": "最多留言",
|
||||
"newcomments": "最新留言"
|
||||
},
|
||||
"view": {
|
||||
"label": "顯示模式",
|
||||
"cozy": "可莉",
|
||||
"list": "列表",
|
||||
"compact": "緊湊",
|
||||
"legacy": "經典"
|
||||
},
|
||||
"type": "類型",
|
||||
"filter": "過濾",
|
||||
"unread": "未讀",
|
||||
"inbox": {
|
||||
"messages": "私信",
|
||||
"replies": "回覆",
|
||||
"mentions": "標記"
|
||||
}
|
||||
},
|
||||
"cards": {
|
||||
"site": {
|
||||
"about": "關於",
|
||||
"stats": "統計",
|
||||
"admins": "管理員"
|
||||
},
|
||||
"community": {
|
||||
"members": "訪客",
|
||||
"moderators": "管理員",
|
||||
"subscribe": "訂閱",
|
||||
"subscribed": "已訂閱",
|
||||
"block": "封鎖",
|
||||
"unblock": "取消封鎖",
|
||||
"blockInstance": "封鎖站點",
|
||||
"favorite": "最愛",
|
||||
"unfavorite": "取消最愛"
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"all": "所有",
|
||||
"users": "使用者"
|
||||
},
|
||||
"post": {
|
||||
"actions": {
|
||||
"save": "保存",
|
||||
"more": {
|
||||
"crosspost": "轉貼"
|
||||
}
|
||||
},
|
||||
"badges": {
|
||||
"nsfw": "限制級(NSFW)",
|
||||
"featured": "置頂"
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"report": "檢舉"
|
||||
},
|
||||
"settings": {
|
||||
"title": "設定",
|
||||
"app": {
|
||||
"lang": {
|
||||
"title": "語言",
|
||||
"auto": "自動"
|
||||
}
|
||||
},
|
||||
"lemmy": {
|
||||
"nsfwBlur": {
|
||||
"title": "限制級(NSFW) 遮擋",
|
||||
"description": "模糊圖片並隱藏限制級(NSFW)帖文預覽。"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
{
|
||||
"profile": {
|
||||
"inbox": "信箱",
|
||||
"profile": "個人資料",
|
||||
"saved": "保存",
|
||||
"subscribed": "訂閱"
|
||||
},
|
||||
"nav": {
|
||||
"home": "首頁",
|
||||
"moderation": "管理",
|
||||
"admin": "設定",
|
||||
"communities": "探索",
|
||||
"search": "搜尋",
|
||||
"create": {
|
||||
"label": "新增",
|
||||
"post": "貼文",
|
||||
"community": "社群",
|
||||
"logingate": "你需要登入,才能發文."
|
||||
},
|
||||
"menu": {
|
||||
"app": "App",
|
||||
"settings": "設定",
|
||||
"colorscheme": {
|
||||
"label": "主題",
|
||||
"system": "系統",
|
||||
"dark": "暗黑",
|
||||
"light": "光亮"
|
||||
},
|
||||
"theme": "主題",
|
||||
"about": "關於",
|
||||
"source": "來源",
|
||||
"instance": "站點",
|
||||
"label": "個人資料"
|
||||
}
|
||||
},
|
||||
"account": {
|
||||
"login": "登入",
|
||||
"logout": "登出",
|
||||
"accounts": "帳號",
|
||||
"changeinstance": "變更站點",
|
||||
"resetColor": "重設顏色",
|
||||
"addGuest": "新增遊客",
|
||||
"moveUp": "往上",
|
||||
"moveDown": "往下",
|
||||
"guest": "遊客",
|
||||
"signup": "註冊"
|
||||
},
|
||||
"filter": {
|
||||
"location": {
|
||||
"label": "範圍",
|
||||
"all": "所有",
|
||||
"subscribed": "已訂閱",
|
||||
"moderator": "管理的",
|
||||
"global": "全部",
|
||||
"local": "本站"
|
||||
},
|
||||
"sort": {
|
||||
"label": "排序",
|
||||
"hot": "熱門",
|
||||
"top": {
|
||||
"label": "最佳",
|
||||
"time": {
|
||||
"label": "時間",
|
||||
"all": "所有",
|
||||
"9months": "9月以來",
|
||||
"6months": "6月以來",
|
||||
"3months": "3月以來",
|
||||
"month": "這月以來",
|
||||
"week": "這周",
|
||||
"day": "日",
|
||||
"6hours": "6小時",
|
||||
"hour": "這小時",
|
||||
"12hours": "12小時"
|
||||
}
|
||||
},
|
||||
"new": "最新",
|
||||
"old": "最舊",
|
||||
"controversial": "最有爭議",
|
||||
"scaled": "各版熱門",
|
||||
"newcomments": "最新留言",
|
||||
"mostcomments": "最多留言",
|
||||
"active": "活躍"
|
||||
},
|
||||
"view": {
|
||||
"cozy": "可莉",
|
||||
"list": "列表",
|
||||
"compact": "緊湊",
|
||||
"label": "顯示模式",
|
||||
"legacy": "經典"
|
||||
},
|
||||
"type": "類型",
|
||||
"filter": "過濾",
|
||||
"unread": "未讀",
|
||||
"inbox": {
|
||||
"messages": "私信",
|
||||
"replies": "回覆",
|
||||
"mentions": "標記"
|
||||
}
|
||||
},
|
||||
"form": {
|
||||
"name": "名稱",
|
||||
"instance": "站點網址",
|
||||
"username": "使用者名稱",
|
||||
"password": "密碼",
|
||||
"confirmPassword": "確認密碼",
|
||||
"forgotpassword": "忘記密碼",
|
||||
"submit": "送出",
|
||||
"edit": "編輯",
|
||||
"preview": "預覽",
|
||||
"post": {
|
||||
"create": "發文",
|
||||
"edit": "編輯貼文",
|
||||
"community": "社群",
|
||||
"title": "標題",
|
||||
"url": "網址",
|
||||
"body": "內文",
|
||||
"nsfw": "限制級(NSFW)",
|
||||
"altText": "替代文字",
|
||||
"generateTitle": "代入標題",
|
||||
"uploadImage": "上傳影像"
|
||||
},
|
||||
"profile": {
|
||||
"displayName": "顯示名稱",
|
||||
"bio": "個人簡介",
|
||||
"avatar": "大頭貼",
|
||||
"banner": "背景橫幅",
|
||||
"email": "Email",
|
||||
"showNSFW": "顯示限制級(NSFW)內容",
|
||||
"scores": "顯示讚數",
|
||||
"bot": "機器人帳號",
|
||||
"showRead": "顯示已讀貼文",
|
||||
"currentPassword": "當前密碼",
|
||||
"newPassword": "新密碼",
|
||||
"verifyNewPassword": "確認密碼",
|
||||
"showBots": "顯示機器人貼文"
|
||||
},
|
||||
"signup": {
|
||||
"title": "註冊"
|
||||
},
|
||||
"2fa": "2FA兩步驗證碼"
|
||||
},
|
||||
"routes": {
|
||||
"saved": "保存",
|
||||
"createPost": "發文",
|
||||
"createCommunity": "創建社群",
|
||||
"post": {
|
||||
"crosspostCount": "轉貼",
|
||||
"commentCount": "留言",
|
||||
"addComment": "新增留言"
|
||||
},
|
||||
"verifyEmail": {
|
||||
"error": "無法驗證您的電子郵件。",
|
||||
"message": "您的電子郵件已通過驗證。您現在可以關閉此視窗。"
|
||||
},
|
||||
"passwordChange": {
|
||||
"title": "更改密碼",
|
||||
"description": "選擇您的新密碼。",
|
||||
"instance": "您的帳戶託管在哪個實例上?"
|
||||
},
|
||||
"resetLogin": {
|
||||
"title": "重置密碼",
|
||||
"description": "輸入您帳戶的電子郵件,將發送密碼重設連結。如果您的帳戶沒有電子郵件,請聯繫您的實例管理員。"
|
||||
},
|
||||
"theme": {
|
||||
"title": "主題",
|
||||
"import": "匯入",
|
||||
"export": "匯出",
|
||||
"reset": "重設"
|
||||
}
|
||||
},
|
||||
"cards": {
|
||||
"site": {
|
||||
"about": "關於",
|
||||
"stats": "統計",
|
||||
"admins": "管理員"
|
||||
},
|
||||
"community": {
|
||||
"moderators": "管理員",
|
||||
"subscribe": "訂閱",
|
||||
"subscribed": "已訂閱",
|
||||
"block": "封鎖",
|
||||
"unblock": "取消封鎖",
|
||||
"blockInstance": "封鎖站點",
|
||||
"favorite": "最愛",
|
||||
"unfavorite": "取消最愛",
|
||||
"members": "訪客"
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"all": "所有",
|
||||
"users": "使用者"
|
||||
},
|
||||
"post": {
|
||||
"actions": {
|
||||
"save": "保存",
|
||||
"more": {
|
||||
"crosspost": "轉貼"
|
||||
}
|
||||
},
|
||||
"badges": {
|
||||
"nsfw": "限制級(NSFW)",
|
||||
"featured": "置頂"
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"report": "檢舉"
|
||||
},
|
||||
"settings": {
|
||||
"title": "設定",
|
||||
"app": {
|
||||
"lang": {
|
||||
"auto": "自動",
|
||||
"title": "語言"
|
||||
}
|
||||
},
|
||||
"lemmy": {
|
||||
"nsfwBlur": {
|
||||
"description": "模糊圖片並隱藏限制級(NSFW)帖文預覽。",
|
||||
"title": "限制級(NSFW) 遮擋"
|
||||
}
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"next": "往後",
|
||||
"back": "往前",
|
||||
"refresh": "重整"
|
||||
}
|
||||
}
|
||||
+22
-19
@@ -44,11 +44,8 @@ async function customFetch(
|
||||
}
|
||||
}
|
||||
|
||||
const url = toURL(input)
|
||||
if (auth && url) url.searchParams.set('auth', auth)
|
||||
|
||||
const res = await f(url ?? input, init)
|
||||
if (!res.ok) error(res.status, await res.text());
|
||||
const res = await f(input, init)
|
||||
if (!res.ok) error(res.status, await res.text())
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -101,27 +98,33 @@ export async function validateInstance(instance: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
export function mayBeIncompatible(minVersion: string, availableVersion: string) {
|
||||
if (minVersion.valueOf() === availableVersion.valueOf()) return false;
|
||||
export function mayBeIncompatible(
|
||||
minVersion: string,
|
||||
availableVersion: string
|
||||
) {
|
||||
if (minVersion.valueOf() === availableVersion.valueOf()) return false
|
||||
|
||||
const versionFormatter = /[\d.]/;
|
||||
if (!minVersion.match(versionFormatter) || !availableVersion.match(availableVersion)) {
|
||||
return true;
|
||||
const versionFormatter = /[\d.]/
|
||||
if (
|
||||
!minVersion.match(versionFormatter) ||
|
||||
!availableVersion.match(availableVersion)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
const splitMinVersion = minVersion.split('.');
|
||||
const splitAvailableVersion = availableVersion.split('.');
|
||||
const splitMinVersion = minVersion.split('.')
|
||||
const splitAvailableVersion = availableVersion.split('.')
|
||||
|
||||
if (splitMinVersion.length !== splitAvailableVersion.length) return true;
|
||||
if (splitMinVersion.length !== splitAvailableVersion.length) return true
|
||||
|
||||
for (let i = 0; i < splitMinVersion.length; ++i) {
|
||||
const minVersionDigit = parseInt(splitMinVersion[i]);
|
||||
const availableVersionDigit = parseInt(splitAvailableVersion[i]);
|
||||
const minVersionDigit = parseInt(splitMinVersion[i])
|
||||
const availableVersionDigit = parseInt(splitAvailableVersion[i])
|
||||
|
||||
if (availableVersionDigit === undefined) return true;
|
||||
if (minVersionDigit < availableVersionDigit) return false;
|
||||
if (availableVersionDigit < minVersionDigit) return true;
|
||||
if (availableVersionDigit === undefined) return true
|
||||
if (minVersionDigit < availableVersionDigit) return false
|
||||
if (availableVersionDigit < minVersionDigit) return true
|
||||
}
|
||||
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
@@ -96,10 +96,4 @@ export function addFavorite(item: Community, add: boolean = true) {
|
||||
}
|
||||
p.favorites = favs
|
||||
profileData.update(() => pd)
|
||||
profile.update((p) => ({
|
||||
...p,
|
||||
favorites: favs,
|
||||
id: p!.id,
|
||||
instance: p!.instance,
|
||||
}))
|
||||
}
|
||||
+5
-16
@@ -1,4 +1,4 @@
|
||||
import { profile, type Profile } from '$lib/auth.js'
|
||||
import { profile, profileData, type Profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { trycatch } from '$lib/util.js'
|
||||
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
||||
@@ -22,30 +22,19 @@ export const addSubscription = (
|
||||
community: Community,
|
||||
subscribe: boolean = true
|
||||
) => {
|
||||
const p = get(profile)
|
||||
const pd = get(profileData)
|
||||
const p = pd.profiles.find((p) => p.id == pd.profile)
|
||||
|
||||
if (!p?.user) return
|
||||
|
||||
if (subscribe) {
|
||||
profile.set({
|
||||
...p,
|
||||
user: {
|
||||
...p.user,
|
||||
follows: [
|
||||
...p.user.follows,
|
||||
{
|
||||
community: community,
|
||||
follower: p.user.local_user_view.person,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
profileData.set(pd)
|
||||
} else {
|
||||
p.user.follows.splice(
|
||||
p.user.follows.findIndex((i) => i.community.id == community.id),
|
||||
1
|
||||
)
|
||||
profile.set(p)
|
||||
profileData.set(pd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-1
@@ -88,8 +88,14 @@ interface Settings {
|
||||
compactFeatured: boolean
|
||||
showHidden: boolean
|
||||
}
|
||||
infiniteScroll: boolean
|
||||
language: string | null
|
||||
useRtl: boolean
|
||||
translator: string | undefined
|
||||
parseTags: boolean
|
||||
tagRules: {
|
||||
[key: string]: 'hide' | 'blur'
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
@@ -155,14 +161,22 @@ export const defaultSettings: Settings = {
|
||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
||||
showHidden: false,
|
||||
},
|
||||
infiniteScroll: true,
|
||||
language: env.PUBLIC_LANGUAGE ?? null,
|
||||
useRtl: false,
|
||||
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
||||
parseTags: true,
|
||||
tagRules: {
|
||||
cw: 'blur',
|
||||
nsfl: 'blur',
|
||||
nsfw: 'blur',
|
||||
},
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
const migrate = (settings: any): Settings => {
|
||||
if (typeof settings.moderation.removalReasonPreset == 'string') {
|
||||
if (typeof settings?.moderation?.removalReasonPreset == 'string') {
|
||||
settings.moderation.presets = [
|
||||
{
|
||||
title: 'Preset 1',
|
||||
|
||||
@@ -27,11 +27,26 @@ const config: Config = {
|
||||
key: '',
|
||||
loader: async () => (await import('./i18n/de.json')).default,
|
||||
},
|
||||
{
|
||||
locale: 'he',
|
||||
key: '',
|
||||
loader: async () => (await import('./i18n/he.json')).default,
|
||||
},
|
||||
{
|
||||
locale: 'pt',
|
||||
key: '',
|
||||
loader: async () => (await import('./i18n/pt.json')).default,
|
||||
},
|
||||
{
|
||||
locale: 'zh-Hans',
|
||||
key: '',
|
||||
loader: async () => (await import('./i18n/zh-Hans.json')).default,
|
||||
},
|
||||
{
|
||||
locale: 'zh-Hant',
|
||||
key: '',
|
||||
loader: async () => (await import('./i18n/zh-Hant.json')).default,
|
||||
},
|
||||
],
|
||||
fallbackLocale: 'en',
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ import { get } from 'svelte/store'
|
||||
import type { SubscribedType } from 'lemmy-js-client'
|
||||
import { page } from '$app/stores'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { client, site } from '$lib/lemmy.js'
|
||||
import { client } from '$lib/lemmy.js'
|
||||
import { site } from './lemmy'
|
||||
|
||||
export const findClosestNumber = (numbers: number[], target: number): number =>
|
||||
numbers.reduce((prev, curr) =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { t } from '$lib/translations'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, XMark } from 'svelte-hero-icons'
|
||||
</script>
|
||||
@@ -18,6 +19,6 @@
|
||||
{$page.error?.message}
|
||||
</code>
|
||||
<Button size="sm" class="w-max" on:click={() => goto($page.url)}>
|
||||
Retry
|
||||
{$t('message.retry')}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -27,21 +27,24 @@
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance'
|
||||
import { locale } from '$lib/translations'
|
||||
|
||||
nProgress.configure({
|
||||
minimum: 0.4,
|
||||
trickleSpeed: 200,
|
||||
showSpinner: false,
|
||||
easing: 'ease-out',
|
||||
speed: 300,
|
||||
})
|
||||
|
||||
let barTimeout: any = 0
|
||||
|
||||
$: {
|
||||
if (browser) {
|
||||
if ($navigating) {
|
||||
nProgress.start()
|
||||
barTimeout = setTimeout(() => nProgress.start(), 100)
|
||||
}
|
||||
if (!$navigating) {
|
||||
clearTimeout(barTimeout)
|
||||
nProgress.done()
|
||||
}
|
||||
}
|
||||
@@ -105,6 +108,7 @@
|
||||
Skip Navigation
|
||||
</Button>
|
||||
<Shell
|
||||
dir={$locale == 'he' && $userSettings.useRtl ? 'rtl' : 'ltr'}
|
||||
class="min-h-screen {$userSettings.font == 'inter'
|
||||
? 'font-inter'
|
||||
: $userSettings.font == 'system'
|
||||
|
||||
+179
-16
@@ -1,26 +1,143 @@
|
||||
<script lang="ts" context="module">
|
||||
export interface CachedPosts {
|
||||
data: {
|
||||
sort: SortType
|
||||
listingType: ListingType
|
||||
page: number
|
||||
posts: GetPostsResponse
|
||||
cursor: {
|
||||
next: string | undefined
|
||||
}
|
||||
}
|
||||
params: URLSearchParams
|
||||
lastSeen: number
|
||||
instance: string
|
||||
}
|
||||
|
||||
export const _posts = writable<CachedPosts>(undefined)
|
||||
|
||||
export const shouldReload = (
|
||||
cache: CachedPosts | undefined,
|
||||
params: string,
|
||||
instance: string
|
||||
): boolean =>
|
||||
cache?.instance != instance || cache?.params.toString() != params
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
||||
import { Button, Modal, Select, Spinner } from 'mono-svelte'
|
||||
import { ChartBar, GlobeAmericas, Icon, ServerStack } from 'svelte-hero-icons'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import { ChartBar, ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||
import { getClient, site } from '$lib/lemmy.js'
|
||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
import { enhance } from '$app/forms'
|
||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { writable } from 'svelte/store'
|
||||
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { browser } from '$app/environment'
|
||||
import { onMount } from 'svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
const limit = 20
|
||||
let hasMore = data.posts.posts.length != 0
|
||||
let error: any = undefined
|
||||
let loading = false
|
||||
|
||||
async function loadMore() {
|
||||
if (!hasMore || loading) return
|
||||
|
||||
try {
|
||||
loading = true
|
||||
console.log(`loading more with cursor ${data.cursor.next}`)
|
||||
const newPosts = await getClient()
|
||||
.getPosts({
|
||||
limit: limit,
|
||||
page: data.page,
|
||||
sort: data.sort,
|
||||
type_: data.listingType,
|
||||
page_cursor: data.cursor.next,
|
||||
})
|
||||
.catch((e) => {
|
||||
throw new Error(e)
|
||||
})
|
||||
|
||||
error = null
|
||||
|
||||
hasMore = newPosts.posts.length != 0
|
||||
|
||||
data.cursor.next = newPosts.next_page
|
||||
data.posts.posts = [...data.posts.posts, ...newPosts.posts]
|
||||
|
||||
_posts.update((ps) => ({
|
||||
data: data,
|
||||
params: ps.params,
|
||||
lastSeen: ps.lastSeen,
|
||||
instance: ps.instance,
|
||||
}))
|
||||
|
||||
loading = false
|
||||
} catch (e) {
|
||||
error = e
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
const callback: IntersectionObserverCallback = (entries, observer) => {
|
||||
entries.forEach((entry) => {
|
||||
if (!entry.isIntersecting) return
|
||||
|
||||
const element = entry.target as HTMLElement
|
||||
const id = element.getAttribute('data-index')
|
||||
|
||||
if (!id) return
|
||||
|
||||
$_posts.lastSeen = Number(id)
|
||||
observer.unobserve(element)
|
||||
})
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const observer = new IntersectionObserver(callback, {
|
||||
root: null,
|
||||
rootMargin: '0px',
|
||||
threshold: 0.5,
|
||||
})
|
||||
|
||||
const elements = document.querySelectorAll('.post-container')
|
||||
elements.forEach((el) => observer.observe(el))
|
||||
|
||||
const postContainer = document.querySelector('#feed')
|
||||
if (postContainer) {
|
||||
const mutationObserver = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (
|
||||
node instanceof HTMLElement &&
|
||||
node.classList.contains('post-container')
|
||||
) {
|
||||
observer.observe(node)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
mutationObserver.observe(postContainer, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
@@ -34,11 +151,51 @@
|
||||
<ViewSelect />
|
||||
</div>
|
||||
</div>
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
<div class="mt-auto">
|
||||
|
||||
<svelte:component
|
||||
this={browser ? VirtualFeed : PostFeed}
|
||||
posts={data.posts.posts}
|
||||
>
|
||||
{#if $userSettings.infiniteScroll && browser}
|
||||
{#if error}
|
||||
<div
|
||||
class="flex flex-col justify-center items-center
|
||||
rounded-xl gap-2 py-8 mt-6
|
||||
border !border-b !border-red-500 bg-red-500/5 px-4"
|
||||
>
|
||||
<div class="bg-red-500/30 rounded-full p-3 text-red-500">
|
||||
<Icon src={ExclamationTriangle} size="24" solid></Icon>
|
||||
</div>
|
||||
<pre class="py-0.5">{error}</pre>
|
||||
<Button
|
||||
color="primary"
|
||||
{loading}
|
||||
disabled={loading}
|
||||
on:click={loadMore}
|
||||
>
|
||||
{$t('message.retry')}
|
||||
</Button>
|
||||
</div>
|
||||
{:else if hasMore}
|
||||
<div class="w-full flex flex-col skeleton gap-2 animate-pulse pt-6">
|
||||
<div class="w-96 h-8"></div>
|
||||
<div class="w-full h-48"></div>
|
||||
<div class="!bg-transparent h-8 flex justify-between">
|
||||
<div class="w-48 h-8"></div>
|
||||
<div class="w-24 h-8"></div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
|
||||
{/if}
|
||||
</svelte:component>
|
||||
<svelte:element
|
||||
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
|
||||
class="mt-auto"
|
||||
>
|
||||
<Pageination
|
||||
page={data.page}
|
||||
cursor={{ next: data.cursor.next, back: data.cursor.back }}
|
||||
cursor={{ next: data.cursor.next }}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
on:cursor={(c) => {
|
||||
searchParam($page.url, 'cursor', c.detail)
|
||||
@@ -52,5 +209,11 @@
|
||||
})}
|
||||
</span>
|
||||
</Pageination>
|
||||
</div>
|
||||
</svelte:element>
|
||||
</div>
|
||||
|
||||
<style lang="postcss">
|
||||
.skeleton * {
|
||||
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
|
||||
}
|
||||
</style>
|
||||
+49
-23
@@ -1,10 +1,11 @@
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
|
||||
import { get, writable } from 'svelte/store'
|
||||
import { error } from '@sveltejs/kit'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { _posts, shouldReload, type CachedPosts } from './+page.svelte'
|
||||
import { browser } from '$app/environment'
|
||||
import { instance } from '$lib/instance'
|
||||
|
||||
export async function load({ url, fetch }) {
|
||||
const cursor = url.searchParams.get('cursor') as string | undefined
|
||||
@@ -18,27 +19,52 @@ export async function load({ url, fetch }) {
|
||||
const listingType: ListingType =
|
||||
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
|
||||
|
||||
const posts = await getClient(undefined, fetch).getPosts({
|
||||
limit: 20,
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: listingType,
|
||||
page_cursor: cursor,
|
||||
show_hidden: settings.posts.showHidden,
|
||||
})
|
||||
const cached: CachedPosts | undefined = get(_posts)
|
||||
|
||||
const posts = shouldReload(cached, url.searchParams.toString(), get(instance))
|
||||
? await getClient(undefined, fetch).getPosts({
|
||||
limit: 20,
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: listingType,
|
||||
page_cursor: cursor,
|
||||
show_hidden: settings.posts.showHidden,
|
||||
})
|
||||
: cached.data.posts
|
||||
|
||||
if (
|
||||
shouldReload(cached, url.searchParams.toString(), get(instance)) &&
|
||||
browser
|
||||
)
|
||||
_posts.set({
|
||||
data: {
|
||||
sort: sort,
|
||||
listingType: listingType,
|
||||
page: page || 1,
|
||||
posts: posts,
|
||||
cursor: {
|
||||
next: posts.next_page,
|
||||
},
|
||||
},
|
||||
params: url.searchParams,
|
||||
lastSeen: 0,
|
||||
instance: get(instance),
|
||||
})
|
||||
|
||||
try {
|
||||
return {
|
||||
sort: sort,
|
||||
listingType: listingType,
|
||||
page: page || 1,
|
||||
posts: posts,
|
||||
cursor: {
|
||||
next: posts.next_page,
|
||||
back: prevCursor,
|
||||
current: cursor,
|
||||
},
|
||||
}
|
||||
return shouldReload(cached, url.searchParams.toString(), get(instance))
|
||||
? {
|
||||
sort: sort,
|
||||
listingType: listingType,
|
||||
page: page || 1,
|
||||
posts: posts,
|
||||
cursor: {
|
||||
next: posts.next_page,
|
||||
back: prevCursor,
|
||||
current: cursor,
|
||||
},
|
||||
}
|
||||
: cached.data
|
||||
} catch (err) {
|
||||
error(500, {
|
||||
message: 'Failed to fetch homepage.',
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<script>
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { profile } from '$lib/auth'
|
||||
import { notifications, profile } from '$lib/auth'
|
||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { Badge } from 'mono-svelte'
|
||||
</script>
|
||||
|
||||
{#if ($profile?.user?.notifications.applications ?? 0) > 0}
|
||||
{#if $notifications.applications > 0}
|
||||
<span class="flex flex-row text-red-500 gap-2">
|
||||
<Badge color="red-subtle" class="w-max">
|
||||
{$profile?.user?.notifications.applications}
|
||||
{$notifications.applications}
|
||||
</Badge> unread applications
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { get } from 'svelte/store'
|
||||
import { getClient, site as siteStore } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { site as siteStore } from '$lib/lemmy'
|
||||
|
||||
export async function load({ fetch }) {
|
||||
if (!get(profile)) return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { notifications, profile } from '$lib/auth.js'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import { Material, toast } from 'mono-svelte'
|
||||
@@ -60,7 +60,7 @@
|
||||
application.admin = $profile.user!.local_user_view.person
|
||||
application.registration_application.deny_reason = denyReason
|
||||
|
||||
$profile.user!.notifications.applications -= 1
|
||||
$notifications.applications -= 1
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: err as any,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { fullCommunityName, searchParam } from '$lib/util.js'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { setSessionStorage } from '$lib/session.js'
|
||||
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import { Button, Modal, toast } from 'mono-svelte'
|
||||
import { afterNavigate } from '$app/navigation'
|
||||
import { browser } from '$app/environment'
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||
import { t } from '$lib/translations.js'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
export let data = {
|
||||
crosspost: false,
|
||||
@@ -47,6 +48,6 @@
|
||||
passedCommunity={community}
|
||||
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
|
||||
>
|
||||
<h1 class="text-3xl font-bold" slot="formtitle">Create Post</h1>
|
||||
<Header class="text-3xl font-bold" slot="formtitle">Create Post</Header>
|
||||
</PostForm>
|
||||
</div>
|
||||
@@ -13,7 +13,7 @@
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { notifications, profile } from '$lib/auth.js'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
const response = await getClient().markAllAsRead()
|
||||
|
||||
$profile.user.notifications.inbox = 0
|
||||
$notifications.inbox = 0
|
||||
|
||||
goto($page.url, {
|
||||
invalidateAll: true,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { notifications, profile } from '$lib/auth.js'
|
||||
import {
|
||||
ArrowUturnLeft,
|
||||
ArrowUturnUp,
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
item.read = isRead
|
||||
if ($profile.user) $profile.user.notifications.inbox += isRead ? -1 : 1
|
||||
if ($profile.user) $notifications.inbox += isRead ? -1 : 1
|
||||
|
||||
loading = false
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
username: form.username,
|
||||
}
|
||||
|
||||
profile.set({
|
||||
...newProfile,
|
||||
})
|
||||
|
||||
return {
|
||||
profile: id,
|
||||
profiles: [...pd.profiles, newProfile],
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
PrivateMessageReportView,
|
||||
} from 'lemmy-js-client'
|
||||
import { Check, Icon } from 'svelte-hero-icons'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { notifications, profile } from '$lib/auth.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import type { ReportView } from '$lib/lemmy/report.js'
|
||||
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
|
||||
@@ -77,7 +77,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$profile.user.notifications.reports += item.resolved ? 1 : -1
|
||||
$notifications.reports += item.resolved ? 1 : -1
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: err as any,
|
||||
|
||||
@@ -42,22 +42,25 @@
|
||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||
import { Popover } from 'mono-svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||
|
||||
export let data
|
||||
|
||||
let post = data.post
|
||||
|
||||
// onMount(async () => {
|
||||
// if (
|
||||
// !(post.post_view.read && $userSettings.markPostsAsRead) &&
|
||||
// $profile?.jwt
|
||||
// ) {
|
||||
// getClient().markPostAsRead({
|
||||
// read: $userSettings.markPostsAsRead,
|
||||
// post_id: post.post_view.post.id,
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
onMount(async () => {
|
||||
if (
|
||||
!(post.post_view.read && $userSettings.markPostsAsRead) &&
|
||||
$profile?.jwt
|
||||
) {
|
||||
getClient().markPostAsRead({
|
||||
read: $userSettings.markPostsAsRead,
|
||||
post_ids: [post.post_view.post.id],
|
||||
// @ts-ignore
|
||||
post_id: post.post_view.post.id,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
afterNavigate(async () => {
|
||||
// reactivity hack
|
||||
@@ -110,7 +113,24 @@
|
||||
$: remoteView =
|
||||
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
|
||||
|
||||
const test = 'wow'
|
||||
const virtualizer = createWindowVirtualizer({
|
||||
count: 0,
|
||||
estimateSize: () => 50,
|
||||
})
|
||||
|
||||
onMount(async () => {
|
||||
const comments = await data.comments
|
||||
|
||||
$virtualizer.setOptions({ count: comments.comments.length })
|
||||
})
|
||||
|
||||
let virtualItemEls: HTMLElement[] = []
|
||||
|
||||
$: items = $virtualizer.getVirtualItems()
|
||||
$: {
|
||||
if (virtualItemEls.length)
|
||||
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -188,6 +208,7 @@
|
||||
moderator: post.post_view.creator_is_moderator,
|
||||
}}
|
||||
published={publishedToDate(post.post_view.post.published)}
|
||||
bind:title={post.post_view.post.name}
|
||||
/>
|
||||
</div>
|
||||
<Button on:click={() => history.back()} size="square-md">
|
||||
@@ -315,7 +336,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
{/each}
|
||||
</div>
|
||||
{:then comments}
|
||||
{#if $profile?.user}
|
||||
{#if $profile?.jwt}
|
||||
<CommentForm
|
||||
postId={post.post_view.post.id}
|
||||
on:comment={(comment) =>
|
||||
@@ -325,7 +346,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
])}
|
||||
locked={(post.post_view.post.locked &&
|
||||
!(
|
||||
$profile?.user.local_user_view.local_user.admin ||
|
||||
$profile?.user?.local_user_view.local_user.admin ||
|
||||
$profile?.user?.moderates
|
||||
.map((c) => c.community.id)
|
||||
.includes(data.post.community_view.community.id)
|
||||
|
||||
@@ -1,56 +1,57 @@
|
||||
import { browser } from '$app/environment'
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { awaitIfServer } from '$lib/promise.js'
|
||||
import { SSR_ENABLED, userSettings } from '$lib/settings.js'
|
||||
import { error } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
import { browser } from "$app/environment";
|
||||
import { env } from "$env/dynamic/public";
|
||||
import { profile } from "$lib/auth.js";
|
||||
import CommunityCard from "$lib/components/lemmy/community/CommunityCard.svelte";
|
||||
import { getClient } from "$lib/lemmy.js";
|
||||
import { awaitIfServer } from "$lib/promise.js";
|
||||
import { SSR_ENABLED, userSettings } from "$lib/settings.js";
|
||||
import { error } from "@sveltejs/kit";
|
||||
import type { GetComments } from "lemmy-js-client";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
export async function load({ params, url, fetch }) {
|
||||
const thread = url.searchParams.get('thread')
|
||||
let parentId: number | undefined
|
||||
let showContext: string | undefined = undefined
|
||||
const thread = url.searchParams.get("thread");
|
||||
let parentId: number | undefined;
|
||||
let showContext: string | undefined = undefined;
|
||||
|
||||
let max_depth = 3
|
||||
let max_depth = 3;
|
||||
|
||||
if (thread) {
|
||||
const split = thread.split('.')
|
||||
const split = thread.split(".");
|
||||
if (split.length >= 9) {
|
||||
const sliced = split.slice(0, split.length - 4)
|
||||
showContext = sliced[sliced.length - 1]
|
||||
parentId = Number(split[split.length - 5])
|
||||
const sliced = split.slice(0, split.length - 4);
|
||||
showContext = sliced[sliced.length - 1];
|
||||
parentId = Number(split[split.length - 5]);
|
||||
} else {
|
||||
parentId = Number(split[1])
|
||||
parentId = Number(split[1]);
|
||||
}
|
||||
|
||||
if (!Number.isInteger(parentId)) {
|
||||
parentId = undefined
|
||||
parentId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (parentId) {
|
||||
max_depth = 10
|
||||
max_depth = 10;
|
||||
}
|
||||
|
||||
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
|
||||
const sort = get(userSettings)?.defaultSort?.comments ?? "Hot";
|
||||
|
||||
const commentParams: any = {
|
||||
const commentParams: GetComments = {
|
||||
post_id: Number(params.id),
|
||||
type_: 'All',
|
||||
type_: "All",
|
||||
limit: 50,
|
||||
page: 1,
|
||||
max_depth: max_depth,
|
||||
saved_only: false,
|
||||
sort: sort,
|
||||
parent_id: parentId,
|
||||
}
|
||||
};
|
||||
|
||||
const comments = getClient(params.instance, fetch).getComments(commentParams);
|
||||
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
|
||||
id: Number(params.id),
|
||||
})
|
||||
const comments = getClient(params.instance, fetch).getComments(commentParams)
|
||||
});
|
||||
|
||||
return {
|
||||
thread: {
|
||||
@@ -60,13 +61,13 @@ export async function load({ params, url, fetch }) {
|
||||
post: post,
|
||||
commentSort: sort,
|
||||
comments: (await awaitIfServer(comments)).data,
|
||||
// slots: {
|
||||
// sidebar: {
|
||||
// component: CommunityCard,
|
||||
// props: {
|
||||
// community_view: post.community_view,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
}
|
||||
slots: {
|
||||
sidebar: {
|
||||
component: CommunityCard,
|
||||
props: {
|
||||
community_view: post.community_view,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -12,12 +12,17 @@
|
||||
TextInput,
|
||||
toast,
|
||||
Popover,
|
||||
Modal,
|
||||
TextArea,
|
||||
} from 'mono-svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import {
|
||||
ArrowDownTray,
|
||||
ArrowPath,
|
||||
ArrowRight,
|
||||
ArrowUpOnSquare,
|
||||
ArrowUpTray,
|
||||
ChatBubbleOvalLeftEllipsis,
|
||||
CheckCircle,
|
||||
ChevronDown,
|
||||
@@ -35,31 +40,90 @@
|
||||
import { DOMAIN_REGEX_FORMS, removeItem } from '$lib/util.js'
|
||||
import Section from './Section.svelte'
|
||||
import ToggleSetting from './ToggleSetting.svelte'
|
||||
import { locales, t } from '$lib/translations'
|
||||
import { locale, locales, t } from '$lib/translations'
|
||||
import { defaultLinks, iconOfLink } from '$lib/components/ui/navbar/link'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
|
||||
let pin: string = ''
|
||||
let importing = false
|
||||
let importText = ''
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{$t('settings.title')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1 class="text-3xl font-bold flex justify-between">
|
||||
{$t('settings.title')}
|
||||
<Button
|
||||
size="square-md"
|
||||
on:click={() => {
|
||||
toast({
|
||||
content: $t('toast.resetSettings'),
|
||||
action: () => ($userSettings = defaultSettings),
|
||||
})
|
||||
{#if importing}
|
||||
<Modal
|
||||
bind:open={importing}
|
||||
on:action={() => {
|
||||
try {
|
||||
if (importText == '') {
|
||||
throw new Error('Import is empty')
|
||||
}
|
||||
const parsed = JSON.parse(importText)
|
||||
const merged = { ...defaultSettings, ...parsed }
|
||||
|
||||
$userSettings = merged
|
||||
|
||||
toast({ content: $t('toast.settingsImport'), type: 'success' })
|
||||
importing = false
|
||||
} catch (err) {
|
||||
// @ts-ignore
|
||||
toast({ content: err, type: 'error' })
|
||||
}
|
||||
}}
|
||||
class="font-normal"
|
||||
title={$t('routes.theme.import')}
|
||||
action={$t('routes.theme.import')}
|
||||
>
|
||||
<Icon src={ArrowPath} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
</h1>
|
||||
<TextArea bind:value={importText} style="font-family: monospace;" />
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
<Header class="text-3xl font-bold flex justify-between">
|
||||
{$t('settings.title')}
|
||||
<div class="flex items-center">
|
||||
<Button
|
||||
size="square-lg"
|
||||
on:click={() => {
|
||||
importText = ''
|
||||
importing = true
|
||||
}}
|
||||
class="font-normal"
|
||||
title={$t('settings.import')}
|
||||
roundingSide="left"
|
||||
>
|
||||
<Icon src={ArrowDownTray} mini size="18" slot="prefix" />
|
||||
</Button>
|
||||
<Button
|
||||
size="square-lg"
|
||||
on:click={() => {
|
||||
const json = JSON.stringify($userSettings)
|
||||
navigator?.clipboard?.writeText?.(json)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
class="font-normal"
|
||||
title={$t('settings.export')}
|
||||
rounding="none"
|
||||
>
|
||||
<Icon src={ArrowUpTray} mini size="18" slot="prefix" />
|
||||
</Button>
|
||||
<Button
|
||||
size="square-lg"
|
||||
on:click={() => {
|
||||
toast({
|
||||
content: $t('toast.resetSettings'),
|
||||
action: () => ($userSettings = defaultSettings),
|
||||
})
|
||||
}}
|
||||
class="font-normal"
|
||||
title={$t('settings.reset')}
|
||||
roundingSide="right"
|
||||
>
|
||||
<Icon src={ArrowPath} mini size="18" slot="prefix" />
|
||||
</Button>
|
||||
</div>
|
||||
</Header>
|
||||
|
||||
<div class="flex flex-col gap-4" style="scroll-behavior: smooth;">
|
||||
<Section title={$t('settings.navigation.title')}>
|
||||
@@ -135,32 +199,40 @@
|
||||
</Section>
|
||||
|
||||
<Section title={$t('settings.app.title')}>
|
||||
<Setting>
|
||||
<span slot="title" class="inline-flex items-center gap-2">
|
||||
{$t('settings.app.lang.title')}
|
||||
<Badge>{$t('settings.beta')}</Badge>
|
||||
</span>
|
||||
<p slot="description">
|
||||
{$t('settings.app.lang.description')}
|
||||
<Note>
|
||||
{$t('settings.app.lang.note')}
|
||||
</Note>
|
||||
<Link href="/translators" highlight class="text-base font-semibold">
|
||||
{$t('settings.app.lang.credits')}
|
||||
</Link>
|
||||
</p>
|
||||
<Select bind:value={$userSettings.language}>
|
||||
<option value={null}>{$t('settings.app.lang.auto')}</option>
|
||||
{#each $locales as locale}
|
||||
<option value={locale}>
|
||||
{$t(`settings.app.lang.${locale}`, { default: locale })}
|
||||
</option>
|
||||
{/each}
|
||||
{#if $userSettings.debugInfo}
|
||||
<option value="dev">Raw Strings</option>
|
||||
{/if}
|
||||
</Select>
|
||||
</Setting>
|
||||
<div class="flex flex-col gap-2">
|
||||
<Setting>
|
||||
<span slot="title" class="inline-flex items-center gap-2">
|
||||
{$t('settings.app.lang.title')}
|
||||
<Badge>{$t('settings.beta')}</Badge>
|
||||
</span>
|
||||
<p slot="description">
|
||||
{$t('settings.app.lang.description')}
|
||||
<Note>
|
||||
{$t('settings.app.lang.note')}
|
||||
</Note>
|
||||
<Link href="/translators" highlight class="text-base font-semibold">
|
||||
{$t('settings.app.lang.credits')}
|
||||
</Link>
|
||||
</p>
|
||||
<Select bind:value={$userSettings.language}>
|
||||
<option value={null}>{$t('settings.app.lang.auto')}</option>
|
||||
{#each $locales as locale}
|
||||
<option value={locale}>
|
||||
{$t(`settings.app.lang.${locale}`, { default: locale })}
|
||||
</option>
|
||||
{/each}
|
||||
{#if $userSettings.debugInfo}
|
||||
<option value="dev">Raw Strings</option>
|
||||
{/if}
|
||||
</Select>
|
||||
</Setting>
|
||||
{#if $locale == 'he'}
|
||||
<ToggleSetting
|
||||
bind:checked={$userSettings.useRtl}
|
||||
title={$t('settings.app.lang.useRtl.title')}
|
||||
></ToggleSetting>
|
||||
{/if}
|
||||
</div>
|
||||
<Setting>
|
||||
<span slot="title">{$t('settings.app.view.title')}</span>
|
||||
<ViewSelect showLabel={false} />
|
||||
@@ -214,6 +286,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</Setting>
|
||||
<ToggleSetting
|
||||
beta
|
||||
bind:checked={$userSettings.infiniteScroll}
|
||||
title={$t('settings.app.infiniteScroll.title')}
|
||||
description={$t('settings.app.infiniteScroll.description')}
|
||||
/>
|
||||
<ToggleSetting
|
||||
bind:checked={$userSettings.openLinksInNewTab}
|
||||
title={$t('settings.app.postsInNewTab.title')}
|
||||
@@ -287,6 +365,35 @@
|
||||
pattern={DOMAIN_REGEX_FORMS}
|
||||
/>
|
||||
</Setting>
|
||||
<div>
|
||||
<ToggleSetting
|
||||
title={$t('settings.app.titleTags.title')}
|
||||
description={$t('settings.app.titleTags.description')}
|
||||
bind:checked={$userSettings.parseTags}
|
||||
/>
|
||||
<Setting>
|
||||
<svelte:fragment slot="title">
|
||||
{$t('settings.app.titleTags.rules.title')}
|
||||
</svelte:fragment>
|
||||
<div
|
||||
class="flex flex-col divide-y [&>*]:py-2 items-end divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#each Object.keys($userSettings.tagRules) as rule}
|
||||
<div class="flex flex-row flex-wrap items-center gap-2">
|
||||
<span class="text-lg font-medium">{rule}</span>
|
||||
<MultiSelect
|
||||
bind:selected={$userSettings.tagRules[rule]}
|
||||
options={['blur', 'hide']}
|
||||
optionNames={[
|
||||
$t('settings.app.titleTags.rules.blur'),
|
||||
$t('settings.app.titleTags.rules.hide'),
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</Setting>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title={$t('settings.embeds.title')}>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
export let title: string
|
||||
export let description: string | undefined = undefined
|
||||
export let checked: boolean = false
|
||||
export let beta = false
|
||||
|
||||
export let supportedPlatforms = {
|
||||
desktop: true,
|
||||
@@ -20,25 +21,30 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
|
||||
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
||||
{#if Object.values(supportedPlatforms).some((v) => v == false) || beta}
|
||||
<div class="flex items-center gap-2 flex-wrap">
|
||||
{#if supportedPlatforms.desktop}
|
||||
<Badge>
|
||||
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
|
||||
{$t('settings.desktop')}
|
||||
</Badge>
|
||||
{#if beta}
|
||||
<Badge>Beta</Badge>
|
||||
{/if}
|
||||
{#if supportedPlatforms.tablet}
|
||||
<Badge>
|
||||
<Icon src={DeviceTablet} micro size="14" slot="icon" />
|
||||
{$t('settings.tablet')}
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if supportedPlatforms.mobile}
|
||||
<Badge>
|
||||
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
|
||||
{$t('settings.mobile')}
|
||||
</Badge>
|
||||
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
||||
{#if supportedPlatforms.desktop}
|
||||
<Badge>
|
||||
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
|
||||
{$t('settings.desktop')}
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if supportedPlatforms.tablet}
|
||||
<Badge>
|
||||
<Icon src={DeviceTablet} micro size="14" slot="icon" />
|
||||
{$t('settings.tablet')}
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if supportedPlatforms.mobile}
|
||||
<Badge>
|
||||
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
|
||||
{$t('settings.mobile')}
|
||||
</Badge>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
+1
-1
@@ -108,4 +108,4 @@ pre {
|
||||
|
||||
.banner {
|
||||
mask-image: linear-gradient(to left, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user