Merge branch 'main' into infinite-scroll
This commit is contained in:
commit
0da8d729f6
30 files changed
+431
-224
No files matched your search
+84
-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,75 @@ 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 {
|
||||
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 +202,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 +237,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 +276,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 +303,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 +321,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 +339,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 +385,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()
|
||||
})
|
||||
@@ -55,6 +55,11 @@
|
||||
}
|
||||
</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
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
}
|
||||
</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'
|
||||
@@ -184,6 +188,8 @@
|
||||
>
|
||||
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown>
|
||||
</a>
|
||||
{:else}
|
||||
<div style="grid-area: title; margin: 0;"></div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
|
||||
@@ -18,8 +18,8 @@ export const bestImageURL = (
|
||||
}
|
||||
|
||||
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`
|
||||
return `${post.thumbnail_url}?thumbnail=512&format=webp`
|
||||
else if (compact && post.url) return `${post.url}?thumbnail=512&format=webp`
|
||||
|
||||
if (post.url) return `${post.url}?thumbnail=${width}&format=webp`
|
||||
else if (post.thumbnail_url)
|
||||
@@ -37,7 +37,7 @@ export const optimizeImageURL = (
|
||||
url.searchParams.append('format', 'webp')
|
||||
url.searchParams.append(
|
||||
'thumbnail',
|
||||
findClosestNumber([128, 256, 512, 1024], width).toString()
|
||||
findClosestNumber([128, 256, 512, 728, 1024, 1536], width).toString()
|
||||
)
|
||||
return url.toString()
|
||||
} catch (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 -->
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
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 +45,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
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
export let type: MediaType = 'none'
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@component
|
||||
Thumbnails for compact and list view posts.
|
||||
-->
|
||||
{#if view == 'compact' || (view == 'list' && type != 'none')}
|
||||
<div
|
||||
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
|
||||
|
||||
@@ -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,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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -582,7 +582,11 @@
|
||||
"fi": "Finnish",
|
||||
"pt": "Portuguese",
|
||||
"auto": "Auto",
|
||||
"credits": "Credits"
|
||||
"credits": "Credits",
|
||||
"useRtl": {
|
||||
"title": "Use RTL layout",
|
||||
"description": "Use an RTL layout for RTL languages."
|
||||
}
|
||||
},
|
||||
"view": {
|
||||
"title": "Post style",
|
||||
|
||||
+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"
|
||||
}
|
||||
}
|
||||
+182
-1
@@ -1 +1,182 @@
|
||||
{}
|
||||
{
|
||||
"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": "שעה"
|
||||
}
|
||||
},
|
||||
"new": "חדש",
|
||||
"old": "ישן",
|
||||
"controversial": "שנוי במחלוקת",
|
||||
"mostcomments": "תגובות",
|
||||
"newcomments": "תגובות חדשות"
|
||||
},
|
||||
"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": "מחיקת תוכן"
|
||||
}
|
||||
},
|
||||
"confirmPassword": "אישור סיסמה",
|
||||
"post": {
|
||||
"title": "כותרת",
|
||||
"altText": "טקסט חלופי",
|
||||
"create": "יצירת פוסט",
|
||||
"edit": "עריכת פוסט",
|
||||
"community": "קהילה",
|
||||
"url": "קישור",
|
||||
"body": "גוף",
|
||||
"nsfw": "תוכן למבוגרים",
|
||||
"generateTitle": "יצירת כותרת",
|
||||
"uploadImage": "העלאת תמונה"
|
||||
},
|
||||
"signup": {
|
||||
"application": {
|
||||
"info": "כדי להצטרף לשרת זה, חובה למלא את בקשת ההצטרפות ולחכות לקבלה. ישלח אימייל כאשר בקשתך התקבלה.",
|
||||
"label": "בקשה להצטרפות"
|
||||
},
|
||||
"title": "הרשמה",
|
||||
"description": "נא לבחור שרת שמעניין אותך, או לכתוב קישור באופן ידני.",
|
||||
"chooseInstance": "בחירת שרת",
|
||||
"closed": {
|
||||
"title": "רישומים סגורים",
|
||||
"description": "בשרת זה הרישומים סגורים. נא למצוא שרת אחר.",
|
||||
"anotherInstance": "מציאת שרת אחר"
|
||||
}
|
||||
},
|
||||
"email": "אימייל",
|
||||
"description": "תיאור",
|
||||
"username": "שם משתמש",
|
||||
"name": "שם",
|
||||
"password": "סיסמה",
|
||||
"2fa": "קוד 2FA",
|
||||
"forgotpassword": "שכחתי את הסיסמה",
|
||||
"submit": "שליחה",
|
||||
"edit": "עריכה",
|
||||
"preview": "תצוגה מקדימה"
|
||||
},
|
||||
"profile": {
|
||||
"profile": "פרופיל",
|
||||
"inbox": "דואר נכנס",
|
||||
"saved": "שמורים"
|
||||
},
|
||||
"routes": {
|
||||
"frontpage": {
|
||||
"footer": "{{users:number}} {{users; 1:משתמש; default:משתמשים;}} {{users; 1:פעיל; default:פעילים;}}",
|
||||
"title": "דף הבית"
|
||||
},
|
||||
"modlog": "יומן הנהלה",
|
||||
"instances": "שרתים",
|
||||
"legal": {
|
||||
"title": "משפטי",
|
||||
"noLegal": "לשרת זה אין מידע משפטי."
|
||||
},
|
||||
"profile": {
|
||||
"user": "משתמש",
|
||||
"settings": "הגדרות"
|
||||
},
|
||||
"translators": "מתרגמים",
|
||||
"accounts": "חשבונות",
|
||||
"communities": "קהילות",
|
||||
"search": {
|
||||
"title": "חיפוש"
|
||||
}
|
||||
},
|
||||
"nav": {
|
||||
"home": "בית",
|
||||
"admin": "מנהל",
|
||||
"moderation": "מנהל",
|
||||
"communities": "קהילות",
|
||||
"search": "חיפוש",
|
||||
"create": {
|
||||
"label": "יצירה",
|
||||
"community": "קהילה",
|
||||
"logingate": "חובה עליך להתחבר כדי ליצור תוכן."
|
||||
},
|
||||
"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}} או גרסה עדכנית יותר."
|
||||
}
|
||||
}
|
||||
+21
-15
@@ -48,7 +48,7 @@ async function customFetch(
|
||||
if (auth && url) url.searchParams.set('auth', auth)
|
||||
|
||||
const res = await f(url ?? input, init)
|
||||
if (!res.ok) error(res.status, await res.text());
|
||||
if (!res.ok) error(res.status, await res.text())
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -101,27 +101,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
|
||||
}
|
||||
@@ -90,6 +90,7 @@ interface Settings {
|
||||
}
|
||||
infiniteScroll: boolean
|
||||
language: string | null
|
||||
useRtl: boolean
|
||||
translator: string | undefined
|
||||
}
|
||||
|
||||
@@ -158,6 +159,7 @@ export const defaultSettings: Settings = {
|
||||
},
|
||||
infiniteScroll: true,
|
||||
language: env.PUBLIC_LANGUAGE ?? null,
|
||||
useRtl: false,
|
||||
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ 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: '',
|
||||
|
||||
+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) =>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
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,
|
||||
@@ -105,6 +106,7 @@
|
||||
Skip Navigation
|
||||
</Button>
|
||||
<Shell
|
||||
dir={$locale == 'he' && $userSettings.useRtl ? 'rtl' : 'ltr'}
|
||||
class="min-h-screen {$userSettings.font == 'inter'
|
||||
? 'font-inter'
|
||||
: $userSettings.font == 'system'
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -48,17 +48,19 @@
|
||||
|
||||
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
|
||||
@@ -333,7 +335,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) =>
|
||||
@@ -343,7 +345,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)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
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'
|
||||
|
||||
let pin: string = ''
|
||||
@@ -135,32 +135,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} />
|
||||
|
||||
Reference in new issue
Block a user