fix: Fix lint errors (#559)
* cleanup: postactions styling * misc: fix first round of errors * pkg: remove vitest * fix: fix lint errors stage 2 * fix: fix lint errors stage 3 * fix: fix lint errors, stage 3 * misc: update eslint rules to warn for writable derived
This commit is contained in:
1 parent
1824245f13
commit
76c581123a
225 files changed
+1553
-2352
No files matched your search
+45
-36
@@ -1,39 +1,48 @@
|
|||||||
import js from '@eslint/js';
|
import js from '@eslint/js'
|
||||||
import { includeIgnoreFile } from '@eslint/compat';
|
import { includeIgnoreFile } from '@eslint/compat'
|
||||||
import svelte from 'eslint-plugin-svelte';
|
import svelte from 'eslint-plugin-svelte'
|
||||||
import globals from 'globals';
|
import globals from 'globals'
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url'
|
||||||
import ts from 'typescript-eslint';
|
import ts from 'typescript-eslint'
|
||||||
import svelteConfig from './svelte.config.js';
|
import svelteConfig from './svelte.config.js'
|
||||||
|
|
||||||
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url))
|
||||||
|
|
||||||
export default ts.config(
|
export default ts.config(
|
||||||
includeIgnoreFile(gitignorePath),
|
includeIgnoreFile(gitignorePath),
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
...ts.configs.recommended,
|
...ts.configs.recommended,
|
||||||
...svelte.configs.recommended,
|
...svelte.configs.recommended,
|
||||||
{
|
{
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
globals: { ...globals.browser, ...globals.node }
|
globals: { ...globals.browser, ...globals.node },
|
||||||
},
|
},
|
||||||
rules: { // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
|
rules: {
|
||||||
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
|
||||||
"no-undef": 'off' }
|
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
||||||
},
|
'no-undef': 'off',
|
||||||
{
|
// sveltekit should make this native then
|
||||||
files: [
|
'svelte/valid-prop-names-in-kit-pages': 'off',
|
||||||
'**/*.svelte',
|
'svelte/no-at-html-tags': 'warn',
|
||||||
'**/*.svelte.ts',
|
'@typescript-eslint/no-unsafe-function-type': 'warn',
|
||||||
'**/*.svelte.js'
|
'svelte/require-each-key': 'off',
|
||||||
],
|
'svelte/prefer-writable-derived': 'warn',
|
||||||
languageOptions: {
|
},
|
||||||
parserOptions: {
|
},
|
||||||
projectService: true,
|
{
|
||||||
extraFileExtensions: ['.svelte'],
|
files: [
|
||||||
parser: ts.parser,
|
'src/lib/**/*.ts',
|
||||||
svelteConfig
|
'**/*.svelte',
|
||||||
}
|
'**/*.svelte.ts',
|
||||||
}
|
'**/*.svelte.js',
|
||||||
}
|
],
|
||||||
);
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
projectService: true,
|
||||||
|
extraFileExtensions: ['.svelte'],
|
||||||
|
parser: ts.parser,
|
||||||
|
svelteConfig,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
+1
-2
@@ -42,8 +42,7 @@
|
|||||||
"typescript": "^5.5.0",
|
"typescript": "^5.5.0",
|
||||||
"typescript-eslint": "^8.33.1",
|
"typescript-eslint": "^8.33.1",
|
||||||
"ua-parser-js": "^1.0.38",
|
"ua-parser-js": "^1.0.38",
|
||||||
"vite": "^5.4.14",
|
"vite": "^5.4.14"
|
||||||
"vitest": "^1.0.0"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"svelte": "^5.19.7"
|
"svelte": "^5.19.7"
|
||||||
|
|||||||
Vendored
+3
-1
@@ -1,7 +1,7 @@
|
|||||||
// See https://kit.svelte.dev/docs/types#app
|
// See https://kit.svelte.dev/docs/types#app
|
||||||
|
|
||||||
import type { Action } from '$lib/components/ui/navbar/commands/actions.svelte'
|
import type { Action } from '$lib/components/ui/navbar/commands/actions.svelte'
|
||||||
import type { ComponentType, SvelteComponent } from 'svelte'
|
import type { ComponentType } from 'svelte'
|
||||||
|
|
||||||
// for information about these interfaces
|
// for information about these interfaces
|
||||||
declare global {
|
declare global {
|
||||||
@@ -14,6 +14,7 @@ declare global {
|
|||||||
slots?: {
|
slots?: {
|
||||||
sidebar?: {
|
sidebar?: {
|
||||||
component?: ComponentType
|
component?: ComponentType
|
||||||
|
// eslint-disable-next-line
|
||||||
props?: any
|
props?: any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +31,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {}
|
export {}
|
||||||
|
// eslint-disable-next-line
|
||||||
declare const __VERSION__: string
|
declare const __VERSION__: string
|
||||||
|
|
||||||
declare module 'markdown-it-sub'
|
declare module 'markdown-it-sub'
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
export function handleError({ error, event }) {
|
export function handleError({ error }) {
|
||||||
return {
|
return {
|
||||||
message: error as any,
|
message: error as string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -8,7 +8,7 @@ export const handleError: HandleServerError = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
console.error(`An error was captured:`)
|
console.error(`An error was captured:`)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
console.error(`Event:`, event),
|
console.error(`Event:`, event)
|
||||||
console.error(`Status:`, status),
|
console.error(`Status:`, status)
|
||||||
console.error(`Message:`, message)
|
console.error(`Message:`, message)
|
||||||
}
|
}
|
||||||
+42
-46
@@ -1,22 +1,23 @@
|
|||||||
|
import { browser } from '$app/environment'
|
||||||
|
import { env } from '$env/dynamic/public'
|
||||||
import {
|
import {
|
||||||
amModOfAny,
|
amModOfAny,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import { toast } from 'mono-svelte'
|
|
||||||
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
||||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { site } from './lemmy.svelte'
|
|
||||||
import { instanceToURL, moveItem } from '$lib/util.svelte'
|
import { instanceToURL, moveItem } from '$lib/util.svelte'
|
||||||
|
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
|
||||||
import {
|
import {
|
||||||
|
type Community,
|
||||||
type GetSiteResponse,
|
type GetSiteResponse,
|
||||||
type MyUserInfo,
|
type MyUserInfo,
|
||||||
type Community,
|
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
|
import { toast } from 'mono-svelte'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
|
|
||||||
import { browser } from '$app/environment'
|
|
||||||
import { env } from '$env/dynamic/public'
|
|
||||||
import { t } from './i18n/translations'
|
import { t } from './i18n/translations'
|
||||||
|
import { site } from './lemmy.svelte'
|
||||||
|
import { errorMessage } from './lemmy/error'
|
||||||
|
|
||||||
const getDefaultProfile = (): Profile => ({
|
const getDefaultProfile = (): Profile => ({
|
||||||
id: -1,
|
id: -1,
|
||||||
@@ -31,6 +32,7 @@ function getFromStorage<T>(key: string): T | undefined {
|
|||||||
return JSON.parse(lc)
|
return JSON.parse(lc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
function setFromStorage(key: string, item: any, stringify: boolean = true) {
|
function setFromStorage(key: string, item: any, stringify: boolean = true) {
|
||||||
if (typeof localStorage == 'undefined') return
|
if (typeof localStorage == 'undefined') return
|
||||||
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item)
|
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item)
|
||||||
@@ -40,7 +42,7 @@ export interface Profile {
|
|||||||
id: number
|
id: number
|
||||||
instance: string
|
instance: string
|
||||||
jwt?: string
|
jwt?: string
|
||||||
user?: PersonData
|
user?: MyUserInfo
|
||||||
username?: string
|
username?: string
|
||||||
avatar?: string
|
avatar?: string
|
||||||
favorites?: Community[]
|
favorites?: Community[]
|
||||||
@@ -56,8 +58,6 @@ interface ProfileData {
|
|||||||
defaultInstance?: string
|
defaultInstance?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PersonData extends MyUserInfo {}
|
|
||||||
|
|
||||||
interface Notifications {
|
interface Notifications {
|
||||||
inbox: number
|
inbox: number
|
||||||
reports: number
|
reports: number
|
||||||
@@ -71,12 +71,12 @@ const getCookie = (key: string): string | undefined => {
|
|||||||
// ask chatgpt or something to explain this for you
|
// ask chatgpt or something to explain this for you
|
||||||
return document?.cookie
|
return document?.cookie
|
||||||
?.split(';')
|
?.split(';')
|
||||||
.map((c) => c.trim())
|
.map(c => c.trim())
|
||||||
.find((c) => c.split('=')?.[0] == key)
|
.find(c => c.split('=')?.[0] == key)
|
||||||
?.split('=')?.[1]
|
?.split('=')?.[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export let profileData = $state<ProfileData>(
|
export const profileData = $state<ProfileData>(
|
||||||
getFromStorage<ProfileData>('profileData') ?? {
|
getFromStorage<ProfileData>('profileData') ?? {
|
||||||
profiles: [
|
profiles: [
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ export let profileData = $state<ProfileData>(
|
|||||||
|
|
||||||
class CurrentProfile {
|
class CurrentProfile {
|
||||||
#data = $derived(
|
#data = $derived(
|
||||||
profileData.profiles.find((i) => i.id == profileData.profile) ??
|
profileData.profiles.find(i => i.id == profileData.profile) ??
|
||||||
getDefaultProfile(),
|
getDefaultProfile(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -101,12 +101,12 @@ class CurrentProfile {
|
|||||||
}
|
}
|
||||||
set data(value) {
|
set data(value) {
|
||||||
if (!value) return
|
if (!value) return
|
||||||
const index = profileData.profiles.findIndex((i) => i.id == value?.id)
|
const index = profileData.profiles.findIndex(i => i.id == value?.id)
|
||||||
profileData.profiles[index] = value
|
profileData.profiles[index] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let profile = new CurrentProfile()
|
export const profile = new CurrentProfile()
|
||||||
|
|
||||||
async function fetchUserData(profile: CurrentProfile) {
|
async function fetchUserData(profile: CurrentProfile) {
|
||||||
if (profile.data.jwt) {
|
if (profile.data.jwt) {
|
||||||
@@ -132,14 +132,14 @@ async function fetchUserData(profile: CurrentProfile) {
|
|||||||
site.data = undefined
|
site.data = undefined
|
||||||
client({ instanceURL: profile.data.instance })
|
client({ instanceURL: profile.data.instance })
|
||||||
.getSite()
|
.getSite()
|
||||||
.then((res) => (site.data = res))
|
.then(res => (site.data = res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
}
|
}
|
||||||
|
|
||||||
export let notifications = writable<Notifications>({
|
export const notifications = writable<Notifications>({
|
||||||
applications: 0,
|
applications: 0,
|
||||||
inbox: 0,
|
inbox: 0,
|
||||||
reports: 0,
|
reports: 0,
|
||||||
@@ -149,7 +149,7 @@ $effect.root(() => {
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
const serialized = {
|
const serialized = {
|
||||||
...profileData,
|
...profileData,
|
||||||
profiles: profileData.profiles.map((p) => serializeUser(p)),
|
profiles: profileData.profiles.map(p => serializeUser(p)),
|
||||||
}
|
}
|
||||||
|
|
||||||
setFromStorage('profileData', serialized)
|
setFromStorage('profileData', serialized)
|
||||||
@@ -167,7 +167,7 @@ $effect.root(() => {
|
|||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (profile.data.id || profileData)
|
if (profile.data.id || profileData)
|
||||||
fetchUserData(profile).then((res) => {
|
fetchUserData(profile).then(() => {
|
||||||
checkInbox()
|
checkInbox()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -180,15 +180,11 @@ if (
|
|||||||
) {
|
) {
|
||||||
const jwt = getCookie('jwt')
|
const jwt = getCookie('jwt')
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
new Promise(async () => {
|
;(async () => {
|
||||||
const user = await userFromJwt(jwt, env.PUBLIC_INSTANCE_URL ?? '')
|
const user = await userFromJwt(jwt, env.PUBLIC_INSTANCE_URL ?? '')
|
||||||
if (!user) return
|
if (!user) return
|
||||||
|
|
||||||
const result = await setUser(
|
const result = await setUser(jwt, env.PUBLIC_INSTANCE_URL ?? '')
|
||||||
jwt,
|
|
||||||
env.PUBLIC_INSTANCE_URL ?? '',
|
|
||||||
user?.user?.local_user_view.person.name,
|
|
||||||
)
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
toast({
|
toast({
|
||||||
@@ -196,21 +192,21 @@ if (
|
|||||||
'Your instance migrated to Photon, and you were logged in using a leftover cookie.',
|
'Your instance migrated to Photon, and you were logged in using a leftover cookie.',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
})
|
})()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setUser(jwt: string, inst: string, username?: string) {
|
export async function setUser(jwt: string, inst: string) {
|
||||||
try {
|
try {
|
||||||
new URL(instanceToURL(inst))
|
new URL(instanceToURL(inst))
|
||||||
} catch (err) {
|
} catch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await userFromJwt(jwt, inst)
|
const user = await userFromJwt(jwt, inst)
|
||||||
.then((u) => u)
|
.then(u => u)
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
toast({ content: err as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
})
|
})
|
||||||
if (!user?.user) {
|
if (!user?.user) {
|
||||||
toast({
|
toast({
|
||||||
@@ -219,7 +215,7 @@ export async function setUser(jwt: string, inst: string, username?: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = Math.max(...profileData.profiles.map((p) => p.id)) + 1
|
const id = Math.max(...profileData.profiles.map(p => p.id)) + 1
|
||||||
profileData.profile = id
|
profileData.profile = id
|
||||||
profileData.profiles.push({
|
profileData.profiles.push({
|
||||||
id: id,
|
id: id,
|
||||||
@@ -236,11 +232,11 @@ async function userFromJwt(
|
|||||||
jwt: string,
|
jwt: string,
|
||||||
instance: string,
|
instance: string,
|
||||||
): Promise<
|
): Promise<
|
||||||
{ user: PersonData | undefined; site: GetSiteResponse } | undefined
|
{ user: MyUserInfo | undefined; site: GetSiteResponse } | undefined
|
||||||
> {
|
> {
|
||||||
const sitePromise = client({ instanceURL: instance, auth: jwt }).getSite()
|
const sitePromise = client({ instanceURL: instance, auth: jwt }).getSite()
|
||||||
|
|
||||||
let timer = setTimeout(
|
const timer = setTimeout(
|
||||||
() =>
|
() =>
|
||||||
toast({
|
toast({
|
||||||
content: `Still loading your user data...`,
|
content: `Still loading your user data...`,
|
||||||
@@ -251,11 +247,11 @@ async function userFromJwt(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const site = await sitePromise
|
const site = await sitePromise
|
||||||
.then((r) => {
|
.then(r => {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
return r
|
return r
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(e => {
|
||||||
toast({ content: `Failed to contact the instance. ${e}` })
|
toast({ content: `Failed to contact the instance. ${e}` })
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -282,7 +278,7 @@ export function resetProfile() {
|
|||||||
|
|
||||||
export function deleteProfile(id: number) {
|
export function deleteProfile(id: number) {
|
||||||
profileData.profiles.splice(
|
profileData.profiles.splice(
|
||||||
profileData.profiles.findIndex((p) => p.id == id),
|
profileData.profiles.findIndex(p => p.id == id),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
if (id == profileData.profile) resetProfile()
|
if (id == profileData.profile) resetProfile()
|
||||||
@@ -296,48 +292,48 @@ function serializeUser(user: Profile): Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setUserID(id: number) {
|
export async function setUserID(id: number) {
|
||||||
if (!profileData.profiles.find((p) => p.id == id)) return -1
|
if (!profileData.profiles.find(p => p.id == id)) return -1
|
||||||
profileData.profile = id
|
profileData.profile = id
|
||||||
return profile
|
return profile
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveProfile(id: number, up: boolean) {
|
export function moveProfile(id: number, up: boolean) {
|
||||||
try {
|
try {
|
||||||
const index = profileData.profiles.findIndex((i) => i.id == id)
|
const index = profileData.profiles.findIndex(i => i.id == id)
|
||||||
profileData.profiles = moveItem(
|
profileData.profiles = moveItem(
|
||||||
profileData.profiles,
|
profileData.profiles,
|
||||||
index,
|
index,
|
||||||
index + (up ? -1 : 1),
|
index + (up ? -1 : 1),
|
||||||
)
|
)
|
||||||
} catch (err) {
|
} catch {
|
||||||
// we dont care
|
/* empty */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
|
async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
|
||||||
const unreadsPromise = getClient()
|
const unreadsPromise = getClient()
|
||||||
.getUnreadCount()
|
.getUnreadCount()
|
||||||
.then((res) => res.mentions + res.private_messages + res.replies)
|
.then(res => res.mentions + res.private_messages + res.replies)
|
||||||
.catch(() => 0)
|
.catch(() => 0)
|
||||||
|
|
||||||
const reportsPromise = mod
|
const reportsPromise = mod
|
||||||
? getClient()
|
? getClient()
|
||||||
.getReportCount({})
|
.getReportCount({})
|
||||||
.then(
|
.then(
|
||||||
(res) =>
|
res =>
|
||||||
res.comment_reports +
|
res.comment_reports +
|
||||||
res.post_reports +
|
res.post_reports +
|
||||||
(res.private_message_reports ?? 0),
|
(res.private_message_reports ?? 0),
|
||||||
)
|
)
|
||||||
.catch(() => 0)
|
.catch(() => 0)
|
||||||
: new Promise<number>((res) => res(0))
|
: new Promise<number>(res => res(0))
|
||||||
|
|
||||||
const applicationsPromise = admin
|
const applicationsPromise = admin
|
||||||
? getClient()
|
? getClient()
|
||||||
.getUnreadRegistrationApplicationCount()
|
.getUnreadRegistrationApplicationCount()
|
||||||
.then((res) => res.registration_applications)
|
.then(res => res.registration_applications)
|
||||||
.catch(() => 0)
|
.catch(() => 0)
|
||||||
: new Promise<number>((res) => res(0))
|
: new Promise<number>(res => res(0))
|
||||||
|
|
||||||
const [unreads, reports, applications] = await Promise.all([
|
const [unreads, reports, applications] = await Promise.all([
|
||||||
unreadsPromise,
|
unreadsPromise,
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
import { writable } from 'svelte/store'
|
|
||||||
|
|
||||||
interface PageScopedError {
|
interface PageScopedError {
|
||||||
scope: string
|
scope: string
|
||||||
message: string
|
message: string
|
||||||
@@ -13,16 +11,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function clearErrorScope(scope: string | null | undefined) {
|
export function clearErrorScope(scope: string | null | undefined) {
|
||||||
errors = errors.filter((error) => error.scope != scope)
|
errors = errors.filter(error => error.scope != scope)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { ExclamationCircle, Icon, XCircle, XMark } from 'svelte-hero-icons'
|
|
||||||
import { fly, slide } from 'svelte/transition'
|
|
||||||
import { expoOut } from 'svelte/easing'
|
|
||||||
import { onDestroy } from 'svelte'
|
import { onDestroy } from 'svelte'
|
||||||
|
import { Icon, XMark } from 'svelte-hero-icons'
|
||||||
|
import { expoOut } from 'svelte/easing'
|
||||||
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
clearErrorScope(scope)
|
clearErrorScope(scope)
|
||||||
@@ -35,7 +33,7 @@
|
|||||||
let { scope = undefined, class: clazz = '' }: Props = $props()
|
let { scope = undefined, class: clazz = '' }: Props = $props()
|
||||||
|
|
||||||
let scopedErrors = $derived(
|
let scopedErrors = $derived(
|
||||||
errors.filter((e) => e.scope == scope || e.scope == 'global'),
|
errors.filter(e => e.scope == scope || e.scope == 'global'),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { TextInput, Select, Option } from 'mono-svelte'
|
import { TextInput, Select, Option } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
|
||||||
|
|
||||||
const multipliers = {
|
const multipliers = {
|
||||||
minute: 60,
|
minute: 60,
|
||||||
@@ -22,17 +21,9 @@
|
|||||||
value: number
|
value: number
|
||||||
max?: number
|
max?: number
|
||||||
min?: number
|
min?: number
|
||||||
number?: Snippet<[number]>
|
|
||||||
duration?: Snippet<[Duration]>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let { value = $bindable(), max, min = 0 }: Props = $props()
|
||||||
value = $bindable(),
|
|
||||||
max,
|
|
||||||
min = 0,
|
|
||||||
number: numberSnippet,
|
|
||||||
duration: durationSnippet,
|
|
||||||
}: Props = $props()
|
|
||||||
|
|
||||||
let number = $state<number>(0)
|
let number = $state<number>(0)
|
||||||
let duration = $state<Duration>(value == -1 ? 'permanent' : 'day')
|
let duration = $state<Duration>(value == -1 ? 'permanent' : 'day')
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { browser } from '$app/environment'
|
|
||||||
import { tick } from 'svelte'
|
import { tick } from 'svelte'
|
||||||
|
import type { HTMLTextareaAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
let textarea: HTMLTextAreaElement | undefined = $state()
|
let textarea: HTMLTextAreaElement | undefined = $state()
|
||||||
|
|
||||||
async function adjustHeight(value: string) {
|
async function adjustHeight() {
|
||||||
await tick()
|
await tick()
|
||||||
if (textarea) {
|
if (textarea) {
|
||||||
textarea.style.height = 'auto' // Reset height to auto to calculate new height
|
textarea.style.height = 'auto' // Reset height to auto to calculate new height
|
||||||
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
|
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interface Props {
|
interface Props extends HTMLTextareaAttributes {
|
||||||
label?: string | undefined
|
label?: string | undefined
|
||||||
value: string
|
value: string
|
||||||
required?: boolean
|
required?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -29,8 +26,8 @@
|
|||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
run(() => {
|
$effect(() => {
|
||||||
adjustHeight(value)
|
if (value) adjustHeight()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -45,7 +42,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
bind:this={textarea}
|
bind:this={textarea}
|
||||||
oninput={() => adjustHeight(value)}
|
oninput={() => adjustHeight()}
|
||||||
bind:value
|
bind:value
|
||||||
{required}
|
{required}
|
||||||
{...rest}
|
{...rest}
|
||||||
|
|||||||
@@ -2,21 +2,22 @@
|
|||||||
export const parseURL = (href: string) => {
|
export const parseURL = (href: string) => {
|
||||||
try {
|
try {
|
||||||
return new URL(href)
|
return new URL(href)
|
||||||
} catch (e) {
|
} catch {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
import type { HTMLAnchorAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
|
interface Props extends HTMLAnchorAttributes {
|
||||||
href: string
|
href: string
|
||||||
highlight?: boolean
|
highlight?: boolean
|
||||||
nowrap?: boolean
|
nowrap?: boolean
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
class?: string
|
class?: string
|
||||||
icon?: import('svelte').Snippet
|
icon?: import('svelte').Snippet
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
type T = $$Generic
|
type T = $$Generic
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -8,10 +6,7 @@
|
|||||||
disabled?: boolean[]
|
disabled?: boolean[]
|
||||||
optionNames?: string[]
|
optionNames?: string[]
|
||||||
selected: T
|
selected: T
|
||||||
headless?: boolean
|
children?: import('svelte').Snippet<[{ selected: T }]>
|
||||||
class?: string
|
|
||||||
buttonClazz?: string
|
|
||||||
children?: import('svelte').Snippet<[any]>
|
|
||||||
onselect?: (item: T) => void
|
onselect?: (item: T) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,9 +15,6 @@
|
|||||||
disabled = [],
|
disabled = [],
|
||||||
optionNames = [],
|
optionNames = [],
|
||||||
selected = $bindable(),
|
selected = $bindable(),
|
||||||
headless = false,
|
|
||||||
class: clazz = '',
|
|
||||||
buttonClazz = '',
|
|
||||||
children,
|
children,
|
||||||
onselect,
|
onselect,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
@@ -30,38 +22,6 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
onselect?.(selected)
|
onselect?.(selected)
|
||||||
})
|
})
|
||||||
|
|
||||||
let containerClass = `
|
|
||||||
flex flex-row rtl:flex-row-reverse items-center w-max max-w-full overflow-auto
|
|
||||||
${headless ? 'pb-1 gap-1' : ''}
|
|
||||||
${clazz}
|
|
||||||
`
|
|
||||||
|
|
||||||
const buttonClass = (selected: boolean) => `
|
|
||||||
first:rounded-l-lg first:border-l dark:first:border-l-transparent
|
|
||||||
last:rounded-r-lg last:border-r dark:last:border-r-transparent
|
|
||||||
rounded-l-none
|
|
||||||
rounded-r-none
|
|
||||||
px-3 py-1.5 text-sm hover:brightness-110 ${buttonClazz || ''}
|
|
||||||
${
|
|
||||||
!selected
|
|
||||||
? `dark:hover:bg-zinc-800 border-slate-100 border-t border-b border-b-slate-300 dark:border-b-0
|
|
||||||
dark:border-t dark:border-t-zinc-700`
|
|
||||||
: ''
|
|
||||||
}
|
|
||||||
transition-all transition-filters rounded-full
|
|
||||||
${
|
|
||||||
selected
|
|
||||||
? headless
|
|
||||||
? ''
|
|
||||||
: `bg-primary-900 dark:bg-primary-100 text-slate-50 dark:text-zinc-900`
|
|
||||||
: headless
|
|
||||||
? ''
|
|
||||||
: 'bg-white dark:bg-zinc-800'
|
|
||||||
}
|
|
||||||
disabled:opacity-60 disabled:pointer-events-none whitespace-nowrap
|
|
||||||
relative
|
|
||||||
`
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -76,7 +36,7 @@
|
|||||||
? 'bg-primary-900 dark:bg-primary-100 text-slate-50 dark:text-zinc-900'
|
? 'bg-primary-900 dark:bg-primary-100 text-slate-50 dark:text-zinc-900'
|
||||||
: 'dark:bg-zinc-900/50 bg-white',
|
: 'dark:bg-zinc-900/50 bg-white',
|
||||||
]}
|
]}
|
||||||
onclick={(e) => {
|
onclick={e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
selected = option
|
selected = option
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import type { Community, CommunityView, ListingType } from 'lemmy-js-client'
|
import type { Community, ListingType } from 'lemmy-js-client'
|
||||||
import { MenuButton, Search } from 'mono-svelte'
|
import { MenuButton, Search } from 'mono-svelte'
|
||||||
import type { SearchProps } from 'mono-svelte/search/Search.svelte'
|
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { Icon, XCircle, ServerStack } from 'svelte-hero-icons'
|
import { Icon, ServerStack, XCircle } from 'svelte-hero-icons'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -14,8 +13,8 @@
|
|||||||
instance?: string | undefined
|
instance?: string | undefined
|
||||||
listing_type?: ListingType
|
listing_type?: ListingType
|
||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
|
// eslint-disable-next-line
|
||||||
onselect?: (item: any) => void
|
onselect?: (item: any) => void
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -35,7 +34,7 @@
|
|||||||
|
|
||||||
{#if type == 'community'}
|
{#if type == 'community'}
|
||||||
<Search
|
<Search
|
||||||
search={async (q) => {
|
search={async q => {
|
||||||
const results = await getClient(instance).search({
|
const results = await getClient(instance).search({
|
||||||
q: q || ' ',
|
q: q || ' ',
|
||||||
type_: 'Communities',
|
type_: 'Communities',
|
||||||
@@ -44,9 +43,9 @@
|
|||||||
sort: 'TopAll',
|
sort: 'TopAll',
|
||||||
})
|
})
|
||||||
|
|
||||||
return results.communities.map((c) => c.community)
|
return results.communities.map(c => c.community)
|
||||||
}}
|
}}
|
||||||
extractName={(c) => `${c.title}@${new URL(c.actor_id).hostname}`}
|
extractName={c => `${c.title}@${new URL(c.actor_id).hostname}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
@@ -80,16 +79,16 @@
|
|||||||
</Search>
|
</Search>
|
||||||
{:else if type == 'instance'}
|
{:else if type == 'instance'}
|
||||||
<Search
|
<Search
|
||||||
search={async (q) => {
|
search={async q => {
|
||||||
const results = (await instances) || {}
|
const results = (await instances) || {}
|
||||||
|
|
||||||
return q
|
return q
|
||||||
? (results.federated_instances?.linked || []).filter(
|
? (results.federated_instances?.linked || []).filter(
|
||||||
(i) => i.software === 'lemmy' && i.domain.includes(q),
|
i => i.software === 'lemmy' && i.domain.includes(q),
|
||||||
)
|
)
|
||||||
: []
|
: []
|
||||||
}}
|
}}
|
||||||
extractName={(i) => `${i.domain}`}
|
extractName={i => `${i.domain}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,27 +2,18 @@
|
|||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { PersonView, SiteView, Tagline } from 'lemmy-js-client'
|
import type { PersonView, SiteView, Tagline } from 'lemmy-js-client'
|
||||||
import { Badge, Button } from 'mono-svelte'
|
import { Badge } from 'mono-svelte'
|
||||||
import {
|
import { Icon, ServerStack } from 'svelte-hero-icons'
|
||||||
BuildingOffice,
|
import Link from '../input/Link.svelte'
|
||||||
ChartBar,
|
import Entity from '../ui/Entity.svelte'
|
||||||
Icon,
|
|
||||||
InformationCircle,
|
|
||||||
Newspaper,
|
|
||||||
ServerStack,
|
|
||||||
UserGroup,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import Expandable from '../ui/Expandable.svelte'
|
import Expandable from '../ui/Expandable.svelte'
|
||||||
import LabelStat from '../ui/LabelStat.svelte'
|
import LabelStat from '../ui/LabelStat.svelte'
|
||||||
import ItemList from './generic/ItemList.svelte'
|
import ItemList from './generic/ItemList.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import Entity from '../ui/Entity.svelte'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { optimizeImageURL } from './post/helpers'
|
import { optimizeImageURL } from './post/helpers'
|
||||||
import Link from '../input/Link.svelte'
|
|
||||||
import EndPlaceholder from '../ui/EndPlaceholder.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
site: SiteView
|
site: SiteView
|
||||||
@@ -130,7 +121,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={admins.map((a) => ({
|
items={admins.map(a => ({
|
||||||
id: a.person.id,
|
id: a.person.id,
|
||||||
name: a.person.name,
|
name: a.person.name,
|
||||||
url: userLink(a.person),
|
url: userLink(a.person),
|
||||||
|
|||||||
@@ -1,4 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
|
||||||
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
Icon,
|
Icon,
|
||||||
@@ -8,25 +20,13 @@
|
|||||||
Plus,
|
Plus,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import type { CommentNodeI } from './comments.svelte'
|
import { expoOut } from 'svelte/easing'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
|
||||||
import CommentForm from './CommentForm.svelte'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
|
||||||
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
|
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
|
||||||
import { Disclosure, toast } from 'mono-svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import { Button, Modal } from 'mono-svelte'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
|
||||||
import { page } from '$app/state'
|
|
||||||
import { onMount } from 'svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { fly, slide } from 'svelte/transition'
|
|
||||||
import { expoInOut, expoOut } from 'svelte/easing'
|
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||||
|
import CommentForm from './CommentForm.svelte'
|
||||||
|
import type { CommentNodeI } from './comments.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
node: CommentNodeI
|
node: CommentNodeI
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
editing = false
|
editing = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err as string),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
<span>{$t('form.edit')}</span>
|
<span>{$t('form.edit')}</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<form
|
<form
|
||||||
onsubmit={(e) => {
|
onsubmit={e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
save()
|
save()
|
||||||
}}
|
}}
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
label={$t('comment.reply')}
|
label={$t('comment.reply')}
|
||||||
{postId}
|
{postId}
|
||||||
parentId={node.comment_view.comment.id}
|
parentId={node.comment_view.comment.id}
|
||||||
oncomment={(e) => {
|
oncomment={e => {
|
||||||
node.children = [
|
node.children = [
|
||||||
{
|
{
|
||||||
children: [],
|
children: [],
|
||||||
|
|||||||
@@ -1,32 +1,28 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { CommentView } from 'lemmy-js-client'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
||||||
|
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||||
|
import {
|
||||||
|
amMod,
|
||||||
|
isAdmin,
|
||||||
|
report,
|
||||||
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
|
import type { CommentView } from 'lemmy-js-client'
|
||||||
|
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ArrowUturnLeft,
|
|
||||||
Bookmark,
|
Bookmark,
|
||||||
BookmarkSlash,
|
BookmarkSlash,
|
||||||
ChatBubbleOvalLeft,
|
ChatBubbleOvalLeft,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Flag,
|
Flag,
|
||||||
Icon,
|
Icon,
|
||||||
Language,
|
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
Square2Stack,
|
Square2Stack,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
import { isCommentMutable } from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import {
|
|
||||||
amMod,
|
|
||||||
isAdmin,
|
|
||||||
report,
|
|
||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
|
||||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
|
||||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
comment: CommentView
|
comment: CommentView
|
||||||
@@ -84,9 +80,11 @@
|
|||||||
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
navigator.share?.({
|
if (navigator.share)
|
||||||
url: comment.comment.ap_id,
|
navigator.share?.({
|
||||||
}) ?? navigator.clipboard.writeText(comment.comment.ap_id)
|
url: comment.comment.ap_id,
|
||||||
|
})
|
||||||
|
else navigator.clipboard.writeText(comment.comment.ap_id)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={Square2Stack} mini size="16" />
|
<Icon src={Square2Stack} mini size="16" />
|
||||||
@@ -102,11 +100,7 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (profile.data?.jwt)
|
if (profile.data?.jwt)
|
||||||
comment.saved = await save(
|
comment.saved = await save(comment, !comment.saved)
|
||||||
comment,
|
|
||||||
!comment.saved,
|
|
||||||
profile.data.jwt,
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
||||||
@@ -122,7 +116,6 @@
|
|||||||
comment.comment.deleted = await deleteItem(
|
comment.comment.deleted = await deleteItem(
|
||||||
comment,
|
comment,
|
||||||
!comment.comment.deleted,
|
!comment.comment.deleted,
|
||||||
profile.data.jwt,
|
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { CommentResponse } from 'lemmy-js-client'
|
|
||||||
import { getClient, site } from '$lib/lemmy.svelte.js'
|
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { Menu, Select, Spinner, toast, Option, MenuButton } from 'mono-svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { placeholders } from '$lib/util.svelte.js'
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getClient, site } from '$lib/lemmy.svelte.js'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import { placeholders } from '$lib/util.svelte.js'
|
||||||
|
import type { CommentResponse } from 'lemmy-js-client'
|
||||||
|
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
||||||
import { ArrowUp, Icon, Language, XMark } from 'svelte-hero-icons'
|
import { ArrowUp, Icon, Language, XMark } from 'svelte-hero-icons'
|
||||||
|
import type { ClassValue, HTMLTextareaAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
interface Props {
|
interface Props extends Omit<HTMLTextareaAttributes, 'oncancel'> {
|
||||||
postId: number
|
postId: number
|
||||||
parentId?: number | undefined
|
parentId?: number | undefined
|
||||||
locked?: boolean
|
locked?: boolean
|
||||||
@@ -22,10 +21,13 @@
|
|||||||
value?: string
|
value?: string
|
||||||
actions?: boolean
|
actions?: boolean
|
||||||
preview?: boolean
|
preview?: boolean
|
||||||
|
class?: ClassValue
|
||||||
|
required?: boolean
|
||||||
|
id?: string
|
||||||
|
label?: string
|
||||||
oncomment?: (comment: CommentResponse) => void
|
oncomment?: (comment: CommentResponse) => void
|
||||||
onconfirm?: (value: string) => void
|
onconfirm?: (value: string) => void
|
||||||
oncancel?: (cancel: boolean) => void
|
oncancel?: (cancel: boolean) => void
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -40,7 +42,6 @@
|
|||||||
preview: previewAction = true,
|
preview: previewAction = true,
|
||||||
oncancel,
|
oncancel,
|
||||||
oncomment,
|
oncomment,
|
||||||
onconfirm,
|
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
toast({
|
toast({
|
||||||
content: errorMessage(err as any),
|
content: errorMessage(err as string),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -93,12 +94,6 @@
|
|||||||
: (placeholder ?? placeholders.get('comment'))}
|
: (placeholder ?? placeholders.get('comment'))}
|
||||||
bind:value
|
bind:value
|
||||||
disabled={locked || loading || banned}
|
disabled={locked || loading || banned}
|
||||||
onconfirm={() => {
|
|
||||||
if (actions) {
|
|
||||||
submit()
|
|
||||||
onconfirm?.(value)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
previewButton={previewAction}
|
previewButton={previewAction}
|
||||||
>
|
>
|
||||||
<Menu>
|
<Menu>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import type { CommentView } from 'lemmy-js-client'
|
import type { CommentView } from 'lemmy-js-client'
|
||||||
import { Button, Material } from 'mono-svelte'
|
import { Button, Material } from 'mono-svelte'
|
||||||
@@ -10,12 +10,11 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
comment: CommentView
|
comment: CommentView
|
||||||
view?: any
|
view?: View
|
||||||
community?: boolean
|
community?: boolean
|
||||||
meta?: boolean
|
meta?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
commentClass?: string
|
commentClass?: string
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
import type { CommentNodeI } from './comments.svelte'
|
import type { CommentNodeI } from './comments.svelte'
|
||||||
import Comments from './Comments.svelte'
|
import Comments from './Comments.svelte'
|
||||||
import { onMount, tick } from 'svelte'
|
|
||||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
|
||||||
import { page } from '$app/state'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
nodes: CommentNodeI[]
|
nodes: CommentNodeI[]
|
||||||
@@ -35,7 +34,7 @@
|
|||||||
|
|
||||||
// IntersectionObserver to watch for shifts
|
// IntersectionObserver to watch for shifts
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
entries => {
|
||||||
entries.forEach(updateOffset)
|
entries.forEach(updateOffset)
|
||||||
},
|
},
|
||||||
{ threshold: [0, 1] },
|
{ threshold: [0, 1] },
|
||||||
@@ -59,11 +58,11 @@
|
|||||||
{initialOffset}
|
{initialOffset}
|
||||||
bind:this={list}
|
bind:this={list}
|
||||||
>
|
>
|
||||||
{#snippet item(item, index)}
|
{#snippet item(index)}
|
||||||
<div class="-mx-4 sm:-mx-6 px-4 sm:px-6">
|
<div class="-mx-4 sm:-mx-6 px-4 sm:px-6">
|
||||||
<Comments
|
<Comments
|
||||||
isParent={true}
|
isParent={true}
|
||||||
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
bind:nodes={() => [nodes[index]], v => (nodes[index] = v[0])}
|
||||||
{post}
|
{post}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
|
||||||
ArrowDownCircle,
|
|
||||||
ArrowUp,
|
|
||||||
ArrowUpCircle,
|
|
||||||
ChevronDown,
|
|
||||||
ChevronUp,
|
|
||||||
Icon,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import { getClient, site } from '$lib/lemmy.svelte'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import { Button, buttonColor, toast } from 'mono-svelte'
|
|
||||||
import { vote as voteItem } from '$lib/lemmy/contentview'
|
|
||||||
import { shouldShowVoteColor } from '../post/PostVote.svelte'
|
|
||||||
import { fly } from 'svelte/transition'
|
|
||||||
import { backOut } from 'svelte/easing'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getClient } from '$lib/lemmy.svelte'
|
||||||
|
import { buttonColor, toast } from 'mono-svelte'
|
||||||
|
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||||
|
import { backOut } from 'svelte/easing'
|
||||||
|
import { fly } from 'svelte/transition'
|
||||||
|
import { shouldShowVoteColor } from '../post/PostVote.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
vote?: number
|
vote?: number
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Comments from './Comments.svelte'
|
|
||||||
import Comment from './Comment.svelte'
|
|
||||||
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
|
||||||
import { page } from '$app/state'
|
|
||||||
import { onMount, setContext } from 'svelte'
|
|
||||||
import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
|
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
|
||||||
import type { CommentView, Post } from 'lemmy-js-client'
|
|
||||||
import { fly } from 'svelte/transition'
|
|
||||||
import { toast } from 'mono-svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import { afterNavigate, goto } from '$app/navigation'
|
|
||||||
import { backOut, expoOut } from 'svelte/easing'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { Button, toast } from 'mono-svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
import { ArrowDownCircle, Icon } from 'svelte-hero-icons'
|
||||||
|
import { expoOut } from 'svelte/easing'
|
||||||
|
import { fly } from 'svelte/transition'
|
||||||
|
import Comment from './Comment.svelte'
|
||||||
|
import Comments from './Comments.svelte'
|
||||||
|
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
nodes: CommentNodeI[]
|
nodes: CommentNodeI[]
|
||||||
@@ -36,7 +35,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let loadingChildren = false
|
|
||||||
let childrenPage = 0
|
let childrenPage = 0
|
||||||
|
|
||||||
async function fetchChildren(parent: CommentNodeI) {
|
async function fetchChildren(parent: CommentNodeI) {
|
||||||
@@ -60,7 +58,6 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (newComments.comments.length == 0) {
|
if (newComments.comments.length == 0) {
|
||||||
loadingChildren = false
|
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.noComments'),
|
content: $t('toast.noComments'),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@@ -96,10 +93,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
childrenPage++
|
childrenPage++
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error(error)
|
console.error(err)
|
||||||
toast({
|
toast({
|
||||||
content: error as any,
|
content: errorMessage(err as string),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -162,7 +159,6 @@
|
|||||||
/>
|
/>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('comment.more', {
|
{$t('comment.more', {
|
||||||
// @ts-ignore
|
|
||||||
comments: node.comment_view.counts.child_count,
|
comments: node.comment_view.counts.child_count,
|
||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function getDepthFromComment(comment?: Comment): number | undefined {
|
|||||||
export function buildCommentsTree(
|
export function buildCommentsTree(
|
||||||
comments: CommentView[],
|
comments: CommentView[],
|
||||||
baseDepth: number = 0,
|
baseDepth: number = 0,
|
||||||
filter: (c: CommentView) => boolean = (c) => true,
|
filter: (c: CommentView) => boolean = () => true,
|
||||||
): CommentNodeI[] {
|
): CommentNodeI[] {
|
||||||
const map = new Map<number, CommentNodeI>()
|
const map = new Map<number, CommentNodeI>()
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
return block
|
return block
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
toast({ content: error as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
return !block
|
return !block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
})
|
})
|
||||||
removeToast(purgeToast)
|
removeToast(purgeToast)
|
||||||
toast({ content: t.get('toast.purgedCommunity'), type: 'success' })
|
toast({ content: t.get('toast.purgedCommunity'), type: 'success' })
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
toast({ content: e as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@
|
|||||||
content: `Successfully blocked that instance.`,
|
content: `Successfully blocked that instance.`,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
toast({ content: error as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -73,43 +73,39 @@
|
|||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import Entity from '$lib/components/ui/Entity.svelte'
|
||||||
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
import {
|
import { t } from '$lib/i18n/translations'
|
||||||
Menu,
|
|
||||||
MenuButton,
|
|
||||||
Modal,
|
|
||||||
removeToast,
|
|
||||||
toast,
|
|
||||||
modal,
|
|
||||||
action,
|
|
||||||
} from 'mono-svelte'
|
|
||||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
|
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
|
||||||
import { Button } from 'mono-svelte'
|
import {
|
||||||
|
action,
|
||||||
|
Button,
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
modal,
|
||||||
|
removeToast,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
BuildingOffice2,
|
BuildingOffice2,
|
||||||
Calendar,
|
|
||||||
ChartBar,
|
|
||||||
Check,
|
Check,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Fire,
|
Fire,
|
||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
|
||||||
Newspaper,
|
Newspaper,
|
||||||
NoSymbol,
|
NoSymbol,
|
||||||
Plus,
|
Plus,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
|
||||||
import ItemList from '../generic/ItemList.svelte'
|
import ItemList from '../generic/ItemList.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import Entity from '$lib/components/ui/Entity.svelte'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
|
|
||||||
let loading = $state({
|
let loading = $state({
|
||||||
blocking: false,
|
blocking: false,
|
||||||
@@ -128,8 +124,8 @@
|
|||||||
community_id: community_view.community.id,
|
community_id: community_view.community.id,
|
||||||
follow: !subscribed,
|
follow: !subscribed,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
toast({ content: error as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
}
|
}
|
||||||
|
|
||||||
community_view.subscribed = subscribed ? 'NotSubscribed' : 'Subscribed'
|
community_view.subscribed = subscribed ? 'NotSubscribed' : 'Subscribed'
|
||||||
@@ -219,7 +215,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={moderators.map((m) => ({
|
items={moderators.map(m => ({
|
||||||
id: m.moderator.id,
|
id: m.moderator.id,
|
||||||
name: m.moderator.name,
|
name: m.moderator.name,
|
||||||
url: userLink(m.moderator),
|
url: userLink(m.moderator),
|
||||||
|
|||||||
@@ -4,22 +4,27 @@
|
|||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { Badge, ImageInput, MenuButton, Switch, toast } from 'mono-svelte'
|
|
||||||
import { client, getClient, site } from '$lib/lemmy.svelte.js'
|
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
|
||||||
import { Button, Checkbox, TextInput } from 'mono-svelte'
|
|
||||||
import { uploadImage } from '$lib/util.svelte.js'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import ImagePreviewInput from '$lib/components/input/ImagePreviewInput.svelte'
|
|
||||||
import Label from 'mono-svelte/forms/Label.svelte'
|
|
||||||
import { DocumentPlus, GlobeAlt, Icon, MapPin, Plus } from 'svelte-hero-icons'
|
|
||||||
import ImageUploadModal from '../modal/ImageUploadModal.svelte'
|
|
||||||
import Select from 'mono-svelte/forms/select/Select.svelte'
|
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getClient, site } from '$lib/lemmy.svelte.js'
|
||||||
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Button,
|
||||||
|
MenuButton,
|
||||||
|
Switch,
|
||||||
|
TextInput,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
|
import Label from 'mono-svelte/forms/Label.svelte'
|
||||||
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import Select from 'mono-svelte/forms/select/Select.svelte'
|
||||||
import Material from 'mono-svelte/materials/Material.svelte'
|
import Material from 'mono-svelte/materials/Material.svelte'
|
||||||
import Menu from 'mono-svelte/popover/Menu.svelte'
|
import Menu from 'mono-svelte/popover/Menu.svelte'
|
||||||
|
import { DocumentPlus, GlobeAlt, Icon, MapPin, Plus } from 'svelte-hero-icons'
|
||||||
|
import ImageUploadModal from '../modal/ImageUploadModal.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +101,7 @@
|
|||||||
|
|
||||||
if (profile.data.user) {
|
if (profile.data.user) {
|
||||||
const c = profile.data.user.moderates
|
const c = profile.data.user.moderates
|
||||||
.map((m) => m.community.id)
|
.map(m => m.community.id)
|
||||||
.indexOf(res.community_view.community.id)
|
.indexOf(res.community_view.community.id)
|
||||||
if (c != -1) {
|
if (c != -1) {
|
||||||
profile.data.user.moderates[c] = {
|
profile.data.user.moderates[c] = {
|
||||||
@@ -127,7 +132,7 @@
|
|||||||
)
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err as string),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -184,7 +189,7 @@
|
|||||||
<ImageUploadModal
|
<ImageUploadModal
|
||||||
bind:open={uploading.icon}
|
bind:open={uploading.icon}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onupload={(uploaded) => {
|
onupload={uploaded => {
|
||||||
uploading.icon = false
|
uploading.icon = false
|
||||||
formData.icon = uploaded[0]
|
formData.icon = uploaded[0]
|
||||||
}}
|
}}
|
||||||
@@ -212,7 +217,7 @@
|
|||||||
<ImageUploadModal
|
<ImageUploadModal
|
||||||
bind:open={uploading.banner}
|
bind:open={uploading.banner}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onupload={(uploaded) => {
|
onupload={uploaded => {
|
||||||
uploading.banner = false
|
uploading.banner = false
|
||||||
formData.banner = uploaded[0]
|
formData.banner = uploaded[0]
|
||||||
}}
|
}}
|
||||||
@@ -249,7 +254,7 @@
|
|||||||
</Badge>
|
</Badge>
|
||||||
</button>
|
</button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#each site.data.all_languages.filter((l) => !formData.languages?.includes(l.id)) as language, index}
|
{#each site.data.all_languages.filter(l => !formData.languages?.includes(l.id)) as language (language.id)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
class="min-h-[16px] py-0"
|
class="min-h-[16px] py-0"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
@@ -263,9 +268,9 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/each}
|
{/each}
|
||||||
</Menu>
|
</Menu>
|
||||||
{#each formData.languages ?? [] as languageId, index}
|
{#each formData.languages ?? [] as languageId, index (languageId)}
|
||||||
{@const language = site.data.all_languages.find(
|
{@const language = site.data.all_languages.find(
|
||||||
(l) => l.id == languageId,
|
l => l.id == languageId,
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||||
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte'
|
import { fullCommunityName } from '$lib/util.svelte'
|
||||||
import type {
|
import type {
|
||||||
Community,
|
Community,
|
||||||
@@ -9,28 +14,22 @@
|
|||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
SubscribedType,
|
SubscribedType,
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
import { Button, toast, Menu, MenuButton, modal, action } from 'mono-svelte'
|
import { action, Button, Menu, MenuButton, modal, toast } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
|
BuildingOffice2,
|
||||||
Check,
|
Check,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
Icon,
|
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Plus,
|
|
||||||
Newspaper,
|
|
||||||
BuildingOffice2,
|
|
||||||
Fire,
|
Fire,
|
||||||
|
Icon,
|
||||||
|
Newspaper,
|
||||||
NoSymbol,
|
NoSymbol,
|
||||||
|
Plus,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
|
||||||
import ItemList from '../generic/ItemList.svelte'
|
import ItemList from '../generic/ItemList.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
|
||||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
|
||||||
import { isAdmin } from '../moderation/moderation'
|
import { isAdmin } from '../moderation/moderation'
|
||||||
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community: Community
|
community: Community
|
||||||
@@ -102,7 +101,7 @@
|
|||||||
<hr class="flex-1 border-slate-200 dark:border-zinc-800 mx-3" />
|
<hr class="flex-1 border-slate-200 dark:border-zinc-800 mx-3" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={moderators.map((m) => ({
|
items={moderators.map(m => ({
|
||||||
id: m.moderator.id,
|
id: m.moderator.id,
|
||||||
name: m.moderator.name,
|
name: m.moderator.name,
|
||||||
url: userLink(m.moderator),
|
url: userLink(m.moderator),
|
||||||
@@ -119,8 +118,7 @@
|
|||||||
community: community,
|
community: community,
|
||||||
banned_from_community: false,
|
banned_from_community: false,
|
||||||
blocked: false,
|
blocked: false,
|
||||||
// @ts-ignore
|
counts: counts!,
|
||||||
counts: counts ?? {},
|
|
||||||
subscribed: subscribed,
|
subscribed: subscribed,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -153,7 +151,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if profile.data?.user && profile.data.user.moderates
|
{#if profile.data?.user && profile.data.user.moderates
|
||||||
.map((c) => c.community.id)
|
.map(c => c.community.id)
|
||||||
.includes(community.id)}
|
.includes(community.id)}
|
||||||
<Button
|
<Button
|
||||||
size="square-lg"
|
size="square-lg"
|
||||||
|
|||||||
@@ -1,29 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
|
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
||||||
import type { CommunityView } from 'lemmy-js-client'
|
import type { CommunityView } from 'lemmy-js-client'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import { Button, Modal } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
Check,
|
Check,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
InformationCircle,
|
||||||
MapPin,
|
MapPin,
|
||||||
NoSymbol,
|
NoSymbol,
|
||||||
PencilSquare,
|
|
||||||
Plus,
|
Plus,
|
||||||
Trash,
|
Trash,
|
||||||
UserGroup,
|
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
|
||||||
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
|
|
||||||
let showInfo = $state(false)
|
let showInfo = $state(false)
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
avatarSize?: number
|
avatarSize?: number
|
||||||
showInstance?: boolean
|
showInstance?: boolean
|
||||||
displayName?: boolean
|
displayName?: boolean
|
||||||
badges?: any
|
badges?: {
|
||||||
|
nsfw: boolean
|
||||||
|
}
|
||||||
class?: string
|
class?: string
|
||||||
instanceClass?: string
|
instanceClass?: string
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -13,19 +13,18 @@
|
|||||||
import { amModOfAny } from '../moderation/moderation'
|
import { amModOfAny } from '../moderation/moderation'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import type { SelectProps } from 'mono-svelte/forms/select/Select.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props extends SelectProps<string> {
|
||||||
selected: string
|
selected: string
|
||||||
navigate?: boolean
|
navigate?: boolean
|
||||||
changeDefault?: boolean
|
changeDefault?: boolean
|
||||||
showLabel?: boolean
|
showLabel?: boolean
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
selected = $bindable(),
|
selected = $bindable(),
|
||||||
navigate = true,
|
navigate = true,
|
||||||
changeDefault = false,
|
|
||||||
showLabel = true,
|
showLabel = true,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { searchParam } from '$lib/util.svelte.js'
|
import { searchParam } from '$lib/util.svelte.js'
|
||||||
import { Select } from 'mono-svelte'
|
import { Select } from 'mono-svelte'
|
||||||
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import type { SelectProps } from 'mono-svelte/forms/select/Select.svelte'
|
||||||
import {
|
import {
|
||||||
ArrowTrendingDown,
|
ArrowTrendingDown,
|
||||||
ArrowTrendingUp,
|
ArrowTrendingUp,
|
||||||
@@ -21,21 +23,18 @@
|
|||||||
Trophy,
|
Trophy,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props extends SelectProps<string> {
|
||||||
selected: string
|
selected: string
|
||||||
navigate?: boolean
|
navigate?: boolean
|
||||||
changeDefault?: boolean
|
changeDefault?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
selected = $bindable(),
|
selected = $bindable(),
|
||||||
navigate = true,
|
navigate = true,
|
||||||
changeDefault = false,
|
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|||||||
@@ -1,22 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { Select } from 'mono-svelte'
|
import { Select } from 'mono-svelte'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
import {
|
import { Bars3, Icon, RectangleGroup, ViewColumns } from 'svelte-hero-icons'
|
||||||
Bars3,
|
|
||||||
Clock,
|
|
||||||
Icon,
|
|
||||||
ListBullet,
|
|
||||||
QueueList,
|
|
||||||
RectangleGroup,
|
|
||||||
Square2Stack,
|
|
||||||
ViewColumns,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
showLabel?: boolean
|
showLabel?: boolean
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { showLabel = true, ...rest }: Props = $props()
|
let { showLabel = true, ...rest }: Props = $props()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { flip } from 'svelte/animate'
|
import { flip } from 'svelte/animate'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { uploadImage } from '$lib/util.svelte.js'
|
import { uploadImage } from '$lib/util.svelte.js'
|
||||||
import { ImageInput, Spinner, toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
import { Button, Modal } from 'mono-svelte'
|
||||||
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
@@ -39,19 +39,19 @@
|
|||||||
try {
|
try {
|
||||||
const uploaded = (
|
const uploaded = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Array.from(image).map((i) =>
|
Array.from(image).map(i =>
|
||||||
uploadImage(i, profile.data.instance, profile.data.jwt!)
|
uploadImage(i, profile.data.instance, profile.data.jwt!)
|
||||||
.then((uploaded) => {
|
.then(uploaded => {
|
||||||
progress += 1 / (image?.length ?? 0)
|
progress += 1 / (image?.length ?? 0)
|
||||||
return uploaded
|
return uploaded
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
toast({ content: errorMessage(err), type: 'error' })
|
toast({ content: errorMessage(err), type: 'error' })
|
||||||
return 'Failed to upload'
|
return 'Failed to upload'
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
).filter((i) => i != undefined)
|
).filter(i => i != undefined)
|
||||||
|
|
||||||
if (!uploaded) throw new Error('Image upload returned undefined')
|
if (!uploaded) throw new Error('Image upload returned undefined')
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<form
|
<form
|
||||||
class="flex flex-col gap-4"
|
class="flex flex-col gap-4"
|
||||||
onsubmit={(e) => {
|
onsubmit={e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
upload()
|
upload()
|
||||||
}}
|
}}
|
||||||
@@ -96,7 +96,6 @@
|
|||||||
{multiple ? 'grid-cols-3 grid-rows-2' : 'grid-cols-1 grid-rows-1'}"
|
{multiple ? 'grid-cols-3 grid-rows-2' : 'grid-cols-1 grid-rows-1'}"
|
||||||
>
|
>
|
||||||
{#each previewURLs as file}
|
{#each previewURLs as file}
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
|
||||||
<img
|
<img
|
||||||
src={file}
|
src={file}
|
||||||
onload={() => URL.revokeObjectURL(file)}
|
onload={() => URL.revokeObjectURL(file)}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import type { Person } from 'lemmy-js-client'
|
import type { Person } from 'lemmy-js-client'
|
||||||
import { Button, Modal, toast } from 'mono-svelte'
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
open = false
|
open = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err as string),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import type { Community, Person, PersonView } from 'lemmy-js-client'
|
import type { Community, Person } from 'lemmy-js-client'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
|
import { Button, Checkbox, Modal } from 'mono-svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import CommunityLink from '../community/CommunityLink.svelte'
|
import CommunityLink from '../community/CommunityLink.svelte'
|
||||||
import Duration from '$lib/components/form/Duration.svelte'
|
import Duration from '$lib/components/form/Duration.svelte'
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
item.banned = !banned
|
item.banned = !banned
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: PostView | CommentView
|
item: PostView | CommentView
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item = $bindable(), ...rest }: Props = $props()
|
let { item = $bindable(), ...rest }: Props = $props()
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient } from '$lib/lemmy.svelte'
|
import { getClient } from '$lib/lemmy.svelte'
|
||||||
|
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
||||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||||
import { amMod, ban, isAdmin, remove } from './moderation'
|
import { Button, Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ArrowsUpDown,
|
|
||||||
Fire,
|
Fire,
|
||||||
Icon,
|
Icon,
|
||||||
LockClosed,
|
LockClosed,
|
||||||
@@ -12,16 +14,12 @@
|
|||||||
ShieldExclamation,
|
ShieldExclamation,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
import { amMod, ban, isAdmin, remove } from './moderation'
|
||||||
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import ShieldIcon from './ShieldIcon.svelte'
|
import ShieldIcon from './ShieldIcon.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: PostView | CommentView
|
item: PostView | CommentView
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item = $bindable(), ...rest }: Props = $props()
|
let { item = $bindable(), ...rest }: Props = $props()
|
||||||
@@ -44,7 +42,7 @@
|
|||||||
item.post.locked = lock
|
item.post.locked = lock
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -67,7 +65,7 @@
|
|||||||
item.post.featured_community = pinned
|
item.post.featured_community = pinned
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
import { preventDefault, run } from 'svelte/legacy'
|
||||||
|
|
||||||
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
|
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import { Select, Switch, toast } from 'mono-svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
||||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
|
||||||
import { Fire, Icon, Trash } from 'svelte-hero-icons'
|
|
||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
|
||||||
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
|
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { fullCommunityName } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
import { amMod, isAdmin } from './moderation'
|
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||||
import { Button, Checkbox, Modal } from 'mono-svelte'
|
import { Button, Modal, Select, Switch, toast } from 'mono-svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import { Fire, Icon, Trash } from 'svelte-hero-icons'
|
||||||
|
import { amMod, isAdmin } from './moderation'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -153,7 +153,7 @@
|
|||||||
open = false
|
open = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
content: err as any,
|
content: errorMessage(err),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
import { preventDefault, run } from 'svelte/legacy'
|
||||||
|
|
||||||
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import type {
|
import type {
|
||||||
CommentView,
|
CommentView,
|
||||||
PostView,
|
PostView,
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
|
||||||
import { onMount } from 'svelte'
|
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -67,7 +65,7 @@
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({ content: err as any, type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
}
|
}
|
||||||
|
|
||||||
loading = false
|
loading = false
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type {
|
|||||||
PostView,
|
PostView,
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
import { get, writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
interface Modals {
|
interface Modals {
|
||||||
reporting: {
|
reporting: {
|
||||||
@@ -29,7 +29,7 @@ interface Modals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let modals = writable<Modals>({
|
export const modals = writable<Modals>({
|
||||||
reporting: {
|
reporting: {
|
||||||
open: false,
|
open: false,
|
||||||
item: undefined,
|
item: undefined,
|
||||||
@@ -48,7 +48,7 @@ export let modals = writable<Modals>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export function report(item: PostView | CommentView | PrivateMessageView) {
|
export function report(item: PostView | CommentView | PrivateMessageView) {
|
||||||
modals.update((m) => ({
|
modals.update(m => ({
|
||||||
...m,
|
...m,
|
||||||
reporting: {
|
reporting: {
|
||||||
open: true,
|
open: true,
|
||||||
@@ -58,7 +58,7 @@ export function report(item: PostView | CommentView | PrivateMessageView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function remove(item: SubmissionView, purge: boolean = false) {
|
export function remove(item: SubmissionView, purge: boolean = false) {
|
||||||
modals.update((m) => ({
|
modals.update(m => ({
|
||||||
...m,
|
...m,
|
||||||
removing: {
|
removing: {
|
||||||
open: true,
|
open: true,
|
||||||
@@ -69,7 +69,7 @@ export function remove(item: SubmissionView, purge: boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ban(banned: boolean, item: Person, community?: Community) {
|
export function ban(banned: boolean, item: Person, community?: Community) {
|
||||||
modals.update((m) => ({
|
modals.update(m => ({
|
||||||
...m,
|
...m,
|
||||||
banning: {
|
banning: {
|
||||||
open: true,
|
open: true,
|
||||||
@@ -88,16 +88,13 @@ export async function feature(featured: boolean, item: Comment, jwt: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const amMod = (me: MyUserInfo, community: Community) =>
|
export const amMod = (me: MyUserInfo, community: Community) =>
|
||||||
me.moderates.map((c) => c.community.id).includes(community.id) ||
|
me.moderates.map(c => c.community.id).includes(community.id) ||
|
||||||
(community.local && isAdmin(me))
|
(community.local && isAdmin(me))
|
||||||
|
|
||||||
export const amModOfAny = (me?: MyUserInfo) =>
|
export const amModOfAny = (me?: MyUserInfo) =>
|
||||||
me && (me.moderates.length > 0 || isAdmin(me))
|
me && (me.moderates.length > 0 || isAdmin(me))
|
||||||
|
|
||||||
export const isAdmin = (me: MyUserInfo) =>
|
export const isAdmin = (me: MyUserInfo) => me.local_user_view.local_user.admin
|
||||||
// backwards compatibility hack
|
|
||||||
// @ts-ignore
|
|
||||||
me.local_user_view.local_user.admin ?? me.local_user_view.person?.admin
|
|
||||||
|
|
||||||
export const removalTemplate = (
|
export const removalTemplate = (
|
||||||
input: string,
|
input: string,
|
||||||
|
|||||||
@@ -1,29 +1,27 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import { goto } from '$app/navigation'
|
||||||
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||||
|
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
||||||
|
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
|
||||||
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
|
||||||
import PostMeta, {
|
import PostMeta, {
|
||||||
parseTags,
|
parseTags,
|
||||||
type Tag,
|
type Tag,
|
||||||
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { Badge } from 'mono-svelte'
|
|
||||||
import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { ArrowUp, ChatBubbleOvalLeft, Icon } from 'svelte-hero-icons'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
|
|
||||||
import PostBody from './PostBody.svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte'
|
|
||||||
import { goto } from '$app/navigation'
|
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
import PostBody from './PostBody.svelte'
|
||||||
|
|
||||||
function getTagRule(tags: Tag[]): 'blur-sm' | 'hide' | undefined {
|
function getTagRule(tags: Tag[]): 'blur-sm' | 'hide' | undefined {
|
||||||
const tagContent = tags.map((t) => t.content.toLowerCase())
|
const tagContent = tags.map(t => t.content.toLowerCase())
|
||||||
|
|
||||||
let rule: 'blur-sm' | 'hide' | undefined
|
let rule: 'blur-sm' | 'hide' | undefined
|
||||||
if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw))
|
if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw))
|
||||||
rule = 'blur-sm'
|
rule = 'blur-sm'
|
||||||
tagContent.forEach((tag) => {
|
tagContent.forEach(tag => {
|
||||||
if (settings.tagRules?.[tag]) rule = settings.tagRules?.[tag] ?? rule
|
if (settings.tagRules?.[tag]) rule = settings.tagRules?.[tag] ?? rule
|
||||||
if (rule == 'hide') return rule
|
if (rule == 'hide') return rule
|
||||||
})
|
})
|
||||||
@@ -31,8 +29,8 @@
|
|||||||
return rule
|
return rule
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(e: any) {
|
function onClick(e: Event) {
|
||||||
const event = e as MouseEvent
|
const event = e as Event
|
||||||
const parent = document.getElementById(post.post.id.toString())
|
const parent = document.getElementById(post.post.id.toString())
|
||||||
|
|
||||||
if (event.target == parent) {
|
if (event.target == parent) {
|
||||||
@@ -68,7 +66,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
let tags = $derived(parseTags(post.post.name))
|
let tags = $derived(parseTags(post.post.name))
|
||||||
let type = $derived(mediaType(post.post.url, view))
|
let type = $derived(mediaType(post.post.url))
|
||||||
let rule = $derived(getTagRule(tags.tags))
|
let rule = $derived(getTagRule(tags.tags))
|
||||||
let hideTitle = $derived(
|
let hideTitle = $derived(
|
||||||
settings.posts.deduplicateEmbed &&
|
settings.posts.deduplicateEmbed &&
|
||||||
@@ -100,7 +98,6 @@
|
|||||||
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
|
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_no_static_element_interactions -->
|
||||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
||||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
@@ -111,11 +108,10 @@
|
|||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
id={post.post.id.toString()}
|
id={post.post.id.toString()}
|
||||||
onclick={(e) => {
|
onclick={e => {
|
||||||
onClick(e)
|
onClick(e)
|
||||||
}}
|
}}
|
||||||
onkeydown={(e) => {
|
onkeydown={e => {
|
||||||
// @ts-ignore
|
|
||||||
if (e.key == 'Enter') onClick(e)
|
if (e.key == 'Enter') onClick(e)
|
||||||
}}
|
}}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@@ -128,7 +124,7 @@
|
|||||||
published={publishedToDate(post.post.published)}
|
published={publishedToDate(post.post.published)}
|
||||||
{badges}
|
{badges}
|
||||||
subscribed={profile.data?.user?.follows
|
subscribed={profile.data?.user?.follows
|
||||||
.map((c) => c.community.id)
|
.map(c => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
? 'Subscribed'
|
? 'Subscribed'
|
||||||
: 'NotSubscribed'}
|
: 'NotSubscribed'}
|
||||||
@@ -156,9 +152,7 @@
|
|||||||
<PostMediaCompact
|
<PostMediaCompact
|
||||||
post={post.post}
|
post={post.post}
|
||||||
{type}
|
{type}
|
||||||
class="{settings.leftAlign
|
class="{settings.leftAlign ? 'mr-3' : 'ml-3'} shrink no-list-margin"
|
||||||
? 'mr-3'
|
|
||||||
: 'ml-3'} shrink no-list-margin"
|
|
||||||
style="grid-area: media;"
|
style="grid-area: media;"
|
||||||
blur={rule == 'blur-sm' ? true : undefined}
|
blur={rule == 'blur-sm' ? true : undefined}
|
||||||
{view}
|
{view}
|
||||||
@@ -169,7 +163,6 @@
|
|||||||
<PostBody
|
<PostBody
|
||||||
element="section"
|
element="section"
|
||||||
body={post.post.body}
|
body={post.post.body}
|
||||||
{view}
|
|
||||||
style="grid-area: body"
|
style="grid-area: body"
|
||||||
class="relative"
|
class="relative"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,43 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import { goto } from '$app/navigation'
|
||||||
import PostVote from './PostVote.svelte'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { site } from '$lib/lemmy.svelte.js'
|
|
||||||
import {
|
|
||||||
ArrowsUpDown,
|
|
||||||
ArrowTopRightOnSquare,
|
|
||||||
Bookmark,
|
|
||||||
BookmarkSlash,
|
|
||||||
BugAnt,
|
|
||||||
ChatBubbleOvalLeft,
|
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
Clock,
|
|
||||||
EllipsisHorizontal,
|
|
||||||
Eye,
|
|
||||||
EyeSlash,
|
|
||||||
Flag,
|
|
||||||
GlobeAmericas,
|
|
||||||
Icon,
|
|
||||||
MapPin,
|
|
||||||
Newspaper,
|
|
||||||
Pencil,
|
|
||||||
PencilSquare,
|
|
||||||
Share,
|
|
||||||
Trash,
|
|
||||||
UserCircle,
|
|
||||||
XMark,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import {
|
import {
|
||||||
amMod,
|
amMod,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
report,
|
report,
|
||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { instance } from '$lib/instance.svelte'
|
||||||
|
import { site } from '$lib/lemmy.svelte.js'
|
||||||
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
|
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
|
||||||
|
import { communityLink, userLink } from '$lib/lemmy/generic'
|
||||||
import { setSessionStorage } from '$lib/session.js'
|
import { setSessionStorage } from '$lib/session.js'
|
||||||
import { goto } from '$app/navigation'
|
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
|
import { instanceToURL } from '$lib/util.svelte'
|
||||||
|
import { feature } from '$lib/version'
|
||||||
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Menu,
|
Menu,
|
||||||
@@ -47,17 +29,29 @@
|
|||||||
Spinner,
|
Spinner,
|
||||||
toast,
|
toast,
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import {
|
||||||
|
ArrowTopRightOnSquare,
|
||||||
|
Bookmark,
|
||||||
|
BookmarkSlash,
|
||||||
|
BugAnt,
|
||||||
|
ChatBubbleOvalLeft,
|
||||||
|
ChatBubbleOvalLeftEllipsis,
|
||||||
|
EllipsisHorizontal,
|
||||||
|
Eye,
|
||||||
|
EyeSlash,
|
||||||
|
Flag,
|
||||||
|
GlobeAmericas,
|
||||||
|
Icon,
|
||||||
|
MapPin,
|
||||||
|
Newspaper,
|
||||||
|
PencilSquare,
|
||||||
|
Share,
|
||||||
|
Trash,
|
||||||
|
UserCircle,
|
||||||
|
XMark,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
import { hidePost, postLink } from './helpers'
|
import { hidePost, postLink } from './helpers'
|
||||||
import { feature } from '$lib/version'
|
import PostVote from './PostVote.svelte'
|
||||||
import { instanceId, instanceToURL } from '$lib/util.svelte'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
|
||||||
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
|
||||||
import { communityLink, userLink } from '$lib/lemmy/generic'
|
|
||||||
import RelativeDate, {
|
|
||||||
formatRelativeDate,
|
|
||||||
} from '$lib/components/util/RelativeDate.svelte'
|
|
||||||
import { instance } from '$lib/instance.svelte'
|
|
||||||
|
|
||||||
let editing = $state(false)
|
let editing = $state(false)
|
||||||
let saving = $state(false)
|
let saving = $state(false)
|
||||||
@@ -98,7 +92,7 @@
|
|||||||
<PostForm
|
<PostForm
|
||||||
edit
|
edit
|
||||||
editingPost={post.post}
|
editingPost={post.post}
|
||||||
onsubmit={(e) => {
|
onsubmit={e => {
|
||||||
editing = false
|
editing = false
|
||||||
post = e
|
post = e
|
||||||
onedit?.(e)
|
onedit?.(e)
|
||||||
@@ -106,7 +100,6 @@
|
|||||||
>
|
>
|
||||||
{#snippet formtitle()}
|
{#snippet formtitle()}
|
||||||
<!-- Have the title not exist at all -->
|
<!-- Have the title not exist at all -->
|
||||||
{''}
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</PostForm>
|
</PostForm>
|
||||||
{/await}
|
{/await}
|
||||||
@@ -136,7 +129,6 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
target={settings.openLinksInNewTab ? '_blank' : ''}
|
target={settings.openLinksInNewTab ? '_blank' : ''}
|
||||||
title={$t('post.actions.comments')}
|
title={$t('post.actions.comments')}
|
||||||
animations={{ scale: true, large: false }}
|
|
||||||
>
|
>
|
||||||
{@const newComment =
|
{@const newComment =
|
||||||
publishedToDate(post.counts.newest_comment_time).getTime() >
|
publishedToDate(post.counts.newest_comment_time).getTime() >
|
||||||
@@ -148,7 +140,6 @@
|
|||||||
<FormattedNumber number={post.counts.comments} />
|
<FormattedNumber number={post.counts.comments} />
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
|
|
||||||
{#if settings.debugInfo}
|
{#if settings.debugInfo}
|
||||||
{#if debug}
|
{#if debug}
|
||||||
{#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }}
|
{#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }}
|
||||||
@@ -185,7 +176,7 @@
|
|||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (!profile.data?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
saving = true
|
saving = true
|
||||||
post.saved = await save(post, !post.saved, profile.data?.jwt)
|
post.saved = await save(post, !post.saved)
|
||||||
saving = false
|
saving = false
|
||||||
}}
|
}}
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -195,7 +186,6 @@
|
|||||||
loading={saving}
|
loading={saving}
|
||||||
disabled={saving}
|
disabled={saving}
|
||||||
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||||
animations={{ scale: true, large: true }}
|
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={post.saved ? BookmarkSlash : Bookmark} size="16" mini />
|
<Icon src={post.saved ? BookmarkSlash : Bookmark} size="16" mini />
|
||||||
@@ -203,13 +193,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Menu
|
<Menu placement="bottom-end" class="h-8">
|
||||||
placement="bottom-end"
|
|
||||||
containerClass="overflow-auto max-h-[400px]"
|
|
||||||
class="h-8"
|
|
||||||
targetClass="h-full"
|
|
||||||
title={$t('post.actions.more.label')}
|
|
||||||
>
|
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<Button
|
<Button
|
||||||
title={$t('post.actions.more.label')}
|
title={$t('post.actions.more.label')}
|
||||||
@@ -224,59 +208,6 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuDivider>{$t('cards.site.stats')}</MenuDivider>
|
|
||||||
<div class="flex flex-row gap-1 items-center">
|
|
||||||
<MenuButton class="flex-1">
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Clock} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
<span>
|
|
||||||
{publishedToDate(post.post.published).toLocaleDateString(undefined, {
|
|
||||||
dateStyle: 'short',
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</MenuButton>
|
|
||||||
{#if post.post.updated}
|
|
||||||
{@const editedTime = formatRelativeDate(
|
|
||||||
publishedToDate(post.post.updated),
|
|
||||||
{
|
|
||||||
style: 'long',
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
<MenuButton class="flex-1" aria-label={editedTime}>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Pencil} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
<RelativeDate date={publishedToDate(post.post.updated)} />
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{#if post.counts.score}
|
|
||||||
{@const ratio =
|
|
||||||
post.counts.upvotes / (post.counts.upvotes + post.counts.downvotes)}
|
|
||||||
<MenuButton
|
|
||||||
aria-label={$t('aria.vote.score', { default: post.counts.score })}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ArrowsUpDown} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.vote.score')}
|
|
||||||
•
|
|
||||||
<FormattedNumber
|
|
||||||
number={post.counts.score}
|
|
||||||
options={{ notation: 'standard' }}
|
|
||||||
class="font-medium"
|
|
||||||
/>
|
|
||||||
•
|
|
||||||
<FormattedNumber
|
|
||||||
number={ratio}
|
|
||||||
options={{ style: 'percent' }}
|
|
||||||
class="font-medium {ratio > 0.7
|
|
||||||
? 'text-blue-700 dark:text-blue-300'
|
|
||||||
: 'text-red-500'}"
|
|
||||||
/>
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
||||||
<MenuButton link href={userLink(post.creator)}>
|
<MenuButton link href={userLink(post.creator)}>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -309,11 +240,7 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (profile.data?.jwt)
|
if (profile.data?.jwt)
|
||||||
post.read = await markAsRead(
|
post.read = await markAsRead(post.post, !post.read)
|
||||||
post.post,
|
|
||||||
!post.read,
|
|
||||||
profile.data.jwt,
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -326,11 +253,13 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
navigator.share?.({
|
if (navigator.share)
|
||||||
url: localShare
|
navigator.share?.({
|
||||||
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
url: localShare
|
||||||
: post.post.ap_id,
|
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
||||||
}) ??
|
: post.post.ap_id,
|
||||||
|
})
|
||||||
|
else
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
localShare
|
localShare
|
||||||
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
? `${instanceToURL(instance.data)}/post/${post.post.id}`
|
||||||
@@ -346,11 +275,11 @@
|
|||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
{#if !post.post.local}
|
{#if !post.post.local}
|
||||||
<div class="flex">
|
<div class="flex gap-1">
|
||||||
<Button
|
<Button
|
||||||
color={!localShare ? 'primary' : 'secondary'}
|
color={!localShare ? 'primary' : 'secondary'}
|
||||||
size="square-md"
|
size="square-sm"
|
||||||
roundingSide="left"
|
rounding="pill"
|
||||||
onclick={() => (localShare = false)}
|
onclick={() => (localShare = false)}
|
||||||
title={$t('filter.location.global')}
|
title={$t('filter.location.global')}
|
||||||
>
|
>
|
||||||
@@ -358,8 +287,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
color={localShare ? 'primary' : 'secondary'}
|
color={localShare ? 'primary' : 'secondary'}
|
||||||
size="square-md"
|
size="square-sm"
|
||||||
roundingSide="right"
|
rounding="pill"
|
||||||
onclick={() => (localShare = true)}
|
onclick={() => (localShare = true)}
|
||||||
title={$t('filter.location.local')}
|
title={$t('filter.location.local')}
|
||||||
>
|
>
|
||||||
@@ -401,11 +330,7 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (profile.data?.jwt)
|
if (profile.data?.jwt)
|
||||||
post.post.deleted = await deleteItem(
|
post.post.deleted = await deleteItem(post, !post.post.deleted)
|
||||||
post,
|
|
||||||
!post.post.deleted,
|
|
||||||
profile.data.jwt,
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import type { View } from '$lib/settings.svelte'
|
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
@@ -16,7 +15,6 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
body: string
|
body: string
|
||||||
view?: View
|
|
||||||
clickThrough?: boolean
|
clickThrough?: boolean
|
||||||
element?: string
|
element?: string
|
||||||
style?: string
|
style?: string
|
||||||
@@ -25,7 +23,6 @@
|
|||||||
|
|
||||||
let {
|
let {
|
||||||
body,
|
body,
|
||||||
view = 'cozy',
|
|
||||||
clickThrough = false,
|
clickThrough = false,
|
||||||
element: htmlElement = 'div',
|
element: htmlElement = 'div',
|
||||||
style = '',
|
style = '',
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
const newTitle = title
|
const newTitle = title
|
||||||
.toString()
|
.toString()
|
||||||
.replace(/^(\[.[^\]]+\])|(\[.[^\]]+\])$/g, (match, content) => {
|
.replace(/^(\[.[^\]]+\])|(\[.[^\]]+\])$/g, match => {
|
||||||
const contents = match.split(',').map((part: string) => part.trim())
|
const contents = match.split(',').map((part: string) => part.trim())
|
||||||
|
|
||||||
contents
|
contents
|
||||||
.map((i) => i.replaceAll(/(\[|\])/g, ''))
|
.map(i => i.replaceAll(/(\[|\])/g, ''))
|
||||||
.forEach((content: string) => {
|
.forEach((content: string) => {
|
||||||
extracted.push(
|
extracted.push(
|
||||||
textToTag.get(content) ?? {
|
textToTag.get(content) ?? {
|
||||||
@@ -44,32 +44,32 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import { Badge, Popover } from 'mono-svelte'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import RelativeDate, {
|
import RelativeDate, {
|
||||||
formatRelativeDate,
|
formatRelativeDate,
|
||||||
} from '$lib/components/util/RelativeDate.svelte'
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { instance } from '$lib/instance.svelte'
|
||||||
|
import { settings, type View } from '$lib/settings.svelte'
|
||||||
import type { Community, Person, SubscribedType } from 'lemmy-js-client'
|
import type { Community, Person, SubscribedType } from 'lemmy-js-client'
|
||||||
|
import { Badge, Popover } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
LockClosed,
|
LockClosed,
|
||||||
Megaphone,
|
Megaphone,
|
||||||
|
PaperAirplane,
|
||||||
|
Pencil,
|
||||||
Tag,
|
Tag,
|
||||||
Trash,
|
Trash,
|
||||||
PaperAirplane,
|
type IconSource,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
|
||||||
import { settings, type View } from '$lib/settings.svelte'
|
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { Pencil, type IconSource } from 'svelte-hero-icons'
|
|
||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||||
import { profile } from '$lib/auth.svelte'
|
|
||||||
import { instance } from '$lib/instance.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community?: Community | undefined
|
community?: Community | undefined
|
||||||
@@ -83,7 +83,16 @@
|
|||||||
edited?: string | undefined
|
edited?: string | undefined
|
||||||
view?: View
|
view?: View
|
||||||
// Badges
|
// Badges
|
||||||
badges?: any
|
badges?: {
|
||||||
|
nsfw: boolean
|
||||||
|
saved: boolean
|
||||||
|
featured: boolean
|
||||||
|
deleted: boolean
|
||||||
|
removed: boolean
|
||||||
|
locked: boolean
|
||||||
|
moderator: boolean
|
||||||
|
admin: boolean
|
||||||
|
}
|
||||||
tags?: Tag[]
|
tags?: Tag[]
|
||||||
style?: string
|
style?: string
|
||||||
titleClass?: string
|
titleClass?: string
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
export const voteColor = (vote: number) =>
|
||||||
export const voteColor = (vote: number, border: boolean = false) =>
|
|
||||||
vote == 1
|
vote == 1
|
||||||
? `bg-linear-to-br from-blue-500 to-indigo-500 dark:from-blue-400 dark:to-indigo-500 text-slate-50 dark:text-zinc-900`
|
? `bg-linear-to-br from-blue-500 to-indigo-500 dark:from-blue-400 dark:to-indigo-500 text-slate-50 dark:text-zinc-900`
|
||||||
: vote == -1
|
: vote == -1
|
||||||
@@ -17,17 +16,17 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import type { Post } from 'lemmy-js-client'
|
|
||||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { vote as voteItem } from '$lib/lemmy/contentview.js'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import { Button, Popover, buttonColor, toast } from 'mono-svelte'
|
|
||||||
import { site } from '$lib/lemmy.svelte.js'
|
|
||||||
import { fade, fly } from 'svelte/transition'
|
|
||||||
import { backOut } from 'svelte/easing'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { site } from '$lib/lemmy.svelte.js'
|
||||||
|
import { vote as voteItem } from '$lib/lemmy/contentview.js'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { buttonColor, toast } from 'mono-svelte'
|
||||||
|
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||||
|
import { backOut } from 'svelte/easing'
|
||||||
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: Post
|
post: Post
|
||||||
@@ -36,7 +35,7 @@
|
|||||||
upvotes?: number
|
upvotes?: number
|
||||||
downvotes?: number
|
downvotes?: number
|
||||||
showCounts?: boolean
|
showCounts?: boolean
|
||||||
children?: import('svelte').Snippet<[any]>
|
children?: import('svelte').Snippet<[{ vote: number; score: number }]>
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -51,17 +50,14 @@
|
|||||||
|
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
let oldScore = score
|
|
||||||
|
|
||||||
const castVote = async (newVote: number) => {
|
const castVote = async (newVote: number) => {
|
||||||
if (!profile.data?.jwt) {
|
if (!profile.data?.jwt) {
|
||||||
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loading = true
|
loading = true
|
||||||
oldScore = score
|
|
||||||
vote = newVote
|
vote = newVote
|
||||||
const res = await voteItem(post, newVote, profile.data.jwt).catch((e) => {
|
const res = await voteItem(post, newVote).catch(e => {
|
||||||
toast({ content: errorMessage(e), type: 'error' })
|
toast({ content: errorMessage(e), type: 'error' })
|
||||||
return { upvotes: 0, downvotes: 0, score: 0 }
|
return { upvotes: 0, downvotes: 0, score: 0 }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,24 +3,17 @@
|
|||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import { Badge, Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
import type { Snippet } from 'svelte'
|
||||||
|
import { ArchiveBox, Icon, Plus } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
posts: PostView[]
|
posts: PostView[]
|
||||||
community?: boolean
|
community?: boolean
|
||||||
feedData: any
|
children?: Snippet
|
||||||
children?: import('svelte').Snippet
|
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let { posts = $bindable(), community = false, children }: Props = $props()
|
||||||
posts = $bindable(),
|
|
||||||
community = false,
|
|
||||||
feedData,
|
|
||||||
children,
|
|
||||||
...rest
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
|
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { client } from '$lib/lemmy.svelte'
|
import { client } from '$lib/lemmy.svelte'
|
||||||
import {
|
import {
|
||||||
postFeeds,
|
postFeeds,
|
||||||
@@ -10,10 +12,9 @@
|
|||||||
type PostFeedID,
|
type PostFeedID,
|
||||||
} from '$lib/lemmy/postfeed.svelte'
|
} from '$lib/lemmy/postfeed.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { onMount, tick, untrack } from 'svelte'
|
import { onMount, untrack } from 'svelte'
|
||||||
import {
|
import {
|
||||||
ArchiveBox,
|
ArchiveBox,
|
||||||
ChevronDoubleUp,
|
ChevronDoubleUp,
|
||||||
@@ -22,7 +23,6 @@
|
|||||||
Plus,
|
Plus,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
posts: PostView[]
|
posts: PostView[]
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
scrollToIndex: (index: number, window?: boolean) => void
|
scrollToIndex: (index: number, window?: boolean) => void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
let error: any = $state(undefined)
|
let error = $state()
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
let hasMore = $state(true)
|
let hasMore = $state(true)
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
sort: feedData.sort,
|
sort: feedData.sort,
|
||||||
type_: feedData.type_,
|
type_: feedData.type_,
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(e => {
|
||||||
throw new Error(e)
|
throw new Error(e)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const callback: IntersectionObserverCallback = (entries, observer) => {
|
const callback: IntersectionObserverCallback = (entries, observer) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach(entry => {
|
||||||
if (!entry.isIntersecting) return
|
if (!entry.isIntersecting) return
|
||||||
|
|
||||||
const element = entry.target as HTMLElement
|
const element = entry.target as HTMLElement
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
const feed = document.getElementById('feed')
|
const feed = document.getElementById('feed')
|
||||||
if (!feed) return
|
if (!feed) return
|
||||||
|
|
||||||
new MutationObserver((mutations) => {
|
new MutationObserver(mutations => {
|
||||||
mutations.forEach(({ addedNodes, removedNodes }) => {
|
mutations.forEach(({ addedNodes, removedNodes }) => {
|
||||||
addedNodes.forEach(observePost)
|
addedNodes.forEach(observePost)
|
||||||
removedNodes.forEach(unobservePost)
|
removedNodes.forEach(unobservePost)
|
||||||
@@ -176,7 +176,7 @@
|
|||||||
bind:restore={postFeeds.value[feedId].clientData}
|
bind:restore={postFeeds.value[feedId].clientData}
|
||||||
bind:this={listComp}
|
bind:this={listComp}
|
||||||
>
|
>
|
||||||
{#snippet item(_, row, __)}
|
{#snippet item(row)}
|
||||||
<li
|
<li
|
||||||
data-index={row}
|
data-index={row}
|
||||||
style={row < 7 ? `--anim-delay: ${row * 100}ms` : ''}
|
style={row < 7 ? `--anim-delay: ${row * 100}ms` : ''}
|
||||||
@@ -238,7 +238,6 @@
|
|||||||
<div style="border-top-width: 0">
|
<div style="border-top-width: 0">
|
||||||
<EndPlaceholder>
|
<EndPlaceholder>
|
||||||
{$t('routes.frontpage.endFeed', {
|
{$t('routes.frontpage.endFeed', {
|
||||||
// @ts-ignore
|
|
||||||
community_name: feedData.community_name ?? 'undefined',
|
community_name: feedData.community_name ?? 'undefined',
|
||||||
})}
|
})}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
|
|||||||
@@ -1,20 +1,11 @@
|
|||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
|
||||||
export type PostViewWithCrossposts = PostView & {
|
export type PostViewWithCrossposts = PostView & {
|
||||||
withCrossposts: true
|
withCrossposts: true
|
||||||
crossposts: PostView[]
|
crossposts: PostView[]
|
||||||
}
|
}
|
||||||
export type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
|
export type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
|
||||||
const addCrosspostProperty = (
|
|
||||||
post: PostView,
|
|
||||||
crossposts: PostView[],
|
|
||||||
): PostViewWithCrossposts => ({
|
|
||||||
...post,
|
|
||||||
crossposts: crossposts,
|
|
||||||
withCrossposts: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const combineCrossposts = (
|
export const combineCrossposts = (
|
||||||
posts: PostView[],
|
posts: PostView[],
|
||||||
@@ -26,7 +17,7 @@ export const combineCrossposts = (
|
|||||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||||
const seenUrls = new Set<string>()
|
const seenUrls = new Set<string>()
|
||||||
|
|
||||||
posts?.forEach((post) => {
|
posts?.forEach(post => {
|
||||||
if (
|
if (
|
||||||
!post ||
|
!post ||
|
||||||
(settings.hidePosts.deleted && post.post.deleted) ||
|
(settings.hidePosts.deleted && post.post.deleted) ||
|
||||||
@@ -38,7 +29,7 @@ export const combineCrossposts = (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let existing = urlMap.get(post.post.url)
|
const existing = urlMap.get(post.post.url)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.withCrossposts = true
|
existing.withCrossposts = true
|
||||||
if (existing.withCrossposts) {
|
if (existing.withCrossposts) {
|
||||||
|
|||||||
@@ -1,40 +1,44 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy'
|
import { preventDefault, run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
|
||||||
import { client, site } from '$lib/lemmy.svelte.js'
|
|
||||||
import type { Community, Post, PostView } from 'lemmy-js-client'
|
|
||||||
import { Select, Spinner, Switch, toast } from 'mono-svelte'
|
|
||||||
import {
|
|
||||||
Icon,
|
|
||||||
Photo,
|
|
||||||
ArrowPath,
|
|
||||||
Sparkles,
|
|
||||||
ChatBubbleBottomCenterText,
|
|
||||||
Plus,
|
|
||||||
Language,
|
|
||||||
Link,
|
|
||||||
XMark,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
|
||||||
import { placeholders, uploadImage } from '$lib/util.svelte.js'
|
|
||||||
import { Checkbox, TextInput } from 'mono-svelte'
|
|
||||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
|
||||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { slide } from 'svelte/transition'
|
|
||||||
import { feature } from '$lib/version'
|
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
|
||||||
import ErrorContainer, {
|
import ErrorContainer, {
|
||||||
clearErrorScope,
|
clearErrorScope,
|
||||||
pushError,
|
pushError,
|
||||||
} from '$lib/components/error/ErrorContainer.svelte'
|
} from '$lib/components/error/ErrorContainer.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
|
||||||
import FreeTextInput from '$lib/components/input/FreeTextInput.svelte'
|
import FreeTextInput from '$lib/components/input/FreeTextInput.svelte'
|
||||||
|
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||||
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { client, site } from '$lib/lemmy.svelte.js'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||||
|
import { placeholders } from '$lib/util.svelte.js'
|
||||||
|
import type { Community, Post, PostView } from 'lemmy-js-client'
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Select,
|
||||||
|
Spinner,
|
||||||
|
Switch,
|
||||||
|
TextInput,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import { onDestroy, onMount } from 'svelte'
|
||||||
|
import {
|
||||||
|
ArrowPath,
|
||||||
|
ChatBubbleBottomCenterText,
|
||||||
|
Icon,
|
||||||
|
Language,
|
||||||
|
Link,
|
||||||
|
Photo,
|
||||||
|
Plus,
|
||||||
|
Sparkles,
|
||||||
|
XMark,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
import { slide } from 'svelte/transition'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
edit?: boolean
|
edit?: boolean
|
||||||
@@ -82,7 +86,6 @@
|
|||||||
let data = $state(passedData)
|
let data = $state(passedData)
|
||||||
|
|
||||||
// weird select menu language handling
|
// weird select menu language handling
|
||||||
// @ts-ignore
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (data.language_id === '') data.language_id = undefined
|
if (data.language_id === '') data.language_id = undefined
|
||||||
})
|
})
|
||||||
@@ -100,7 +103,6 @@
|
|||||||
data.nsfw = editingPost.nsfw
|
data.nsfw = editingPost.nsfw
|
||||||
data.alt_text = editingPost.alt_text
|
data.alt_text = editingPost.alt_text
|
||||||
data.thumbnail = editingPost.thumbnail_url
|
data.thumbnail = editingPost.thumbnail_url
|
||||||
// @ts-ignore
|
|
||||||
data.language_id = editingPost.language_id.toString()
|
data.language_id = editingPost.language_id.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +117,12 @@
|
|||||||
limit: 40,
|
limit: 40,
|
||||||
})
|
})
|
||||||
|
|
||||||
communities = list.communities.map((c) => c.community)
|
communities = list.communities.map(c => c.community)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
// @ts-ignore
|
// @ts-expect-error TODO get rid of sessionStorage stuff
|
||||||
if (saveDraft) setSessionStorage('postDraft', data)
|
if (saveDraft) setSessionStorage('postDraft', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@
|
|||||||
if (data.url && data.url != '') {
|
if (data.url && data.url != '') {
|
||||||
try {
|
try {
|
||||||
new URL(data.url)
|
new URL(data.url)
|
||||||
} catch (err) {
|
} catch {
|
||||||
pushError({
|
pushError({
|
||||||
message: $t('toast.invalidURL'),
|
message: $t('toast.invalidURL'),
|
||||||
scope: 'post-form',
|
scope: 'post-form',
|
||||||
@@ -190,7 +192,7 @@
|
|||||||
onsubmit?.(post.post_view)
|
onsubmit?.(post.post_view)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
pushError({ message: errorMessage(err as any), scope: 'post-form' })
|
pushError({ message: errorMessage(err as string), scope: 'post-form' })
|
||||||
data.loading = false
|
data.loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,7 +214,7 @@
|
|||||||
if (res.metadata.description)
|
if (res.metadata.description)
|
||||||
data.body = res.metadata.description
|
data.body = res.metadata.description
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((l) => `> ${l}`)
|
.map(l => `> ${l}`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
@@ -221,7 +223,7 @@
|
|||||||
action: () => (data = oldData),
|
action: () => (data = oldData),
|
||||||
duration: 15 * 1000,
|
duration: 15 * 1000,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch {
|
||||||
pushError({
|
pushError({
|
||||||
message: $t('toast.failGenerateTitle'),
|
message: $t('toast.failGenerateTitle'),
|
||||||
scope: 'post-form',
|
scope: 'post-form',
|
||||||
@@ -234,7 +236,7 @@
|
|||||||
if (!url) return false
|
if (!url) return false
|
||||||
try {
|
try {
|
||||||
new URL(url)
|
new URL(url)
|
||||||
} catch (e) {
|
} catch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -258,7 +260,7 @@
|
|||||||
<UploadModal
|
<UploadModal
|
||||||
bind:open={uploadingImage}
|
bind:open={uploadingImage}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onupload={(e) => {
|
onupload={e => {
|
||||||
if (e) data.url = e[0]
|
if (e) data.url = e[0]
|
||||||
uploadingImage = false
|
uploadingImage = false
|
||||||
}}
|
}}
|
||||||
@@ -282,7 +284,7 @@
|
|||||||
listing_type="All"
|
listing_type="All"
|
||||||
label={$t('form.post.community')}
|
label={$t('form.post.community')}
|
||||||
required
|
required
|
||||||
onselect={(e) => {
|
onselect={e => {
|
||||||
const c = e
|
const c = e
|
||||||
if (!c) {
|
if (!c) {
|
||||||
data.community = null
|
data.community = null
|
||||||
@@ -399,7 +401,9 @@
|
|||||||
const url = new URL(await navigator.clipboard.readText())
|
const url = new URL(await navigator.clipboard.readText())
|
||||||
|
|
||||||
data.url = url.toString()
|
data.url = url.toString()
|
||||||
} catch (e) {}
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
@@ -472,9 +476,9 @@
|
|||||||
toast({ content: $t('toast.restoredFromDraft') })
|
toast({ content: $t('toast.restoredFromDraft') })
|
||||||
const draft = getSessionStorage('postDraft')
|
const draft = getSessionStorage('postDraft')
|
||||||
if (draft && !edit) {
|
if (draft && !edit) {
|
||||||
// @ts-ignore
|
// @ts-expect-error TODO get rid of session storage
|
||||||
draft.loading = false
|
draft.loading = false
|
||||||
// @ts-ignore
|
// @ts-expect-error TODO get rid of session storage
|
||||||
data = draft
|
data = draft
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
|
||||||
import { instance } from '$lib/instance.svelte'
|
import { instance } from '$lib/instance.svelte'
|
||||||
import { client } from '$lib/lemmy.svelte.js'
|
import { client } from '$lib/lemmy.svelte.js'
|
||||||
import type { View } from '$lib/settings.svelte'
|
|
||||||
import { isImage, isVideo } from '$lib/ui/image'
|
import { isImage, isVideo } from '$lib/ui/image'
|
||||||
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
|
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
|
||||||
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
import type { CommentView, PersonView, Post } from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
|
||||||
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
||||||
me.person.id == comment.creator.id
|
me.person.id == comment.creator.id
|
||||||
@@ -15,6 +12,9 @@ export const bestImageURL = (
|
|||||||
compact: boolean = true,
|
compact: boolean = true,
|
||||||
width: number = 1024,
|
width: number = 1024,
|
||||||
) => {
|
) => {
|
||||||
|
if (compact) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
if (post.url) return optimizeImageURL(post.url, width)
|
if (post.url) return optimizeImageURL(post.url, width)
|
||||||
else if (post.thumbnail_url)
|
else if (post.thumbnail_url)
|
||||||
return optimizeImageURL(post.thumbnail_url, width)
|
return optimizeImageURL(post.thumbnail_url, width)
|
||||||
@@ -67,7 +67,7 @@ export const postLink = (post: Post) =>
|
|||||||
export type MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none'
|
export type MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none'
|
||||||
export type IframeType = 'youtube' | 'video' | 'none'
|
export type IframeType = 'youtube' | 'video' | 'none'
|
||||||
|
|
||||||
export const mediaType = (url?: string, view: View = 'cozy'): MediaType => {
|
export const mediaType = (url?: string): MediaType => {
|
||||||
if (url) {
|
if (url) {
|
||||||
if (isImage(url)) return 'image'
|
if (isImage(url)) return 'image'
|
||||||
if (isVideo(url)) return 'iframe'
|
if (isVideo(url)) return 'iframe'
|
||||||
@@ -89,7 +89,7 @@ export async function hidePost(
|
|||||||
hide: boolean,
|
hide: boolean,
|
||||||
jwt: string,
|
jwt: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const res = await client({ auth: jwt }).hidePost({
|
await client({ auth: jwt }).hidePost({
|
||||||
hide: hide,
|
hide: hide,
|
||||||
post_ids: [id],
|
post_ids: [id],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,31 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
import { parseURL } from '$lib/components/input/Link.svelte'
|
||||||
import { Button, Material } from 'mono-svelte'
|
|
||||||
import {
|
|
||||||
CheckBadge,
|
|
||||||
ChevronDown,
|
|
||||||
Icon,
|
|
||||||
Link as LinkIcon,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import { optimizeImageURL } from '../helpers'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import type { View } from '$lib/settings.svelte'
|
import type { View } from '$lib/settings.svelte'
|
||||||
|
import { Button, Material } from 'mono-svelte'
|
||||||
|
import { optimizeImageURL } from '../helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
url: string
|
url: string
|
||||||
thumbnail_url?: string | undefined
|
thumbnail_url?: string
|
||||||
nsfw?: boolean
|
nsfw?: boolean
|
||||||
embed_title?: string | undefined
|
embed_title?: string
|
||||||
embed_description?: string | undefined
|
|
||||||
view?: View
|
view?: View
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
url,
|
url,
|
||||||
thumbnail_url = undefined,
|
thumbnail_url,
|
||||||
nsfw = false,
|
nsfw = false,
|
||||||
embed_title = undefined,
|
embed_title,
|
||||||
embed_description = undefined,
|
|
||||||
view = 'cozy',
|
view = 'cozy',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
|
|||||||
@@ -27,15 +27,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
PuzzlePiece,
|
PuzzlePiece,
|
||||||
VideoCamera,
|
VideoCamera,
|
||||||
type IconSource,
|
type IconSource,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { optimizeImageURL, type IframeType, type MediaType } from '../helpers'
|
import { optimizeImageURL, type IframeType } from '../helpers'
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
|
||||||
const urlToEmbed = (inputUrl: string) => {
|
const urlToEmbed = (inputUrl: string) => {
|
||||||
if (type == 'video') {
|
if (type == 'video') {
|
||||||
@@ -89,7 +88,7 @@
|
|||||||
type?: IframeType
|
type?: IframeType
|
||||||
thumbnail?: string | undefined
|
thumbnail?: string | undefined
|
||||||
url: string
|
url: string
|
||||||
opened?: any
|
opened?: boolean
|
||||||
autoplay?: boolean
|
autoplay?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { stopPropagation } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { settings, type View } from '$lib/settings.svelte'
|
|
||||||
import type { Post } from 'lemmy-js-client'
|
|
||||||
import { bestImageURL, postLink } from '../helpers'
|
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
import { bestImageURL, postLink } from '../helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: Post
|
post: Post
|
||||||
@@ -54,7 +52,6 @@
|
|||||||
srcset={bestImageURL(post, false, 1536)}
|
srcset={bestImageURL(post, false, 1536)}
|
||||||
media="(max-width: 1024px)"
|
media="(max-width: 1024px)"
|
||||||
/>
|
/>
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
|
||||||
<img
|
<img
|
||||||
src={bestImageURL(post, false, -1)}
|
src={bestImageURL(post, false, -1)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
@@ -74,11 +71,11 @@
|
|||||||
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
class="absolute bottom-0 left-0 right-0 flex justify-between items-center
|
||||||
rounded-full ml-auto w-max m-2 p-0 gap-1
|
rounded-full ml-auto w-max m-2 p-0 gap-1
|
||||||
*:bg-white *:border *:border-slate-200 dark:*:border-zinc-800 dark:*:bg-zinc-900"
|
*:bg-white *:border *:border-slate-200 dark:*:border-zinc-800 dark:*:bg-zinc-900"
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={e => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
{#if post.alt_text}
|
{#if post.alt_text}
|
||||||
<Button
|
<Button
|
||||||
onclick={(e) => {
|
onclick={e => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
modal({
|
modal({
|
||||||
title: 'Alt',
|
title: 'Alt',
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Empty from '$lib/components/helper/Empty.svelte'
|
|
||||||
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
|
||||||
import {
|
import {
|
||||||
bestImageURL,
|
|
||||||
postLink,
|
|
||||||
type MediaType,
|
|
||||||
iframeType,
|
iframeType,
|
||||||
|
type MediaType,
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
} from '$lib/components/lemmy/post/helpers.js'
|
||||||
import ExpandableImage, {
|
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
||||||
showImage,
|
|
||||||
} from '$lib/components/ui/ExpandableImage.svelte'
|
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import PostIframe from './PostIframe.svelte'
|
import PostIframe from './PostIframe.svelte'
|
||||||
import { Button, Material, modal } from 'mono-svelte'
|
|
||||||
import { onMount } from 'svelte'
|
|
||||||
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
|
||||||
import PostImage from './PostImage.svelte'
|
import PostImage from './PostImage.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -7,17 +7,16 @@
|
|||||||
} from '$lib/components/lemmy/post/helpers.js'
|
} from '$lib/components/lemmy/post/helpers.js'
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { isImage } from '$lib/ui/image'
|
import { isImage } from '$lib/ui/image'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
import { Material, modal, Popover } from 'mono-svelte'
|
import { modal } from 'mono-svelte'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
import {
|
import {
|
||||||
DocumentText,
|
DocumentText,
|
||||||
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
Link,
|
Link,
|
||||||
VideoCamera,
|
VideoCamera,
|
||||||
ExclamationTriangle,
|
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
const thumbnailSize = (view: View) =>
|
const thumbnailSize = (view: View) =>
|
||||||
@@ -68,6 +67,7 @@
|
|||||||
}}
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
{#if post.thumbnail_url || isImage(post.url)}
|
{#if post.thumbnail_url || isImage(post.url)}
|
||||||
<div class="relative overflow-hidden rounded-xl">
|
<div class="relative overflow-hidden rounded-xl">
|
||||||
@@ -75,16 +75,20 @@
|
|||||||
<img
|
<img
|
||||||
src={optimizeImageURL(post.thumbnail_url || post.url || '', 256)}
|
src={optimizeImageURL(post.thumbnail_url || post.url || '', 256)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="object-cover relative overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl
|
class={[
|
||||||
transition-colors {size}"
|
'object-cover relative overflow-hidden bg-slate-100 dark:bg-zinc-800 rounded-xl transition-colors',
|
||||||
|
size,
|
||||||
|
]}
|
||||||
alt={post.alt_text ?? ' '}
|
alt={post.alt_text ?? ' '}
|
||||||
class:blur-xl={blur}
|
class:blur-xl={blur}
|
||||||
/>
|
/>
|
||||||
{#if type != 'image'}
|
{#if type != 'image'}
|
||||||
<div
|
<div
|
||||||
class="absolute w-8 h-8 m-1 bottom-0 left-0 rounded-xl text-slate-800 dark:text-zinc-200
|
class={[
|
||||||
bg-slate-25 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-700
|
'absolute w-8 h-8 m-1 bottom-0 left-0 rounded-xl text-slate-800 dark:text-zinc-200',
|
||||||
grid place-items-center"
|
'bg-slate-25 dark:bg-zinc-900 border border-slate-200 dark:border-zinc-700',
|
||||||
|
'grid place-items-center',
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
src={type == 'iframe' ? VideoCamera : Link}
|
src={type == 'iframe' ? VideoCamera : Link}
|
||||||
@@ -109,10 +113,13 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<div
|
||||||
class="object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl
|
class={[
|
||||||
border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400
|
'object-cover overflow-hidden bg-slate-50 dark:bg-zinc-900 rounded-xl',
|
||||||
dark:group-hover/media:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid
|
'border border-slate-200 dark:border-zinc-800 group-hover/media:border-slate-400',
|
||||||
place-items-center {size}"
|
'dark:group-hover/media:border-zinc-600 transition-colors text-slate-400 dark:text-zinc-600 grid',
|
||||||
|
'place-items-center',
|
||||||
|
size,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
src={type == 'embed'
|
src={type == 'embed'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import type { Community, ListingType, Person } from 'lemmy-js-client'
|
import type { ListingType, Person } from 'lemmy-js-client'
|
||||||
import { MenuButton, Search } from 'mono-svelte'
|
import { MenuButton, Search } from 'mono-svelte'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import { Icon, XCircle } from 'svelte-hero-icons'
|
import { Icon, XCircle } from 'svelte-hero-icons'
|
||||||
@@ -12,8 +12,7 @@
|
|||||||
instance?: string | undefined
|
instance?: string | undefined
|
||||||
listing_type?: ListingType
|
listing_type?: ListingType
|
||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
onselect?: (e: any) => void
|
onselect?: (e: Person) => void
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -28,7 +27,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Search
|
<Search
|
||||||
search={async (q) => {
|
search={async q => {
|
||||||
const results = await getClient(instance).search({
|
const results = await getClient(instance).search({
|
||||||
q: q || ' ',
|
q: q || ' ',
|
||||||
type_: 'Users',
|
type_: 'Users',
|
||||||
@@ -37,9 +36,9 @@
|
|||||||
sort: 'TopAll',
|
sort: 'TopAll',
|
||||||
})
|
})
|
||||||
|
|
||||||
return results.users.map((c) => c.person)
|
return results.users.map(c => c.person)
|
||||||
}}
|
}}
|
||||||
extractName={(c) => `${c.name}@${new URL(c.actor_id).hostname}`}
|
extractName={c => `${c.name}@${new URL(c.actor_id).hostname}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PersonView } from 'lemmy-js-client'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import {
|
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
Icon,
|
|
||||||
PencilSquare,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/lemmy/generic'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import type { PersonView } from 'lemmy-js-client'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
user: PersonView
|
user: PersonView
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
} else {
|
} else {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
badges?: boolean
|
badges?: boolean
|
||||||
inComment?: boolean
|
inComment?: boolean
|
||||||
showInstance?: boolean
|
showInstance?: boolean
|
||||||
displayName?: any
|
displayName?: boolean
|
||||||
instanceClass?: string
|
instanceClass?: string
|
||||||
class?: string
|
class?: string
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { TextInput } from 'mono-svelte'
|
|
||||||
|
|
||||||
let query: string = $state('')
|
|
||||||
let loading = $state(false)
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
loading = true
|
|
||||||
goto(`/search?q=${query}`).then(() => (loading = false))
|
|
||||||
}
|
|
||||||
interface Props {
|
|
||||||
class?: string
|
|
||||||
children?: import('svelte').Snippet<[any]>
|
|
||||||
}
|
|
||||||
|
|
||||||
let { class: clazz = '', children }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<form onsubmit={preventDefault(search)} class="w-full h-full {clazz}">
|
|
||||||
<TextInput
|
|
||||||
bind:value={query}
|
|
||||||
class="w-full h-full {clazz}"
|
|
||||||
placeholder={$t('nav.search')}
|
|
||||||
autofocus
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
{@render children?.({ search, loading })}
|
|
||||||
@@ -21,19 +21,22 @@
|
|||||||
MdSuperscript,
|
MdSuperscript,
|
||||||
MdText,
|
MdText,
|
||||||
} from './renderers/index'
|
} from './renderers/index'
|
||||||
import { linkify, subSupscriptExtension } from './renderers/plugins'
|
import { linkify, subSupscriptExtension } from './renderers/plugins.js'
|
||||||
import containerExtension from './renderers/spoiler/spoiler'
|
import containerExtension from './renderers/spoiler/spoiler.js'
|
||||||
|
|
||||||
export const options: any = {
|
export const options = {
|
||||||
mangle: false,
|
mangle: false,
|
||||||
headerIds: false,
|
headerIds: false,
|
||||||
pedantic: false,
|
pedantic: false,
|
||||||
|
inline: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
marked.setOptions(options)
|
marked.setOptions(options)
|
||||||
|
|
||||||
marked.use(linkify, {
|
marked.use(linkify, {
|
||||||
extensions: [
|
extensions: [
|
||||||
|
// @ts-expect-error hell with marked
|
||||||
|
// eslint-disable-next-line
|
||||||
containerExtension((params: any) => {
|
containerExtension((params: any) => {
|
||||||
if (params.type == 'spoiler') {
|
if (params.type == 'spoiler') {
|
||||||
return {
|
return {
|
||||||
@@ -45,6 +48,8 @@
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}),
|
}),
|
||||||
|
// @ts-expect-error hell with marked
|
||||||
|
// eslint-disable-next-line
|
||||||
subSupscriptExtension((params: any) => {
|
subSupscriptExtension((params: any) => {
|
||||||
if (params.type == 'subscript') {
|
if (params.type == 'subscript') {
|
||||||
return {
|
return {
|
||||||
@@ -74,7 +79,6 @@
|
|||||||
html: MdHtml,
|
html: MdHtml,
|
||||||
code: MdCode,
|
code: MdCode,
|
||||||
list: MdList,
|
list: MdList,
|
||||||
// @ts-ignore
|
|
||||||
spoiler: MdSpoiler,
|
spoiler: MdSpoiler,
|
||||||
table: MdTable,
|
table: MdTable,
|
||||||
tablebody: MdTableBody,
|
tablebody: MdTableBody,
|
||||||
@@ -96,7 +100,6 @@
|
|||||||
html: MdText,
|
html: MdText,
|
||||||
code: MdText,
|
code: MdText,
|
||||||
list: MdText,
|
list: MdText,
|
||||||
// @ts-ignore
|
|
||||||
spoiler: MdText,
|
spoiler: MdText,
|
||||||
table: MdText,
|
table: MdText,
|
||||||
tablebody: MdText,
|
tablebody: MdText,
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { uploadImage } from '$lib/util.svelte.js'
|
import { Button, Label, TextArea } from 'mono-svelte'
|
||||||
import { ImageInput, toast } from 'mono-svelte'
|
import type { TextAreaProps } from 'mono-svelte/forms/TextArea.svelte'
|
||||||
import { Button, Label, Modal, TextArea } from 'mono-svelte'
|
import { tick } from 'svelte'
|
||||||
import { createEventDispatcher, tick } from 'svelte'
|
|
||||||
import {
|
import {
|
||||||
Bold,
|
Bold,
|
||||||
CodeBracket,
|
CodeBracket,
|
||||||
DocumentPlus,
|
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
H1,
|
H1,
|
||||||
Icon,
|
Icon,
|
||||||
@@ -23,8 +18,7 @@
|
|||||||
Strikethrough,
|
Strikethrough,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import ImageUploadModal from '../lemmy/modal/ImageUploadModal.svelte'
|
import ImageUploadModal from '../lemmy/modal/ImageUploadModal.svelte'
|
||||||
import type { HTMLTextareaAttributes } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
import type { TextAreaProps } from 'mono-svelte/forms/TextArea.svelte'
|
|
||||||
|
|
||||||
let textArea: HTMLTextAreaElement | undefined = $state()
|
let textArea: HTMLTextAreaElement | undefined = $state()
|
||||||
|
|
||||||
@@ -60,7 +54,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let uploadingImage = $state(false)
|
let uploadingImage = $state(false)
|
||||||
let image = $state<any>(null)
|
let image = $state<FileList | null | undefined>(null)
|
||||||
|
|
||||||
const shortcuts = {
|
const shortcuts = {
|
||||||
KeyB: () => wrapSelection('**', '**'),
|
KeyB: () => wrapSelection('**', '**'),
|
||||||
@@ -68,11 +62,6 @@
|
|||||||
KeyS: () => wrapSelection('~~', '~~'),
|
KeyS: () => wrapSelection('~~', '~~'),
|
||||||
KeyH: () => wrapSelection('\n# ', ''),
|
KeyH: () => wrapSelection('\n# ', ''),
|
||||||
KeyK: () => wrapSelection('[](', ')'),
|
KeyK: () => wrapSelection('[](', ')'),
|
||||||
Enter: (e: any) => {
|
|
||||||
onconfirm?.(value)
|
|
||||||
const newEvent = new Event('submit', { cancelable: true })
|
|
||||||
e?.target?.form?.dispatchEvent(newEvent)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function adjustHeight() {
|
async function adjustHeight() {
|
||||||
@@ -93,10 +82,9 @@
|
|||||||
rows?: number
|
rows?: number
|
||||||
beforePreview?: (input: string) => string
|
beforePreview?: (input: string) => string
|
||||||
previewing?: boolean
|
previewing?: boolean
|
||||||
class?: string
|
class?: ClassValue
|
||||||
customLabel?: import('svelte').Snippet
|
customLabel?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
onconfirm?: (value: string) => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -107,12 +95,11 @@
|
|||||||
tools = true,
|
tools = true,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
rows = 2,
|
rows = 2,
|
||||||
beforePreview = (input) => input,
|
beforePreview = input => input,
|
||||||
previewing = $bindable(false),
|
previewing = $bindable(false),
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
customLabel,
|
customLabel,
|
||||||
children,
|
children,
|
||||||
onconfirm,
|
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
@@ -125,8 +112,8 @@
|
|||||||
<ImageUploadModal
|
<ImageUploadModal
|
||||||
bind:open={uploadingImage}
|
bind:open={uploadingImage}
|
||||||
bind:image
|
bind:image
|
||||||
onupload={(e) => {
|
onupload={e => {
|
||||||
e.forEach((i) => {
|
e.forEach(i => {
|
||||||
wrapSelection(`\n\n`, '')
|
wrapSelection(`\n\n`, '')
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -265,10 +252,10 @@ overflow-hidden transition-colors {clazz}"
|
|||||||
class="bg-inherit z-0 border-0 rounded-none ring-0! focus:ring-transparent! transition-none! resize-none"
|
class="bg-inherit z-0 border-0 rounded-none ring-0! focus:ring-transparent! transition-none! resize-none"
|
||||||
bind:value
|
bind:value
|
||||||
bind:element={textArea}
|
bind:element={textArea}
|
||||||
onkeydown={(e) => {
|
onkeydown={e => {
|
||||||
if (disabled) return
|
if (disabled) return
|
||||||
if (e.ctrlKey || e.metaKey) {
|
if (e.ctrlKey || e.metaKey) {
|
||||||
// @ts-ignore
|
// @ts-expect-error yes it can
|
||||||
let shortcut = shortcuts[e.code]
|
let shortcut = shortcuts[e.code]
|
||||||
if (shortcut) {
|
if (shortcut) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -277,11 +264,11 @@ overflow-hidden transition-colors {clazz}"
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
oninput={adjustHeight}
|
oninput={adjustHeight}
|
||||||
onpaste={(e) => {
|
onpaste={e => {
|
||||||
if (!e.clipboardData?.files) return
|
if (!e.clipboardData?.files) return
|
||||||
const files = Array.from(e.clipboardData.files)
|
const files = Array.from(e.clipboardData.files)
|
||||||
if (files[0]?.type.startsWith('image/')) {
|
if (files[0]?.type.startsWith('image/')) {
|
||||||
image = e.clipboardData.files[0]
|
image = e.clipboardData.files[0] as unknown as FileList | null
|
||||||
uploadingImage = true
|
uploadingImage = true
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
|
||||||
import {
|
import {
|
||||||
iframeType,
|
iframeType,
|
||||||
mediaType,
|
mediaType,
|
||||||
optimizeImageURL,
|
optimizeImageURL,
|
||||||
} from '$lib/components/lemmy/post/helpers'
|
} from '$lib/components/lemmy/post/helpers'
|
||||||
import PostIframe from '$lib/components/lemmy/post/media/PostIframe.svelte'
|
import PostIframe from '$lib/components/lemmy/post/media/PostIframe.svelte'
|
||||||
import { getContext } from 'svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
import { ArrowDown, ArrowDownTray, Icon } from 'svelte-hero-icons'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { getContext } from 'svelte'
|
||||||
|
import { ArrowDownTray, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let loaded: boolean = $state(
|
let loaded: boolean = $state(
|
||||||
(getContext('options') as { autoloadImages: boolean })?.autoloadImages ??
|
(getContext('options') as { autoloadImages: boolean })?.autoloadImages ??
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
class="inline"
|
class="inline"
|
||||||
onclick={() => showImage(optimizeImageURL(href, -1), text)}
|
onclick={() => showImage(optimizeImageURL(href, -1))}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={optimizeImageURL(href, 1024)}
|
src={optimizeImageURL(href, 1024)}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { photonify } from './plugins'
|
import { photonify } from './plugins.js'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
href?: string
|
href?: string
|
||||||
title?: any
|
title?: string
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
export const parseURL = (href: string) => {
|
export const parseURL = (href: string) => {
|
||||||
try {
|
try {
|
||||||
return new URL(href)
|
return new URL(href)
|
||||||
} catch (e) {
|
} catch {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
let { tokens, children } = $props()
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { marked } from 'marked'
|
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import { options, renderers } from '../Markdown.svelte'
|
import { options, renderers } from '../Markdown.svelte'
|
||||||
import { Disclosure } from 'mono-svelte'
|
|
||||||
import { Icon } from 'svelte-hero-icons'
|
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
+19
-17
@@ -4,10 +4,11 @@ import markedLinkifyIt from 'marked-linkify-it'
|
|||||||
export const spoilerPlugin = {
|
export const spoilerPlugin = {
|
||||||
name: 'spoiler',
|
name: 'spoiler',
|
||||||
level: 'block',
|
level: 'block',
|
||||||
start(src: string) {
|
start(src) {
|
||||||
return src.match(/^:::/)?.index
|
return src.match(/^:::/)?.index
|
||||||
},
|
},
|
||||||
tokenizer(src: string, tokens: any) {
|
// eslint-disable-next-line
|
||||||
|
tokenizer(src, tokens) {
|
||||||
const rule = /^::: spoiler (.+)\n([\s\S]*?)\n:::/
|
const rule = /^::: spoiler (.+)\n([\s\S]*?)\n:::/
|
||||||
const match = rule.exec(src)
|
const match = rule.exec(src)
|
||||||
if (match) {
|
if (match) {
|
||||||
@@ -19,7 +20,7 @@ export const spoilerPlugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token: any) {
|
renderer(token) {
|
||||||
return `
|
return `
|
||||||
<details>
|
<details>
|
||||||
<summary>${marked.parseInline(token.title)}</summary>
|
<summary>${marked.parseInline(token.title)}</summary>
|
||||||
@@ -32,12 +33,12 @@ export const spoilerPlugin = {
|
|||||||
export const linkify = markedLinkifyIt(
|
export const linkify = markedLinkifyIt(
|
||||||
{
|
{
|
||||||
'!': {
|
'!': {
|
||||||
validate: function (text: any, pos: any, self: any) {
|
validate: function (text, pos, self) {
|
||||||
var tail = text.slice(pos)
|
var tail = text.slice(pos)
|
||||||
|
|
||||||
if (!self.re.community) {
|
if (!self.re.community) {
|
||||||
self.re.community = new RegExp(
|
self.re.community = new RegExp(
|
||||||
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i,
|
/^([a-z0-9_.-]+)@([\da-z.-]+)\.([a-z]{2,63})/i,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (self.re.community.test(tail)) {
|
if (self.re.community.test(tail)) {
|
||||||
@@ -46,11 +47,11 @@ export const linkify = markedLinkifyIt(
|
|||||||
if (pos >= 2 && tail[pos - 2] === '!') {
|
if (pos >= 2 && tail[pos - 2] === '!') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return tail.match(self.re.community)![0].length
|
return tail.match(self.re.community)[0].length
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
normalize: function (match: any) {
|
normalize: function (match) {
|
||||||
let prefix = match.url
|
let prefix = match.url
|
||||||
prefix = prefix.startsWith('c/') ? prefix.slice(2) : prefix.slice(1)
|
prefix = prefix.startsWith('c/') ? prefix.slice(2) : prefix.slice(1)
|
||||||
|
|
||||||
@@ -58,12 +59,12 @@ export const linkify = markedLinkifyIt(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'@': {
|
'@': {
|
||||||
validate: function (text: any, pos: any, self: any) {
|
validate: function (text, pos, self) {
|
||||||
var tail = text.slice(pos)
|
var tail = text.slice(pos)
|
||||||
|
|
||||||
if (!self.re.user) {
|
if (!self.re.user) {
|
||||||
self.re.user = new RegExp(
|
self.re.user = new RegExp(
|
||||||
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z]{2,63})/i,
|
/^([a-z0-9_.-]+)@([\da-z.-]+)\.([a-z]{2,63})/i,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (self.re.user.test(tail)) {
|
if (self.re.user.test(tail)) {
|
||||||
@@ -72,11 +73,11 @@ export const linkify = markedLinkifyIt(
|
|||||||
if (pos >= 2 && tail[pos - 2] === '!') {
|
if (pos >= 2 && tail[pos - 2] === '!') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return tail.match(self.re.user)![0].length
|
return tail.match(self.re.user)[0].length
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
normalize: function (match: any) {
|
normalize: function (match) {
|
||||||
let prefix = match.url
|
let prefix = match.url
|
||||||
prefix = prefix.startsWith('u/') ? prefix.slice(2) : prefix.slice(1)
|
prefix = prefix.startsWith('u/') ? prefix.slice(2) : prefix.slice(1)
|
||||||
|
|
||||||
@@ -94,13 +95,13 @@ const regexes = {
|
|||||||
comment: /^https:\/\/([a-zA-Z0-9.-]+)\/comment\/(\d+)$/i,
|
comment: /^https:\/\/([a-zA-Z0-9.-]+)\/comment\/(\d+)$/i,
|
||||||
user: /^https:\/\/([a-zA-Z0-9.-]+)(\/u\/)([a-zA-Z0-9.-_]+)$/i,
|
user: /^https:\/\/([a-zA-Z0-9.-]+)(\/u\/)([a-zA-Z0-9.-_]+)$/i,
|
||||||
community: /^https:\/\/([a-zA-Z0-9.-]+)(\/c\/)([a-zA-Z0-9.-_]+)$/i,
|
community: /^https:\/\/([a-zA-Z0-9.-]+)(\/c\/)([a-zA-Z0-9.-_]+)$/i,
|
||||||
implicitUser: /^mailto:([a-z0-9_\.-]+)@(([\da-z\.-]+)\.([a-z]{2,63}))/i,
|
implicitUser: /^mailto:([a-z0-9_.-]+)@(([\da-z.-]+)\.([a-z]{2,63}))/i,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert links to photon links
|
* Convert links to photon links
|
||||||
*/
|
*/
|
||||||
export const photonify = (link: string) => {
|
export const photonify = link => {
|
||||||
if (regexes.community.test(link)) {
|
if (regexes.community.test(link)) {
|
||||||
const match = link.match(regexes.community)
|
const match = link.match(regexes.community)
|
||||||
if (!match) return
|
if (!match) return
|
||||||
@@ -136,16 +137,17 @@ export const photonify = (link: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subSupscriptExtension(tokensExtractor: any): any {
|
export function subSupscriptExtension(tokensExtractor) {
|
||||||
return {
|
return {
|
||||||
name: 'subscriptSuperscript',
|
name: 'subscriptSuperscript',
|
||||||
level: 'inline',
|
level: 'inline',
|
||||||
start(src: string) {
|
start(src) {
|
||||||
return src.match(/[~^]/)?.index
|
return src.match(/[~^]/)?.index
|
||||||
},
|
},
|
||||||
tokenizer(src: string, tokens: any[]): any {
|
// eslint-disable-next-line
|
||||||
|
tokenizer(src, tokens) {
|
||||||
const subscriptRule = /^~([^~\s](?:[^~]*[^~\s])?)~/
|
const subscriptRule = /^~([^~\s](?:[^~]*[^~\s])?)~/
|
||||||
const superscriptRule = /^\^([^\^\s](?:[^\^]*[^\^\s])?)\^/
|
const superscriptRule = /^\^([^^\s](?:[^^]*[^^\s])?)\^/
|
||||||
|
|
||||||
let match
|
let match
|
||||||
|
|
||||||
+6
-35
@@ -1,32 +1,3 @@
|
|||||||
import { Lexer } from 'marked'
|
|
||||||
|
|
||||||
export type ContainerOptions = Record<string, boolean | string>
|
|
||||||
|
|
||||||
export type TokenExtractionParameters = {
|
|
||||||
/**
|
|
||||||
* The type of container
|
|
||||||
*/
|
|
||||||
type: string
|
|
||||||
/**
|
|
||||||
* The content inside the container
|
|
||||||
*/
|
|
||||||
content: string
|
|
||||||
/**
|
|
||||||
* The raw full container block
|
|
||||||
*/
|
|
||||||
raw: string
|
|
||||||
/**
|
|
||||||
* The options of the container
|
|
||||||
*/
|
|
||||||
options: ContainerOptions
|
|
||||||
/**
|
|
||||||
* The lexer that can be used to render nested tokens if needed
|
|
||||||
*/
|
|
||||||
lexer: Lexer
|
|
||||||
}
|
|
||||||
|
|
||||||
export type TokenExtractor = (params: any) => any
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container extension is a marked extension that parses a block of text surrounded by :::
|
* Container extension is a marked extension that parses a block of text surrounded by :::
|
||||||
*
|
*
|
||||||
@@ -48,14 +19,14 @@ export type TokenExtractor = (params: any) => any
|
|||||||
* **content**: `Something inside the container`
|
* **content**: `Something inside the container`
|
||||||
* **options**: { 'option': 'option-1', 'option-2': 'option-2', 'boolean-option': true }
|
* **options**: { 'option': 'option-1', 'option-2': 'option-2', 'boolean-option': true }
|
||||||
*/
|
*/
|
||||||
export default function (tokensExtractor: any): any {
|
export default function (tokensExtractor) {
|
||||||
return {
|
return {
|
||||||
name: 'container',
|
name: 'container',
|
||||||
level: 'block',
|
level: 'block',
|
||||||
start(src: any) {
|
start(src) {
|
||||||
return src.match(/^:::[^:\n]/)?.index
|
return src.match(/^:::[^:\n]/)?.index
|
||||||
},
|
},
|
||||||
tokenizer(src: any): any {
|
tokenizer(src) {
|
||||||
const rule =
|
const rule =
|
||||||
/^:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n|$)/i
|
/^:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n|$)/i
|
||||||
|
|
||||||
@@ -83,7 +54,7 @@ export default function (tokensExtractor: any): any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findRawContainer(src: any): any {
|
function findRawContainer(src) {
|
||||||
if (!src.startsWith(':::')) return undefined
|
if (!src.startsWith(':::')) return undefined
|
||||||
const lines = src.split('\n')
|
const lines = src.split('\n')
|
||||||
let open = 1
|
let open = 1
|
||||||
@@ -107,8 +78,8 @@ function findRawContainer(src: any): any {
|
|||||||
return lines.slice(0, lineNumber + 1).join('\n')
|
return lines.slice(0, lineNumber + 1).join('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseOptions(options: string): ContainerOptions {
|
function parseOptions(options) {
|
||||||
const output: any = {}
|
const output = {}
|
||||||
let remaining = options
|
let remaining = options
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
<script lang="ts" generics="T">
|
<script lang="ts" generics="T">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { debounce } from 'mono-svelte/util/time'
|
import { onDestroy, untrack, type Snippet } from 'svelte'
|
||||||
import { onDestroy, tick, untrack, type Snippet } from 'svelte'
|
|
||||||
import type { HTMLAttributes } from 'svelte/elements'
|
import type { HTMLAttributes } from 'svelte/elements'
|
||||||
import { innerHeight, scrollY } from 'svelte/reactivity/window'
|
import { innerHeight } from 'svelte/reactivity/window'
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<HTMLDivElement> {
|
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||||
items: T[]
|
items: T[]
|
||||||
estimatedHeight?: number
|
estimatedHeight?: number
|
||||||
overscan?: number
|
overscan?: number
|
||||||
item: Snippet<[T, number, Function]>
|
item: Snippet<[number]>
|
||||||
restore?: {
|
restore?: {
|
||||||
itemHeights: (number | null)[]
|
itemHeights: (number | null)[]
|
||||||
}
|
}
|
||||||
@@ -117,7 +116,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resizeObserver(node: HTMLElement) {
|
function resizeObserver(node: HTMLElement) {
|
||||||
const observer = new ResizeObserver((entries) => {
|
const observer = new ResizeObserver(entries => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const indexAttr = node.getAttribute('data-index')
|
const indexAttr = node.getAttribute('data-index')
|
||||||
if (indexAttr === null) continue
|
if (indexAttr === null) continue
|
||||||
@@ -174,7 +173,7 @@
|
|||||||
class="post-container fix-divide"
|
class="post-container fix-divide"
|
||||||
use:resizeObserver
|
use:resizeObserver
|
||||||
>
|
>
|
||||||
{@render itemSnippet(items[item.index], item.index, () => {})}
|
{@render itemSnippet(item.index)}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return urlObj.toString()
|
return urlObj.toString()
|
||||||
} catch (e) {
|
} catch {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
res?: number | undefined
|
res?: number | undefined
|
||||||
style?: string
|
style?: string
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -53,7 +52,7 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let optimizedURLs = $derived(
|
let optimizedURLs = $derived(
|
||||||
[2, 3, 6, -1].map((n) => optimizeUrl(url, (res || width) * n)),
|
[2, 3, 6, -1].map(n => optimizeUrl(url, (res || width) * n)),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Material } from 'mono-svelte'
|
|
||||||
import Avatar from './Avatar.svelte'
|
|
||||||
import PostBody from '../lemmy/post/PostBody.svelte'
|
|
||||||
import LabelStat from './LabelStat.svelte'
|
|
||||||
import { optimizeImageURL } from '../lemmy/post/helpers'
|
|
||||||
import FormattedNumber from '../util/FormattedNumber.svelte'
|
|
||||||
import Expandable from './Expandable.svelte'
|
|
||||||
import { Icon, InformationCircle } from 'svelte-hero-icons'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import Markdown from '../markdown/Markdown.svelte'
|
import Markdown from '../markdown/Markdown.svelte'
|
||||||
import EndPlaceholder from './EndPlaceholder.svelte'
|
import FormattedNumber from '../util/FormattedNumber.svelte'
|
||||||
|
import Avatar from './Avatar.svelte'
|
||||||
|
import Expandable from './Expandable.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
avatar?: string | undefined
|
avatar?: string | undefined
|
||||||
@@ -27,7 +21,6 @@
|
|||||||
nameDetail?: import('svelte').Snippet
|
nameDetail?: import('svelte').Snippet
|
||||||
actions?: import('svelte').Snippet
|
actions?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
import { pushState } from '$app/navigation'
|
import { pushState } from '$app/navigation'
|
||||||
|
|
||||||
export function showImage(url: string, alt: string = '') {
|
export function showImage(url: string) {
|
||||||
pushState('', {
|
pushState('', {
|
||||||
openImage: url,
|
openImage: url,
|
||||||
})
|
})
|
||||||
@@ -30,16 +30,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if page.state.openImage || '' != ''}
|
{#if page.state.openImage || '' != ''}
|
||||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
||||||
<!-- svelte-ignore a11y_positive_tabindex -->
|
|
||||||
<div
|
<div
|
||||||
class="fixed top-0 left-0 w-screen h-svh overflow-auto bg-white/50 dark:bg-black/50
|
class="fixed top-0 left-0 w-screen h-svh overflow-auto bg-white/50 dark:bg-black/50
|
||||||
flex flex-col z-100 backdrop-blur-xs"
|
flex flex-col z-100 backdrop-blur-xs"
|
||||||
transition:fade={{ duration: 150 }}
|
transition:fade={{ duration: 150 }}
|
||||||
onclick={() => history.back()}
|
onclick={() => history.back()}
|
||||||
onkeydown={(e) => {
|
onkeydown={e => {
|
||||||
if (e.key == 'Escape') history.back()
|
if (e.key == 'Escape') history.back()
|
||||||
}}
|
}}
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
@@ -60,7 +57,7 @@
|
|||||||
rounding="full"
|
rounding="full"
|
||||||
padding="none"
|
padding="none"
|
||||||
color="uniform"
|
color="uniform"
|
||||||
onclick={(e) => e.stopPropagation()}
|
onclick={e => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
width?: number
|
width?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
cursor?: { next?: string; back?: string } | undefined
|
cursor?: { next?: string; back?: string } | undefined
|
||||||
hasMore?: boolean
|
hasMore?: boolean
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
onchange?: (page: number) => void
|
|
||||||
onchangecursor?: (cursor: string) => void
|
|
||||||
href?: (current: number | string) => string
|
href?: (current: number | string) => string
|
||||||
back?: boolean
|
back?: boolean
|
||||||
}
|
}
|
||||||
@@ -23,8 +21,6 @@
|
|||||||
cursor = undefined,
|
cursor = undefined,
|
||||||
hasMore = true,
|
hasMore = true,
|
||||||
children,
|
children,
|
||||||
onchange,
|
|
||||||
onchangecursor,
|
|
||||||
href,
|
href,
|
||||||
back = true,
|
back = true,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
icon?: IconSource | undefined
|
icon?: IconSource | undefined
|
||||||
title: string
|
title: string
|
||||||
description?: string | undefined
|
description?: string | undefined
|
||||||
center?: boolean
|
|
||||||
class?: string
|
class?: string
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
icon = undefined,
|
icon = undefined,
|
||||||
title,
|
title,
|
||||||
description = undefined,
|
description = undefined,
|
||||||
center = false,
|
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
import type { HTMLAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
|
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
||||||
small?: boolean
|
small?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { small = false, class: clazz = '', children, ...rest }: Props = $props()
|
let { small = false, class: clazz = '', children, ...rest }: Props = $props()
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { theme } from '$lib/ui/colors.svelte'
|
import type { Snippet } from 'svelte'
|
||||||
import type { ClassValue, UIEventHandler } from 'svelte/elements'
|
import type { ClassValue, UIEventHandler } from 'svelte/elements'
|
||||||
import { scrollY } from 'svelte/reactivity/window'
|
import { scrollY } from 'svelte/reactivity/window'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
route?: { id: string | null } | undefined
|
route?: { id: string | null } | undefined
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
children?: import('svelte').Snippet
|
children?: Snippet
|
||||||
navbar?: import('svelte').Snippet<[any]>
|
navbar?: Snippet<[{ class: string; style: string }]>
|
||||||
sidebar?: import('svelte').Snippet<[any]>
|
sidebar?: Snippet<[{ class: string; style: string }]>
|
||||||
main?: import('svelte').Snippet<[any]>
|
main?: Snippet<[{ class: string; style: string }]>
|
||||||
suffix?: import('svelte').Snippet<[any]>
|
suffix?: Snippet<[{ class: string; style: string }]>
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
route = undefined,
|
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
navbar,
|
navbar,
|
||||||
@@ -27,7 +25,7 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let previousTop = 0
|
let previousTop = 0
|
||||||
const onscroll: UIEventHandler<Window> = (e) => {
|
const onscroll: UIEventHandler<Window> = () => {
|
||||||
if (!settings.dock.autoHide) {
|
if (!settings.dock.autoHide) {
|
||||||
dockVisible = true
|
dockVisible = true
|
||||||
return
|
return
|
||||||
@@ -56,6 +54,7 @@
|
|||||||
class: `bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900
|
class: `bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900
|
||||||
pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0
|
pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0
|
||||||
rounded-full lg:rounded-none`,
|
rounded-full lg:rounded-none`,
|
||||||
|
style: '',
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { invalidate, invalidateAll } from '$app/navigation'
|
import { invalidateAll } from '$app/navigation'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { fly } from 'svelte/transition'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
routes: {
|
routes: {
|
||||||
@@ -18,7 +17,7 @@
|
|||||||
let {
|
let {
|
||||||
routes,
|
routes,
|
||||||
currentRoute = undefined,
|
currentRoute = undefined,
|
||||||
buildUrl = (route, href) => href,
|
buildUrl = (_, href) => href,
|
||||||
defaultRoute = undefined,
|
defaultRoute = undefined,
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
@@ -49,7 +48,7 @@
|
|||||||
''}
|
''}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{#each routes as route}
|
{#each routes as route (route.href)}
|
||||||
<a
|
<a
|
||||||
onclick={() => invalidateAll()}
|
onclick={() => invalidateAll()}
|
||||||
href={buildUrl(currentRoute, route.href)}
|
href={buildUrl(currentRoute, route.href)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { Button, buttonColor } from 'mono-svelte'
|
import { Button, buttonColor } from 'mono-svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
|
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
|
|
||||||
interface Props extends ButtonProps {
|
interface Props extends ButtonProps {
|
||||||
label: string
|
label: string
|
||||||
@@ -11,9 +12,8 @@
|
|||||||
adaptive?: boolean
|
adaptive?: boolean
|
||||||
isSelectedFilter?: (path: string) => boolean
|
isSelectedFilter?: (path: string) => boolean
|
||||||
class?: string
|
class?: string
|
||||||
customIcon?: import('svelte').Snippet<[any]>
|
customIcon?: Snippet<[{ size: number; isSelected?: boolean }]>
|
||||||
children?: import('svelte').Snippet
|
children?: Snippet
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
icon,
|
icon,
|
||||||
href,
|
href,
|
||||||
adaptive = true,
|
adaptive = true,
|
||||||
isSelectedFilter = (path) => href != undefined && path == href,
|
isSelectedFilter = path => href != undefined && path == href,
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
customIcon,
|
customIcon,
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
isAdmin,
|
isAdmin,
|
||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||||
import { site } from '$lib/lemmy.svelte.js'
|
import { site } from '$lib/lemmy.svelte.js'
|
||||||
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
GlobeAlt,
|
GlobeAlt,
|
||||||
Icon,
|
Icon,
|
||||||
@@ -17,13 +19,11 @@
|
|||||||
Plus,
|
Plus,
|
||||||
ServerStack,
|
ServerStack,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Profile from './Profile.svelte'
|
|
||||||
import NavButton from './NavButton.svelte'
|
|
||||||
import Logo from '../Logo.svelte'
|
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import CommandsWrapper from './commands/CommandsWrapper.svelte'
|
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
import Logo from '../Logo.svelte'
|
||||||
|
import NavButton from './NavButton.svelte'
|
||||||
|
import Profile from './Profile.svelte'
|
||||||
|
import CommandsWrapper from './commands/CommandsWrapper.svelte'
|
||||||
|
|
||||||
let promptOpen: boolean = $state(false)
|
let promptOpen: boolean = $state(false)
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
{style}
|
{style}
|
||||||
>
|
>
|
||||||
<NavButton
|
<NavButton
|
||||||
oncontextmenu={(e) => {
|
oncontextmenu={e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
promptOpen = true
|
promptOpen = true
|
||||||
return true
|
return true
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
label={$t('nav.admin')}
|
label={$t('nav.admin')}
|
||||||
icon={ServerStack}
|
icon={ServerStack}
|
||||||
class="relative"
|
class="relative"
|
||||||
isSelectedFilter={(path) => path.startsWith('/admin')}
|
isSelectedFilter={path => path.startsWith('/admin')}
|
||||||
>
|
>
|
||||||
{#if ($notifications.applications ?? 0) > 0}
|
{#if ($notifications.applications ?? 0) > 0}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
import { notifications, profile } from '$lib/auth.svelte'
|
import { notifications, profile } from '$lib/auth.svelte'
|
||||||
|
|
||||||
|
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { site } from '$lib/lemmy.svelte'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
|
import { theme } from '$lib/ui/colors.svelte'
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
@@ -10,12 +15,12 @@
|
|||||||
MenuButton,
|
MenuButton,
|
||||||
MenuDivider,
|
MenuDivider,
|
||||||
Modal,
|
Modal,
|
||||||
|
Option,
|
||||||
Select,
|
Select,
|
||||||
Spinner,
|
Spinner,
|
||||||
toast,
|
toast,
|
||||||
Option,
|
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import Avatar from '../Avatar.svelte'
|
import type { Placement } from 'svelte-floating-ui/core'
|
||||||
import {
|
import {
|
||||||
Bars3,
|
Bars3,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
@@ -23,10 +28,8 @@
|
|||||||
CodeBracketSquare,
|
CodeBracketSquare,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
ComputerDesktop,
|
ComputerDesktop,
|
||||||
Heart,
|
|
||||||
Icon,
|
Icon,
|
||||||
Inbox,
|
Inbox,
|
||||||
InformationCircle,
|
|
||||||
Moon,
|
Moon,
|
||||||
ServerStack,
|
ServerStack,
|
||||||
Sun,
|
Sun,
|
||||||
@@ -34,17 +37,13 @@
|
|||||||
UserCircle,
|
UserCircle,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { theme } from '$lib/ui/colors.svelte'
|
import Avatar from '../Avatar.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { site } from '$lib/lemmy.svelte'
|
|
||||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
|
|
||||||
let showInstance = $state(false)
|
let showInstance = $state(false)
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
buttonClass?: string
|
buttonClass?: string
|
||||||
[key: string]: any
|
placement?: Placement
|
||||||
}
|
}
|
||||||
|
|
||||||
let { buttonClass = '', ...rest }: Props = $props()
|
let { buttonClass = '', ...rest }: Props = $props()
|
||||||
@@ -97,13 +96,13 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
|
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
|
||||||
{#if profile.data?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton link href="/profile">
|
<MenuButton href="/profile">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={UserCircle} micro width={16} />
|
<Icon src={UserCircle} micro width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('profile.profile')}
|
{$t('profile.profile')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton link href="/inbox">
|
<MenuButton href="/inbox">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Inbox} micro width={16} />
|
<Icon src={Inbox} micro width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
@@ -114,21 +113,21 @@
|
|||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton link href="/saved">
|
<MenuButton href="/saved">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Bookmark} micro width={16} />
|
<Icon src={Bookmark} micro width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('profile.saved')}
|
{$t('profile.saved')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuButton link href="/accounts">
|
<MenuButton href="/accounts">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={UserGroup} micro width={16} />
|
<Icon src={UserGroup} micro width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('account.accounts')}
|
{$t('account.accounts')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
||||||
<MenuButton link href="/settings">
|
<MenuButton href="/settings">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Cog6Tooth} micro width={16} />
|
<Icon src={Cog6Tooth} micro width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
@@ -176,7 +175,7 @@
|
|||||||
{$t('nav.menu.theme')}
|
{$t('nav.menu.theme')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if settings.debugInfo}
|
{#if settings.debugInfo}
|
||||||
<MenuButton link href="/util">
|
<MenuButton href="/util">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={BugAnt} mini width={16} />
|
<Icon src={BugAnt} mini width={16} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button, Material } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import {
|
import { ArrowUturnDown, Icon, QuestionMarkCircle } from 'svelte-hero-icons'
|
||||||
ArrowUturnDown,
|
import type { HTMLButtonAttributes } from 'svelte/elements'
|
||||||
Icon,
|
|
||||||
QuestionMarkCircle,
|
|
||||||
type IconSource,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import Avatar from '../../Avatar.svelte'
|
import Avatar from '../../Avatar.svelte'
|
||||||
import type { Action } from './actions.svelte'
|
import type { Action } from './actions.svelte'
|
||||||
import type { HTMLButtonAttributes } from 'svelte/elements'
|
import type { Snippet } from 'svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
action: Action
|
action: Action
|
||||||
class?: string
|
class?: string
|
||||||
children?: import('svelte').Snippet
|
children?: Snippet
|
||||||
onclick?: HTMLButtonAttributes['onclick']
|
onclick?: HTMLButtonAttributes['onclick']
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { action, class: clazz = '', children, ...rest }: Props = $props()
|
let { action, class: clazz = '', children, ...rest }: Props = $props()
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
import { browser } from '$app/environment'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import { profile, profileData } from '$lib/auth.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { resumables } from '$lib/lemmy/item'
|
import { resumables } from '$lib/lemmy/item'
|
||||||
|
import { theme } from '$lib/ui/colors.svelte'
|
||||||
import { TextInput } from 'mono-svelte'
|
import { TextInput } from 'mono-svelte'
|
||||||
import { createEventDispatcher, onMount } from 'svelte'
|
import { createEventDispatcher, onMount } from 'svelte'
|
||||||
import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
import { Home, Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import CommandItem from './CommandItem.svelte'
|
|
||||||
import { browser } from '$app/environment'
|
|
||||||
import { afterNavigate, goto } from '$app/navigation'
|
|
||||||
import { profile, profileData } from '$lib/auth.svelte'
|
|
||||||
import { getGroups, type Action, type Group } from './actions.svelte'
|
import { getGroups, type Action, type Group } from './actions.svelte'
|
||||||
import { theme } from '$lib/ui/colors.svelte'
|
import CommandItem from './CommandItem.svelte'
|
||||||
import { page } from '$app/state'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
@@ -73,6 +71,7 @@
|
|||||||
|
|
||||||
const debounce = (fn: Function, ms = 300) => {
|
const debounce = (fn: Function, ms = 300) => {
|
||||||
let timeoutId: ReturnType<typeof setTimeout>
|
let timeoutId: ReturnType<typeof setTimeout>
|
||||||
|
// eslint-disable-next-line
|
||||||
return function (this: any, ...args: any[]) {
|
return function (this: any, ...args: any[]) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
||||||
@@ -82,16 +81,16 @@
|
|||||||
function searchGroup(term: string) {
|
function searchGroup(term: string) {
|
||||||
if (term.length < 1) {
|
if (term.length < 1) {
|
||||||
if (breadcrumbs.length <= 0) {
|
if (breadcrumbs.length <= 0) {
|
||||||
filteredGroups = groups.map((group) => ({
|
filteredGroups = groups.map(group => ({
|
||||||
...group,
|
...group,
|
||||||
actions: flattenActions(group.actions, false),
|
actions: flattenActions(group.actions, false),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filteredGroups = groups
|
filteredGroups = groups
|
||||||
.map((group) => {
|
.map(group => {
|
||||||
const scoredActions = flattenActions(group.actions)
|
const scoredActions = flattenActions(group.actions)
|
||||||
.map((action) => ({
|
.map(action => ({
|
||||||
...action,
|
...action,
|
||||||
score: Math.max(
|
score: Math.max(
|
||||||
fuzzySearch(action.name, term),
|
fuzzySearch(action.name, term),
|
||||||
@@ -99,7 +98,7 @@
|
|||||||
action.detail ? fuzzySearch(action.detail, term) : -1,
|
action.detail ? fuzzySearch(action.detail, term) : -1,
|
||||||
),
|
),
|
||||||
}))
|
}))
|
||||||
.filter((action) => action.score > 0)
|
.filter(action => action.score > 0)
|
||||||
.sort((a, b) => b.score - a.score)
|
.sort((a, b) => b.score - a.score)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -107,11 +106,11 @@
|
|||||||
actions: scoredActions,
|
actions: scoredActions,
|
||||||
score: Math.max(
|
score: Math.max(
|
||||||
fuzzySearch(group.name, term),
|
fuzzySearch(group.name, term),
|
||||||
...scoredActions.map((a) => a.score),
|
...scoredActions.map(a => a.score),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((group) => group.actions.length > 0)
|
.filter(group => group.actions.length > 0)
|
||||||
.sort((a, b) => b.score - a.score)
|
.sort((a, b) => b.score - a.score)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +142,7 @@
|
|||||||
actions: Action[],
|
actions: Action[],
|
||||||
subaction: boolean = true,
|
subaction: boolean = true,
|
||||||
): Action[] {
|
): Action[] {
|
||||||
return actions.flatMap((action) => [
|
return actions.flatMap(action => [
|
||||||
action,
|
action,
|
||||||
...(action.subActions && subaction
|
...(action.subActions && subaction
|
||||||
? flattenActions(action.subActions)
|
? flattenActions(action.subActions)
|
||||||
@@ -164,10 +163,10 @@
|
|||||||
function handleKeydown(event: KeyboardEvent) {
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
const actions = groups
|
const actions = groups
|
||||||
.flatMap((g) => g.actions)
|
.flatMap(g => g.actions)
|
||||||
.filter((a) => a.shortcut != undefined)
|
.filter(a => a.shortcut != undefined)
|
||||||
|
|
||||||
actions.forEach((a) => {
|
actions.forEach(a => {
|
||||||
if (event.key === a.shortcut) {
|
if (event.key === a.shortcut) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (a.href) goto(a.href)
|
if (a.href) goto(a.href)
|
||||||
@@ -247,7 +246,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
let flattenedActions = $derived(
|
let flattenedActions = $derived(
|
||||||
filteredGroups.flatMap((group) => group.actions),
|
filteredGroups.flatMap(group => group.actions),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -269,7 +268,7 @@
|
|||||||
>
|
>
|
||||||
<Icon src={Home} size="16" mini />
|
<Icon src={Home} size="16" mini />
|
||||||
</button>
|
</button>
|
||||||
{#each breadcrumbs as crumb, index}
|
{#each breadcrumbs as crumb (crumb.href)}
|
||||||
<span class="text-base text-slate-400 dark:text-zinc-600">/</span>
|
<span class="text-base text-slate-400 dark:text-zinc-600">/</span>
|
||||||
<span class="text-[13px] font-medium">
|
<span class="text-[13px] font-medium">
|
||||||
{crumb.name}
|
{crumb.name}
|
||||||
@@ -278,11 +277,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="space-y-1" bind:this={container}>
|
<div class="space-y-1" bind:this={container}>
|
||||||
{#each filteredGroups as group, groupIndex}
|
{#each filteredGroups as group, groupIndex (group.name)}
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<span class="text-sm font-medium">{group.name}</span>
|
<span class="text-sm font-medium">{group.name}</span>
|
||||||
<ul class="flex flex-col gap-1">
|
<ul class="flex flex-col gap-1">
|
||||||
{#each group.actions as action, actionIndex}
|
{#each group.actions as action, actionIndex (action.href)}
|
||||||
{@const globalIndex =
|
{@const globalIndex =
|
||||||
filteredGroups
|
filteredGroups
|
||||||
.slice(0, groupIndex)
|
.slice(0, groupIndex)
|
||||||
@@ -290,7 +289,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<CommandItem
|
<CommandItem
|
||||||
{action}
|
{action}
|
||||||
onclick={(e) => {
|
onclick={e => {
|
||||||
if (action.href) {
|
if (action.href) {
|
||||||
togglePalette()
|
togglePalette()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { Modal, Spinner } from 'mono-svelte'
|
import { Modal, Spinner } from 'mono-svelte'
|
||||||
import Commands from './Commands.svelte'
|
|
||||||
import { CommandLine, Icon } from 'svelte-hero-icons'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
|
|||||||
@@ -5,47 +5,46 @@ import {
|
|||||||
amModOfAny,
|
amModOfAny,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
} from '$lib/components/lemmy/moderation/moderation'
|
} from '$lib/components/lemmy/moderation/moderation'
|
||||||
import { resumables, type ResumableItem } from '$lib/lemmy/item'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { type ResumableItem } from '$lib/lemmy/item'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { theme, type ThemeData } from '$lib/ui/colors.svelte'
|
import { theme, type ThemeData } from '$lib/ui/colors.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte'
|
import { fullCommunityName } from '$lib/util.svelte'
|
||||||
import {
|
import {
|
||||||
ArrowRightOnRectangle,
|
ArrowRightOnRectangle,
|
||||||
|
ArrowTrendingDown,
|
||||||
|
ArrowTrendingUp,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
|
ChartBar,
|
||||||
|
ChatBubbleLeftRight,
|
||||||
|
ChatBubbleOvalLeftEllipsis,
|
||||||
|
Clock,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
|
ComputerDesktop,
|
||||||
|
Fire,
|
||||||
GlobeAlt,
|
GlobeAlt,
|
||||||
|
GlobeAmericas,
|
||||||
Home,
|
Home,
|
||||||
Identification,
|
Identification,
|
||||||
Inbox,
|
Inbox,
|
||||||
|
MapPin,
|
||||||
|
Moon,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
|
PaintBrush,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
|
Plus,
|
||||||
|
Scale,
|
||||||
ServerStack,
|
ServerStack,
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
|
Star,
|
||||||
|
Sun,
|
||||||
|
Swatch,
|
||||||
|
Trophy,
|
||||||
UserCircle,
|
UserCircle,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
ViewColumns,
|
ViewColumns,
|
||||||
type IconSource,
|
type IconSource,
|
||||||
PaintBrush,
|
|
||||||
ComputerDesktop,
|
|
||||||
Sun,
|
|
||||||
Moon,
|
|
||||||
MapPin,
|
|
||||||
GlobeAmericas,
|
|
||||||
ChartBar,
|
|
||||||
Trophy,
|
|
||||||
ArrowTrendingUp,
|
|
||||||
Fire,
|
|
||||||
Scale,
|
|
||||||
Star,
|
|
||||||
Clock,
|
|
||||||
ArrowTrendingDown,
|
|
||||||
ChatBubbleOvalLeftEllipsis,
|
|
||||||
ChatBubbleLeftRight,
|
|
||||||
Swatch,
|
|
||||||
Plus,
|
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
|
||||||
export interface Group {
|
export interface Group {
|
||||||
name: string
|
name: string
|
||||||
@@ -55,7 +54,7 @@ export interface Group {
|
|||||||
export interface Action {
|
export interface Action {
|
||||||
name: string
|
name: string
|
||||||
desc?: string
|
desc?: string
|
||||||
handle?: () => any
|
handle?: () => void
|
||||||
href?: string
|
href?: string
|
||||||
shortcut?: string
|
shortcut?: string
|
||||||
icon: string | IconSource
|
icon: string | IconSource
|
||||||
@@ -73,7 +72,7 @@ export function getGroups(
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: t.get('nav.commands.recents'),
|
name: t.get('nav.commands.recents'),
|
||||||
actions: resumables.map((r) => ({
|
actions: resumables.map(r => ({
|
||||||
name: r.name,
|
name: r.name,
|
||||||
icon: r.avatar ?? PencilSquare,
|
icon: r.avatar ?? PencilSquare,
|
||||||
href: r.url,
|
href: r.url,
|
||||||
@@ -306,7 +305,7 @@ export function getGroups(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t.get('account.accounts'),
|
name: t.get('account.accounts'),
|
||||||
actions: profiles.map((p) => ({
|
actions: profiles.map(p => ({
|
||||||
name: p.username ?? t.get('account.guest'),
|
name: p.username ?? t.get('account.guest'),
|
||||||
icon: p.avatar ?? UserCircle,
|
icon: p.avatar ?? UserCircle,
|
||||||
detail: p.instance,
|
detail: p.instance,
|
||||||
@@ -379,7 +378,7 @@ export function getGroups(
|
|||||||
{
|
{
|
||||||
name: t.get('nav.commands.setTheme'),
|
name: t.get('nav.commands.setTheme'),
|
||||||
icon: Swatch,
|
icon: Swatch,
|
||||||
subActions: td.themes.map((th) => ({
|
subActions: td.themes.map(th => ({
|
||||||
name: t.get('nav.commands.setThemeTo', { default: th.name }),
|
name: t.get('nav.commands.setThemeTo', { default: th.name }),
|
||||||
icon: Swatch,
|
icon: Swatch,
|
||||||
handle: () => (theme.data.currentTheme = th.id),
|
handle: () => (theme.data.currentTheme = th.id),
|
||||||
@@ -405,7 +404,7 @@ export function getGroups(
|
|||||||
{
|
{
|
||||||
name: t.get('profile.subscribed'),
|
name: t.get('profile.subscribed'),
|
||||||
actions:
|
actions:
|
||||||
profile.user?.follows.map((f) => ({
|
profile.user?.follows.map(f => ({
|
||||||
icon: f.community.icon,
|
icon: f.community.icon,
|
||||||
name: f.community.title,
|
name: f.community.title,
|
||||||
href: `/c/${fullCommunityName(
|
href: `/c/${fullCommunityName(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import {
|
import {
|
||||||
UserCircle,
|
|
||||||
type IconSource,
|
type IconSource,
|
||||||
Home,
|
Home,
|
||||||
ChartBar,
|
ChartBar,
|
||||||
@@ -17,7 +16,6 @@ import {
|
|||||||
ArrowTrendingUp,
|
ArrowTrendingUp,
|
||||||
Star,
|
Star,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
|
||||||
export interface Link {
|
export interface Link {
|
||||||
url: string
|
url: string
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||||
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
||||||
import { Button } from 'mono-svelte'
|
|
||||||
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons'
|
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let switching: boolean = $state(false)
|
let switching: boolean = $state(false)
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
|
||||||
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
||||||
|
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
|
||||||
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
|
import { Badge } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ArrowLeftOnRectangle,
|
ArrowLeftOnRectangle,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
@@ -8,17 +16,7 @@
|
|||||||
UserCircle,
|
UserCircle,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
|
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
|
||||||
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
|
||||||
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
|
|
||||||
import { flip } from 'svelte/animate'
|
|
||||||
import { expoOut } from 'svelte/easing'
|
|
||||||
import { Badge } from 'mono-svelte'
|
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
|
||||||
import EndPlaceholder from '../EndPlaceholder.svelte'
|
import EndPlaceholder from '../EndPlaceholder.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
style?: string
|
style?: string
|
||||||
@@ -162,7 +160,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<CommunityList
|
<CommunityList
|
||||||
items={profile.data.user.moderates.map((i) => i.community)}
|
items={profile.data.user.moderates.map(i => i.community)}
|
||||||
/>
|
/>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
@@ -184,9 +182,7 @@
|
|||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<CommunityList
|
<CommunityList items={profile.data.user.follows.map(i => i.community)} />
|
||||||
items={profile.data.user.follows.map((i) => i.community)}
|
|
||||||
/>
|
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
|
import type { ButtonProps } from 'mono-svelte/button/Button.svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props extends ButtonProps {
|
||||||
href?: string | undefined
|
href?: string | undefined
|
||||||
icon?: IconSource | undefined
|
icon?: IconSource | undefined
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
class?: string
|
class?: string
|
||||||
customIcon?: import('svelte').Snippet<[any]>
|
customIcon?: import('svelte').Snippet<[{ selected: boolean }]>
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
label?: import('svelte').Snippet
|
label?: import('svelte').Snippet
|
||||||
[key: string]: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
const rtf = new Intl.RelativeTimeFormat(language, options)
|
const rtf = new Intl.RelativeTimeFormat(language, options)
|
||||||
|
|
||||||
return rtf.format(-value, thresholds[i].unit as any)
|
return rtf.format(-value, thresholds[i].unit as 'second')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'Now'
|
return 'Now'
|
||||||
} catch (err) {
|
} catch {
|
||||||
return 'Invalid Date'
|
return 'Invalid Date'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
const toLocaleDateString = (date: Date): string => {
|
const toLocaleDateString = (date: Date): string => {
|
||||||
try {
|
try {
|
||||||
return date.toLocaleString()
|
return date.toLocaleString()
|
||||||
} catch (err) {
|
} catch {
|
||||||
return 'Invalid Date'
|
return 'Invalid Date'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { Modal } from 'mono-svelte'
|
import { Modal } from 'mono-svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
// eslint-disable-next-line
|
||||||
object: any
|
object: any
|
||||||
open?: boolean
|
open?: boolean
|
||||||
title?: import('svelte').Snippet
|
title?: import('svelte').Snippet
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import DebugTree from './DebugTree.svelte'
|
import DebugTree from './DebugTree.svelte'
|
||||||
interface Props {
|
interface Props {
|
||||||
|
// eslint-disable-next-line
|
||||||
object: any
|
object: any
|
||||||
isParent?: boolean
|
isParent?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import i18n, { type Config } from 'sveltekit-i18n'
|
import i18n, { type Config, type Parser } from 'sveltekit-i18n'
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
loaders: [
|
loaders: [
|
||||||
@@ -116,4 +116,8 @@ export const aliases = new Map([
|
|||||||
['he-IL', 'he'],
|
['he-IL', 'he'],
|
||||||
])
|
])
|
||||||
|
|
||||||
export let { t, locale, locales, loading, loadTranslations } = new i18n(config)
|
export const { t, locale, locales, loading, loadTranslations } = new i18n<
|
||||||
|
Parser.Params<any, object>, // eslint-disable-line
|
||||||
|
object,
|
||||||
|
object
|
||||||
|
>(config)
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
// maybe fix circular dependency, hopefully.
|
|
||||||
|
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public'
|
||||||
import { writable } from 'svelte/store'
|
|
||||||
import { profile } from './auth.svelte'
|
import { profile } from './auth.svelte'
|
||||||
|
|
||||||
class InstanceData {
|
class InstanceData {
|
||||||
@@ -13,7 +10,7 @@ class InstanceData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let instance = new InstanceData()
|
export const instance = new InstanceData()
|
||||||
|
|
||||||
export const LINKED_INSTANCE_URL =
|
export const LINKED_INSTANCE_URL =
|
||||||
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
|
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { type GetSiteResponse, LemmyHttp } from 'lemmy-js-client'
|
|
||||||
import { get, writable } from 'svelte/store'
|
|
||||||
import { error } from '@sveltejs/kit'
|
|
||||||
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.svelte.js'
|
|
||||||
import { instanceToURL } from '$lib/util.svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
||||||
|
import { instanceToURL } from '$lib/util.svelte'
|
||||||
|
import { error } from '@sveltejs/kit'
|
||||||
|
import { LemmyHttp, type GetSiteResponse } from 'lemmy-js-client'
|
||||||
|
|
||||||
class SiteData {
|
class SiteData {
|
||||||
#data = $state<GetSiteResponse>()
|
#data = $state<GetSiteResponse>()
|
||||||
@@ -63,13 +61,13 @@ export function client({
|
|||||||
} = {}) {
|
} = {}) {
|
||||||
if (!instanceURL) instanceURL = profile.data.instance || DEFAULT_INSTANCE_URL
|
if (!instanceURL) instanceURL = profile.data.instance || DEFAULT_INSTANCE_URL
|
||||||
|
|
||||||
let jwt = auth ? auth : profile.data?.jwt
|
const jwt = auth ? auth : profile.data?.jwt
|
||||||
|
|
||||||
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
|
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
|
||||||
|
|
||||||
return new LemmyHttp(instanceToURL(instanceURL), {
|
return new LemmyHttp(instanceToURL(instanceURL), {
|
||||||
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
|
fetchFunction: (input, init) => customFetch(func, input, init, jwt),
|
||||||
//@ts-ignore
|
// @ts-expect-error headers thing
|
||||||
headers: headers,
|
headers: headers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -92,7 +90,7 @@ export async function validateInstance(instance: string): Promise<boolean> {
|
|||||||
await getClient(instance).getSite()
|
await getClient(instance).getSite()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
} catch (err) {
|
} catch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { isComment, isCommentView, isPostView } from '$lib/lemmy/item.js'
|
import { isComment, isCommentView } from '$lib/lemmy/item.js'
|
||||||
import type {
|
import type {
|
||||||
CommentView,
|
CommentView,
|
||||||
Person,
|
Person,
|
||||||
@@ -63,7 +63,6 @@ export const contentItem = (item: Submission): ContentView => {
|
|||||||
export async function save(
|
export async function save(
|
||||||
item: ContentView | SubmissionView,
|
item: ContentView | SubmissionView,
|
||||||
save: boolean,
|
save: boolean,
|
||||||
jwt: string,
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmissionView(item)) item = contentView(item)
|
if (isSubmissionView(item)) item = contentView(item)
|
||||||
|
|
||||||
@@ -88,7 +87,6 @@ export async function save(
|
|||||||
export async function deleteItem(
|
export async function deleteItem(
|
||||||
item: ContentView | SubmissionView,
|
item: ContentView | SubmissionView,
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
jwt: string,
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmissionView(item)) item = contentView(item)
|
if (isSubmissionView(item)) item = contentView(item)
|
||||||
|
|
||||||
@@ -113,7 +111,6 @@ export async function deleteItem(
|
|||||||
export async function vote(
|
export async function vote(
|
||||||
item: ContentView | Submission,
|
item: ContentView | Submission,
|
||||||
vote: number,
|
vote: number,
|
||||||
jwt: string,
|
|
||||||
): Promise<{ upvotes: number; downvotes: number; score: number }> {
|
): Promise<{ upvotes: number; downvotes: number; score: number }> {
|
||||||
if (isSubmission(item)) item = contentItem(item)
|
if (isSubmission(item)) item = contentItem(item)
|
||||||
|
|
||||||
@@ -138,14 +135,11 @@ export async function vote(
|
|||||||
export async function markAsRead(
|
export async function markAsRead(
|
||||||
item: ContentView | Submission,
|
item: ContentView | Submission,
|
||||||
read: boolean,
|
read: boolean,
|
||||||
jwt: string,
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmission(item)) item = contentItem(item)
|
if (isSubmission(item)) item = contentItem(item)
|
||||||
|
|
||||||
if (item.type == 'post') {
|
if (item.type == 'post') {
|
||||||
getClient().markPostAsRead({
|
getClient().markPostAsRead({
|
||||||
// @ts-ignore
|
|
||||||
post_id: item.id,
|
|
||||||
post_ids: [item.id],
|
post_ids: [item.id],
|
||||||
read: read,
|
read: read,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
export function errorMessage(error: any, instance?: string): string {
|
export function errorMessage(error: any, instance?: string): string {
|
||||||
try {
|
try {
|
||||||
if (error?.body?.message) {
|
if (error?.body?.message) {
|
||||||
@@ -12,7 +13,8 @@ export function errorMessage(error: any, instance?: string): string {
|
|||||||
if (!error) throw error
|
if (!error) throw error
|
||||||
|
|
||||||
return t.get(`error.${error}`)
|
return t.get(`error.${error}`)
|
||||||
} catch (e) {
|
} catch {
|
||||||
|
// eslint-disable-next-line
|
||||||
return error as any
|
return error as any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import type {
|
import type {
|
||||||
Comment,
|
|
||||||
CommentReplyView,
|
CommentReplyView,
|
||||||
CommentView,
|
CommentView,
|
||||||
Person,
|
Person,
|
||||||
|
|||||||
+11
-11
@@ -1,18 +1,18 @@
|
|||||||
import { profile, profileData } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import type {
|
import type {
|
||||||
|
Comment,
|
||||||
CommentReportView,
|
CommentReportView,
|
||||||
CommentView,
|
CommentView,
|
||||||
|
Community,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
Comment,
|
|
||||||
PersonView,
|
PersonView,
|
||||||
|
Post,
|
||||||
PostReportView,
|
PostReportView,
|
||||||
PostView,
|
PostView,
|
||||||
Post,
|
|
||||||
PrivateMessageReportView,
|
PrivateMessageReportView,
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
Community,
|
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
import { get, writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
export type Result =
|
export type Result =
|
||||||
| PostView
|
| PostView
|
||||||
@@ -90,8 +90,8 @@ function resumableStore(limit: number = 10) {
|
|||||||
set,
|
set,
|
||||||
update,
|
update,
|
||||||
add: (item: ResumableItem) => {
|
add: (item: ResumableItem) => {
|
||||||
update((resumables) => {
|
update(resumables => {
|
||||||
if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
|
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item)))
|
||||||
return resumables
|
return resumables
|
||||||
resumables.unshift(item)
|
resumables.unshift(item)
|
||||||
if (resumables.length > limit) resumables.pop()
|
if (resumables.length > limit) resumables.pop()
|
||||||
@@ -101,13 +101,13 @@ function resumableStore(limit: number = 10) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let resumables = resumableStore()
|
export const resumables = resumableStore()
|
||||||
|
|
||||||
export function addFavorite(item: Community, add: boolean = true) {
|
export function addFavorite(item: Community, add: boolean = true) {
|
||||||
let favs = profile.data.favorites ?? []
|
const favs = profile.data.favorites ?? []
|
||||||
if (favs.map((fav) => fav.id).includes(item.id)) if (add) return
|
if (favs.map(fav => fav.id).includes(item.id)) if (add) return
|
||||||
if (!add) {
|
if (!add) {
|
||||||
favs.splice(favs.map((c) => c.id).indexOf(item.id), 1)
|
favs.splice(favs.map(c => c.id).indexOf(item.id), 1)
|
||||||
} else {
|
} else {
|
||||||
favs.unshift(item)
|
favs.unshift(item)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,4 +104,4 @@ export interface PostFeed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let postFeeds = new PostFeedState()
|
export const postFeeds = new PostFeedState()
|
||||||
@@ -7,7 +7,6 @@ import type {
|
|||||||
PostView,
|
PostView,
|
||||||
PrivateMessage,
|
PrivateMessage,
|
||||||
PrivateMessageReportView,
|
PrivateMessageReportView,
|
||||||
PrivateMessageView,
|
|
||||||
} from 'lemmy-js-client'
|
} from 'lemmy-js-client'
|
||||||
|
|
||||||
interface CommentReport {
|
interface CommentReport {
|
||||||
|
|||||||
+10
-10
@@ -1,34 +1,34 @@
|
|||||||
import { profile, profileData, type Profile } from '$lib/auth.svelte'
|
import { profile, type Profile } from '$lib/auth.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { trycatch } from '$lib/util.svelte'
|
import { trycatch } from '$lib/util.svelte'
|
||||||
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
import type { Community, MyUserInfo } from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
|
||||||
|
// TODO obliterate this file
|
||||||
|
|
||||||
export const blockUser = async (block: boolean, id: number) => {
|
export const blockUser = async (block: boolean, id: number) => {
|
||||||
const auth = profile.data?.jwt
|
const auth = profile.data?.jwt
|
||||||
|
|
||||||
if (!auth) throw new Error('Unauthorized')
|
if (!auth) throw new Error('Unauthorized')
|
||||||
|
|
||||||
const response = await getClient().blockPerson({
|
await getClient().blockPerson({
|
||||||
block: block,
|
block: block,
|
||||||
person_id: id,
|
person_id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isBlocked = (me: MyUserInfo, user: number) =>
|
export const isBlocked = (me: MyUserInfo, user: number) =>
|
||||||
me.person_blocks.map((b) => b.target.id).includes(user)
|
me.person_blocks.map(b => b.target.id).includes(user)
|
||||||
|
|
||||||
export const addSubscription = (
|
export const addSubscription = (
|
||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true,
|
subscribe: boolean = true,
|
||||||
) => {
|
) => {
|
||||||
const index = profile.data.user?.follows
|
const index = profile.data.user?.follows
|
||||||
.map((f) => f.community.id)
|
.map(f => f.community.id)
|
||||||
.indexOf(community.id)
|
.indexOf(community.id)
|
||||||
|
|
||||||
if (subscribe && index == -1) {
|
if (subscribe && index == -1) {
|
||||||
profile.data.user?.follows.push({
|
profile.data.user?.follows.push({
|
||||||
// @ts-ignore
|
|
||||||
follower: profile.data.user.follows[0]?.follower,
|
follower: profile.data.user.follows[0]?.follower,
|
||||||
community: community,
|
community: community,
|
||||||
})
|
})
|
||||||
@@ -37,7 +37,7 @@ export const addSubscription = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
export const addAdmin = async (handle: string, added: boolean) =>
|
||||||
trycatch(async () => {
|
trycatch(async () => {
|
||||||
const user = await getClient().resolveObject({
|
const user = await getClient().resolveObject({
|
||||||
q: handle,
|
q: handle,
|
||||||
@@ -46,10 +46,10 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
|||||||
if (!user.person) throw new Error('No user found')
|
if (!user.person) throw new Error('No user found')
|
||||||
|
|
||||||
return await getClient().addAdmin({
|
return await getClient().addAdmin({
|
||||||
added: true,
|
added: added,
|
||||||
person_id: user.person.person.id,
|
person_id: user.person.person.id,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hasFavorite = (profile: Profile, id: number): boolean =>
|
export const hasFavorite = (profile: Profile, id: number): boolean =>
|
||||||
profile.favorites?.map((i) => i.id).includes(id) ?? false
|
profile.favorites?.map(i => i.id).includes(id) ?? false
|
||||||
Loaded 100 of 225 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user