Merge pull request #650 from Xyphyn/format-refactor
refactor: clean up legacy stuff
This commit is contained in:
193 files changed
+1314
-1895
No files matched your search
+11
-3
@@ -1,9 +1,17 @@
|
|||||||
{
|
{
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "always",
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"htmlWhitespaceSensitivity": "ignore",
|
"htmlWhitespaceSensitivity": "css",
|
||||||
"plugins": ["prettier-plugin-svelte"],
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"svelteAllowShorthand": true,
|
||||||
|
"svelteBracketNewLine": true,
|
||||||
|
"svelteIndentScriptAndStyle": true,
|
||||||
|
"svelteSortOrder": "scripts-options-markup-styles",
|
||||||
|
"svelteStrictMode": false,
|
||||||
|
"useTabs": false
|
||||||
}
|
}
|
||||||
+2
-2
@@ -12,7 +12,7 @@
|
|||||||
"@sveltejs/adapter-node": "^5.2.9",
|
"@sveltejs/adapter-node": "^5.2.9",
|
||||||
"@sveltejs/adapter-static": "^3.0.8",
|
"@sveltejs/adapter-static": "^3.0.8",
|
||||||
"@sveltejs/kit": "^2.17.1",
|
"@sveltejs/kit": "^2.17.1",
|
||||||
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
"@sveltejs/vite-plugin-svelte": "^4.0.4",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"openapi-fetch": "^0.14.0",
|
"openapi-fetch": "^0.14.0",
|
||||||
"postcss": "^8.4.30",
|
"postcss": "^8.4.30",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-svelte": "^3.2.7",
|
"prettier-plugin-svelte": "^3.4.0",
|
||||||
"svelte": "^5.37.3",
|
"svelte": "^5.37.3",
|
||||||
"svelte-adapter-bun-next": "^1.0.3",
|
"svelte-adapter-bun-next": "^1.0.3",
|
||||||
"svelte-check": "^4.0.0",
|
"svelte-check": "^4.0.0",
|
||||||
|
|||||||
+21
-31
@@ -7,7 +7,6 @@ import {
|
|||||||
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
||||||
import { client, getClient, site } from '$lib/client/lemmy.svelte'
|
import { client, getClient, site } from '$lib/client/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 { toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { t } from './i18n/translations'
|
import { t } from './i18n/translations'
|
||||||
@@ -61,8 +60,8 @@ const getCookie = (key: string): string | undefined => {
|
|||||||
|
|
||||||
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]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ class Profile {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
#current = $derived(
|
#current = $derived(
|
||||||
this.meta.profiles.find(i => i.id == this.meta.profile) ??
|
this.meta.profiles.find((i) => i.id == this.meta.profile) ??
|
||||||
this.getDefaultProfile(),
|
this.getDefaultProfile(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ class Profile {
|
|||||||
setInterval(
|
setInterval(
|
||||||
() => {
|
() => {
|
||||||
if (profile.current.jwt)
|
if (profile.current.jwt)
|
||||||
this.checkInbox().then(res => notifications.update(() => res))
|
this.checkInbox().then((res) => notifications.update(() => res))
|
||||||
},
|
},
|
||||||
4 * 60 * 1000,
|
4 * 60 * 1000,
|
||||||
)
|
)
|
||||||
@@ -165,7 +164,7 @@ class Profile {
|
|||||||
}
|
}
|
||||||
set current(value) {
|
set current(value) {
|
||||||
if (!value) return
|
if (!value) return
|
||||||
const index = this.meta.profiles.findIndex(i => i.id == value?.id)
|
const index = this.meta.profiles.findIndex((i) => i.id == value?.id)
|
||||||
this.meta.profiles[index] = value
|
this.meta.profiles[index] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +199,7 @@ class Profile {
|
|||||||
site.data = undefined
|
site.data = undefined
|
||||||
client({ instanceURL: this.#current.instance })
|
client({ instanceURL: this.#current.instance })
|
||||||
.getSite()
|
.getSite()
|
||||||
.then(res => (site.data = res))
|
.then((res) => (site.data = res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +225,8 @@ class Profile {
|
|||||||
|
|
||||||
async add(jwt: string, instance: string, type: ClientType) {
|
async add(jwt: string, instance: string, type: ClientType) {
|
||||||
const user = await userFromJwt(jwt, instance)
|
const user = await userFromJwt(jwt, instance)
|
||||||
.then(u => u)
|
.then((u) => u)
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
toast({ content: errorMessage(err as string), type: 'error' })
|
toast({ content: errorMessage(err as string), type: 'error' })
|
||||||
})
|
})
|
||||||
if (!user?.user) {
|
if (!user?.user) {
|
||||||
@@ -237,7 +236,7 @@ class Profile {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1
|
const id = Math.max(...this.meta.profiles.map((p) => p.id)) + 1
|
||||||
this.meta.profile = id
|
this.meta.profile = id
|
||||||
this.meta.profiles.unshift({
|
this.meta.profiles.unshift({
|
||||||
id: id,
|
id: id,
|
||||||
@@ -253,7 +252,7 @@ class Profile {
|
|||||||
|
|
||||||
remove(id: number) {
|
remove(id: number) {
|
||||||
this.meta.profiles.splice(
|
this.meta.profiles.splice(
|
||||||
this.meta.profiles.findIndex(p => p.id == id),
|
this.meta.profiles.findIndex((p) => p.id == id),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
if (id == this.meta.profile) this.meta.profile = -1
|
if (id == this.meta.profile) this.meta.profile = -1
|
||||||
@@ -261,7 +260,7 @@ class Profile {
|
|||||||
|
|
||||||
move(id: number, up: boolean) {
|
move(id: number, up: boolean) {
|
||||||
try {
|
try {
|
||||||
const index = this.meta.profiles.findIndex(i => i.id == id)
|
const index = this.meta.profiles.findIndex((i) => i.id == id)
|
||||||
this.meta.profiles = moveItem(
|
this.meta.profiles = moveItem(
|
||||||
this.meta.profiles,
|
this.meta.profiles,
|
||||||
index,
|
index,
|
||||||
@@ -277,7 +276,7 @@ class Profile {
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
const serialized = {
|
const serialized = {
|
||||||
...this.meta,
|
...this.meta,
|
||||||
profiles: this.meta.profiles.map(p => serializeUser(p)),
|
profiles: this.meta.profiles.map((p) => serializeUser(p)),
|
||||||
}
|
}
|
||||||
|
|
||||||
setFromStorage('profileData', serialized)
|
setFromStorage('profileData', serialized)
|
||||||
@@ -292,7 +291,7 @@ class Profile {
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
this.fetchUserData().then(() => {
|
this.fetchUserData().then(() => {
|
||||||
if (this.current.jwt)
|
if (this.current.jwt)
|
||||||
this.checkInbox().then(res => notifications.update(() => res))
|
this.checkInbox().then((res) => notifications.update(() => res))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -309,9 +308,7 @@ export const notifications = writable<Notifications>({
|
|||||||
async function userFromJwt(
|
async function userFromJwt(
|
||||||
jwt: string,
|
jwt: string,
|
||||||
instance: string,
|
instance: string,
|
||||||
): Promise<
|
): Promise<{ user?: MyUserInfo; 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()
|
||||||
|
|
||||||
const timer = setTimeout(
|
const timer = setTimeout(
|
||||||
@@ -325,23 +322,16 @@ 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}` })
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!site) return
|
if (!site) return
|
||||||
|
|
||||||
if (!versionIsSupported(site.version, MINIMUM_VERSION)) {
|
|
||||||
toast({
|
|
||||||
content: `This version of Photon only supports Lemmy instances with version ${MINIMUM_VERSION} or higher. This Lemmy instance is running: ${site.version}`,
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const myUser = site.my_user
|
const myUser = site.my_user
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -360,27 +350,27 @@ function serializeUser(user: ProfileInfo): ProfileInfo {
|
|||||||
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,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export abstract class BaseClient {
|
|||||||
abstract type: ClientType
|
abstract type: ClientType
|
||||||
|
|
||||||
abstract getSite(): Promise<types.GetSiteResponse>
|
abstract getSite(): Promise<types.GetSiteResponse>
|
||||||
|
abstract editSite(form: types.EditSite): Promise<types.SiteResponse>
|
||||||
abstract generateTotpSecret(): Promise<types.GenerateTotpSecretResponse>
|
abstract generateTotpSecret(): Promise<types.GenerateTotpSecretResponse>
|
||||||
abstract listLogins(): Promise<types.LoginToken[]>
|
abstract listLogins(): Promise<types.LoginToken[]>
|
||||||
abstract listAllMedia(form: types.ListMedia): Promise<types.ListMediaResponse>
|
abstract listAllMedia(form: types.ListMedia): Promise<types.ListMediaResponse>
|
||||||
@@ -221,6 +222,7 @@ export abstract class BaseClient {
|
|||||||
abstract uploadImage(
|
abstract uploadImage(
|
||||||
form: types.UploadImage,
|
form: types.UploadImage,
|
||||||
): Promise<types.UploadImageResponse>
|
): Promise<types.UploadImageResponse>
|
||||||
|
abstract deleteImage(form: types.DeleteImage): Promise<boolean>
|
||||||
|
|
||||||
abstract setFlair?(form: types.SetPersonFlair): Promise<types.PersonView>
|
abstract setFlair?(form: types.SetPersonFlair): Promise<types.PersonView>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,4 +476,14 @@ export class LemmyClient implements BaseClient {
|
|||||||
): ReturnType<BaseClient['uploadImage']> {
|
): ReturnType<BaseClient['uploadImage']> {
|
||||||
return await this.#client.uploadImage(...params)
|
return await this.#client.uploadImage(...params)
|
||||||
}
|
}
|
||||||
|
async editSite(
|
||||||
|
...params: Parameters<BaseClient['editSite']>
|
||||||
|
): ReturnType<BaseClient['editSite']> {
|
||||||
|
return await this.#client.editSite(...params)
|
||||||
|
}
|
||||||
|
async deleteImage(
|
||||||
|
...params: Parameters<BaseClient['deleteImage']>
|
||||||
|
): ReturnType<BaseClient['deleteImage']> {
|
||||||
|
return await this.#client.deleteImage(...params)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ export class PiefedClient implements BaseClient {
|
|||||||
return {
|
return {
|
||||||
community_view: toCommunityView(response.community_view),
|
community_view: toCommunityView(response.community_view),
|
||||||
cross_posts: response.cross_posts.map(toPostView),
|
cross_posts: response.cross_posts.map(toPostView),
|
||||||
moderators: response.moderators.map(i => ({
|
moderators: response.moderators.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
moderator: toPerson(i.moderator),
|
moderator: toPerson(i.moderator),
|
||||||
})),
|
})),
|
||||||
@@ -261,7 +261,7 @@ export class PiefedClient implements BaseClient {
|
|||||||
return {
|
return {
|
||||||
...response,
|
...response,
|
||||||
community_view: toCommunityView(response.community_view),
|
community_view: toCommunityView(response.community_view),
|
||||||
moderators: response.moderators.map(i => ({
|
moderators: response.moderators.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
moderator: toPerson(i.moderator),
|
moderator: toPerson(i.moderator),
|
||||||
})),
|
})),
|
||||||
@@ -380,7 +380,7 @@ export class PiefedClient implements BaseClient {
|
|||||||
).data!
|
).data!
|
||||||
|
|
||||||
return {
|
return {
|
||||||
moderators: response.moderators.map(i => ({
|
moderators: response.moderators.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
moderator: toPerson(i.moderator),
|
moderator: toPerson(i.moderator),
|
||||||
})),
|
})),
|
||||||
@@ -731,7 +731,7 @@ export class PiefedClient implements BaseClient {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
comments: response.comments.map(toCommentView),
|
comments: response.comments.map(toCommentView),
|
||||||
moderates: response.moderates.map(i => ({
|
moderates: response.moderates.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
moderator: toPerson(i.moderator),
|
moderator: toPerson(i.moderator),
|
||||||
})),
|
})),
|
||||||
@@ -908,4 +908,11 @@ export class PiefedClient implements BaseClient {
|
|||||||
|
|
||||||
return toPersonView(response.person_view)
|
return toPersonView(response.person_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async editSite(): ReturnType<BaseClient['editSite']> {
|
||||||
|
throw new Error('unsupported')
|
||||||
|
}
|
||||||
|
async deleteImage(): ReturnType<BaseClient['deleteImage']> {
|
||||||
|
throw new Error('unsupported')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ export function toMyUser(
|
|||||||
): MyUserInfo {
|
): MyUserInfo {
|
||||||
return {
|
return {
|
||||||
...myUser,
|
...myUser,
|
||||||
community_blocks: myUser.community_blocks.map(i => ({
|
community_blocks: myUser.community_blocks.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
person: toPerson(i.person),
|
person: toPerson(i.person),
|
||||||
})),
|
})),
|
||||||
@@ -101,23 +101,23 @@ export function toMyUser(
|
|||||||
},
|
},
|
||||||
person: toPerson(myUser.local_user_view.person),
|
person: toPerson(myUser.local_user_view.person),
|
||||||
},
|
},
|
||||||
follows: myUser.follows.map(i => ({
|
follows: myUser.follows.map((i) => ({
|
||||||
follower: toPerson(i.follower),
|
follower: toPerson(i.follower),
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
})),
|
})),
|
||||||
moderates: myUser.moderates.map(i => ({
|
moderates: myUser.moderates.map((i) => ({
|
||||||
community: toCommunity(i.community),
|
community: toCommunity(i.community),
|
||||||
moderator: toPerson(i.moderator),
|
moderator: toPerson(i.moderator),
|
||||||
})),
|
})),
|
||||||
instance_blocks: myUser.instance_blocks.map(i => ({
|
instance_blocks: myUser.instance_blocks.map((i) => ({
|
||||||
instance: i.instance,
|
instance: i.instance,
|
||||||
person: toPerson(i.person),
|
person: toPerson(i.person),
|
||||||
})),
|
})),
|
||||||
person_blocks: myUser.person_blocks.map(i => ({
|
person_blocks: myUser.person_blocks.map((i) => ({
|
||||||
person: toPerson(i.person),
|
person: toPerson(i.person),
|
||||||
target: toPerson(i.target),
|
target: toPerson(i.target),
|
||||||
})),
|
})),
|
||||||
discussion_languages: myUser.discussion_languages.map(i => i.id!),
|
discussion_languages: myUser.discussion_languages.map((i) => i.id!),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface BlockInstanceResponse {
|
export interface BlockInstanceResponse {
|
||||||
blocked: boolean;
|
blocked: boolean
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface CaptchaResponse {
|
export interface CaptchaResponse {
|
||||||
png: string;
|
png: string
|
||||||
wav: string;
|
wav: string
|
||||||
uuid: string;
|
uuid: string
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface GenerateTotpSecretResponse {
|
export interface GenerateTotpSecretResponse {
|
||||||
totp_secret_url: string;
|
totp_secret_url: string
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface GetSiteMetadata {
|
export interface GetSiteMetadata {
|
||||||
url: string;
|
url: string
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface GetUnreadCountResponse {
|
export interface GetUnreadCountResponse {
|
||||||
replies: number;
|
replies: number
|
||||||
mentions: number;
|
mentions: number
|
||||||
private_messages: number;
|
private_messages: number
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||||
registration_applications: number;
|
registration_applications: number
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface LoginResponse {
|
export interface LoginResponse {
|
||||||
jwt?: string;
|
jwt?: string
|
||||||
registration_created: boolean;
|
registration_created: boolean
|
||||||
verify_email_sent: boolean;
|
verify_email_sent: boolean
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface SuccessResponse {
|
export interface SuccessResponse {
|
||||||
success: boolean;
|
success: boolean
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export interface UpdateTotpResponse {
|
export interface UpdateTotpResponse {
|
||||||
enabled: boolean;
|
enabled: boolean
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
@@ -32,7 +32,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>
|
||||||
|
|
||||||
|
|||||||
@@ -36,19 +36,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.current.instance, profile.current.jwt!)
|
uploadImage(i, profile.current.instance, profile.current.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')
|
||||||
|
|
||||||
@@ -72,7 +72,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()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
{#if customUrl}
|
{#if customUrl}
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (!imageUrl) throw new Error('missing imageurl')
|
if (!imageUrl) throw new Error('missing imageurl')
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<ImageAttachForm
|
<ImageAttachForm
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onupload={uploaded => {
|
onupload={(uploaded) => {
|
||||||
open = false
|
open = false
|
||||||
passedImageUrl = uploaded[0]
|
passedImageUrl = uploaded[0]
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<script>
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import('svelte').Snippet<[any]>} [children]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {Props & { [key: string]: any }} */
|
|
||||||
let { children, ...rest } = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{@render children?.({ ...rest })}
|
|
||||||
@@ -34,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',
|
||||||
@@ -43,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}
|
||||||
>
|
>
|
||||||
@@ -79,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}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
|
import type { LocalImage, Person } from '$lib/client/types'
|
||||||
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { instance } from '$lib/instance.svelte'
|
import { instance } from '$lib/instance.svelte'
|
||||||
import { client } from '$lib/client/lemmy.svelte'
|
|
||||||
import { instanceToURL } from '$lib/util.svelte'
|
import { instanceToURL } from '$lib/util.svelte'
|
||||||
import type { LocalImage, Person } from '$lib/client/types'
|
|
||||||
import { action, Button, modal, toast } from 'mono-svelte'
|
import { action, Button, modal, toast } from 'mono-svelte'
|
||||||
import { ArrowDownTray, Icon, Trash } from 'svelte-hero-icons'
|
import { ArrowDownTray, Trash } from 'svelte-hero-icons'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
|
||||||
|
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
@@ -60,11 +60,8 @@
|
|||||||
href="{instanceToURL(instance.data)}/pictrs/image/{image.pictrs_alias}"
|
href="{instanceToURL(instance.data)}/pictrs/image/{image.pictrs_alias}"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
class="ml-auto"
|
class="ml-auto"
|
||||||
>
|
icon={ArrowDownTray}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={ArrowDownTray} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
title={$t('post.actions.more.delete')}
|
title={$t('post.actions.more.delete')}
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
@@ -88,10 +85,7 @@
|
|||||||
size="square-md"
|
size="square-md"
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
icon={Trash}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={Trash} size="16" mini color="text-red-500" />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
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 UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
@@ -20,14 +19,14 @@
|
|||||||
Minus,
|
Minus,
|
||||||
Pencil,
|
Pencil,
|
||||||
Plus,
|
Plus,
|
||||||
|
ShieldCheck,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
|
||||||
import CommentForm from './CommentForm.svelte'
|
|
||||||
import type { CommentNodeI } from './comments.svelte'
|
import type { CommentNodeI } from './comments.svelte'
|
||||||
|
import { CommentActions, CommentForm } from '.'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
node: CommentNodeI
|
node: CommentNodeI
|
||||||
@@ -94,7 +93,7 @@
|
|||||||
<div>{$t('form.edit')}</div>
|
<div>{$t('form.edit')}</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
save(replying ? 'reply' : 'edit')
|
save(replying ? 'reply' : 'edit')
|
||||||
}}
|
}}
|
||||||
@@ -154,10 +153,22 @@
|
|||||||
>
|
>
|
||||||
{#snippet extraBadges()}
|
{#snippet extraBadges()}
|
||||||
{#if node.comment_view.creator_is_moderator}
|
{#if node.comment_view.creator_is_moderator}
|
||||||
<ShieldIcon filled width={14} class="text-green-500" />
|
<Icon
|
||||||
|
src={ShieldCheck}
|
||||||
|
size="14"
|
||||||
|
micro
|
||||||
|
class="text-green-500"
|
||||||
|
aria-label={$t('class.moderator')}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if node.comment_view.creator_is_admin}
|
{#if node.comment_view.creator_is_admin}
|
||||||
<ShieldIcon filled width={14} class="text-red-500" />
|
<Icon
|
||||||
|
src={ShieldCheck}
|
||||||
|
size="16"
|
||||||
|
micro
|
||||||
|
class="text-red-500"
|
||||||
|
aria-label={$t('class.admin')}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</UserLink>
|
</UserLink>
|
||||||
@@ -262,7 +273,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,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
import type { CommentView } from '$lib/client/types'
|
||||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||||
import {
|
import {
|
||||||
amMod,
|
amMod,
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { CommentView } from '$lib/client/types'
|
|
||||||
import { Button, Menu, MenuButton } from 'mono-svelte'
|
import { Button, Menu, MenuButton } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
Share,
|
Share,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
import { CommentVote } from '.'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
comment: CommentView
|
comment: CommentView
|
||||||
@@ -74,11 +74,8 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
class="text-slate-600 dark:text-zinc-400"
|
class="text-slate-600 dark:text-zinc-400"
|
||||||
>
|
icon={EllipsisHorizontal}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
@@ -88,18 +85,13 @@
|
|||||||
})
|
})
|
||||||
else navigator.clipboard.writeText(comment.comment.ap_id)
|
else navigator.clipboard.writeText(comment.comment.ap_id)
|
||||||
}}
|
}}
|
||||||
|
icon={Share}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Share} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
{#if comment.creator.id == profile.current.user?.local_user_view.person.id}
|
{#if comment.creator.id == profile.current.user?.local_user_view.person.id}
|
||||||
<MenuButton onclick={() => onedit?.(comment)}>
|
<MenuButton onclick={() => onedit?.(comment)} icon={PencilSquare}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={PencilSquare} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.edit')}
|
{$t('post.actions.more.edit')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -108,10 +100,8 @@
|
|||||||
if (profile.current?.jwt)
|
if (profile.current?.jwt)
|
||||||
comment.saved = await save(comment, !comment.saved)
|
comment.saved = await save(comment, !comment.saved)
|
||||||
}}
|
}}
|
||||||
|
icon={comment.saved ? BookmarkSlash : Bookmark}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current?.user && profile.current.jwt && profile.current.user.local_user_view.person.id == comment.creator.id}
|
{#if profile.current?.user && profile.current.jwt && profile.current.user.local_user_view.person.id == comment.creator.id}
|
||||||
@@ -124,20 +114,19 @@
|
|||||||
!comment.comment.deleted,
|
!comment.comment.deleted,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
|
icon={Trash}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Trash} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{comment.comment.deleted
|
{comment.comment.deleted
|
||||||
? $t('post.actions.more.restore')
|
? $t('post.actions.more.restore')
|
||||||
: $t('post.actions.more.delete')}
|
: $t('post.actions.more.delete')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current.jwt && profile.current.user?.local_user_view.person.id != comment.creator.id}
|
{#if profile.current.jwt && profile.current.user?.local_user_view.person.id != comment.creator.id}
|
||||||
<MenuButton onclick={() => report(comment)} color="danger-subtle">
|
<MenuButton
|
||||||
{#snippet prefix()}
|
onclick={() => report(comment)}
|
||||||
<Icon src={Flag} mini size="16" />
|
color="danger-subtle"
|
||||||
{/snippet}
|
icon={Flag}
|
||||||
|
>
|
||||||
{$t('moderation.report')}
|
{$t('moderation.report')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import Markdown from '$lib/components/markdown/Markdown.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 { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient, site } from '$lib/client/lemmy.svelte'
|
import { client, site } from '$lib/client/lemmy.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { placeholders } from '$lib/util.svelte.js'
|
import { placeholders } from '$lib/util.svelte.js'
|
||||||
import type { CommentResponse } from '$lib/client/types'
|
import type { CommentResponse } from '$lib/client/types'
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await getClient().createComment({
|
const response = await client().createComment({
|
||||||
content: value,
|
content: value,
|
||||||
post_id: postId,
|
post_id: postId,
|
||||||
parent_id: parentId,
|
parent_id: parentId,
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.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 { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import type { CommentView } from '$lib/client/types'
|
import type { CommentView } from '$lib/client/types'
|
||||||
import { Button, Material } from 'mono-svelte'
|
import { Button, Material } from 'mono-svelte'
|
||||||
import { ArrowUturnUp, Icon } from 'svelte-hero-icons'
|
import { ArrowUturnUp, Icon } from 'svelte-hero-icons'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
import { PostMeta } from '../post'
|
||||||
|
import { Comment } from '.'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
comment: CommentView
|
comment: CommentView
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new ResizeObserver(entries => {
|
const observer = new ResizeObserver((entries) => {
|
||||||
entries.forEach(entry => {
|
entries.forEach((entry) => {
|
||||||
if (offsetEl) {
|
if (offsetEl) {
|
||||||
initialOffset =
|
initialOffset =
|
||||||
entry.target.getBoundingClientRect().top + window.scrollY
|
entry.target.getBoundingClientRect().top + window.scrollY
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
||||||
<Comments
|
<Comments
|
||||||
bind:nodes={() => [nodes[index]], v => (nodes[index] = v[0])}
|
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
||||||
{post}
|
{post}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/state'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
|
||||||
import type { Post } from '$lib/client/types'
|
import type { Post } from '$lib/client/types'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { Button, toast } from 'mono-svelte'
|
import { Button, toast } from 'mono-svelte'
|
||||||
import { ArrowDownCircle, Icon } from 'svelte-hero-icons'
|
import { ArrowDownCircle } from 'svelte-hero-icons'
|
||||||
import Comment from './Comment.svelte'
|
import Comment from './Comment.svelte'
|
||||||
import Comments from './CommentTree.svelte'
|
import Comments from './CommentTree.svelte'
|
||||||
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
||||||
@@ -34,7 +33,7 @@
|
|||||||
try {
|
try {
|
||||||
parent.loading = true
|
parent.loading = true
|
||||||
|
|
||||||
const newComments = await getClient(page.params.instance).getComments({
|
const newComments = await client().getComments({
|
||||||
max_depth: 5,
|
max_depth: 5,
|
||||||
parent_id: parent.comment_view.comment.id,
|
parent_id: parent.comment_view.comment.id,
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
@@ -54,7 +53,7 @@
|
|||||||
// 0.18.2 -> 0.18.3 broke this
|
// 0.18.2 -> 0.18.3 broke this
|
||||||
// so i'm adding this check
|
// so i'm adding this check
|
||||||
const treeParent = tree.find(
|
const treeParent = tree.find(
|
||||||
c => c.comment_view.comment.id == parent.comment_view.comment.id,
|
(c) => c.comment_view.comment.id == parent.comment_view.comment.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (treeParent) {
|
if (treeParent) {
|
||||||
@@ -130,15 +129,8 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
icon={ArrowDownCircle}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon
|
|
||||||
src={ArrowDownCircle}
|
|
||||||
micro
|
|
||||||
size="16"
|
|
||||||
class="text-primary-900 dark:text-primary-100"
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
{$t('comment.more', {
|
{$t('comment.more', {
|
||||||
comments: node.comment_view.counts.child_count,
|
comments: node.comment_view.counts.child_count,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export { default as Comment } from './Comment.svelte'
|
||||||
|
export { default as CommentActions } from './CommentActions.svelte'
|
||||||
|
export { default as CommentForm } from './CommentForm.svelte'
|
||||||
|
export { default as CommentItem } from './CommentItem.svelte'
|
||||||
|
export { default as CommentListVirtualizer } from './CommentListVirtualizer.svelte'
|
||||||
|
export { default as CommentTree } from './CommentTree.svelte'
|
||||||
|
export { default as CommentVote } from './CommentVote.svelte'
|
||||||
|
|
||||||
|
export * from './comments.svelte'
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
@@ -139,7 +139,6 @@
|
|||||||
loading.subscribing = false
|
loading.subscribing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let setFlair = $state(false)
|
let setFlair = $state(false)
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -155,7 +154,6 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{#await community_view}
|
{#await community_view}
|
||||||
<div
|
<div
|
||||||
class="w-full h-full grid place-items-center"
|
class="w-full h-full grid place-items-center"
|
||||||
@@ -166,7 +164,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{:then community_view}
|
{:then community_view}
|
||||||
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
||||||
<CommunityFlair community={community_view.community.id} onsubmit={() => setFlair = !setFlair} />
|
<CommunityFlair
|
||||||
|
community={community_view.community.id}
|
||||||
|
onsubmit={() => (setFlair = !setFlair)}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
<aside
|
<aside
|
||||||
class={[
|
class={[
|
||||||
@@ -198,7 +199,7 @@
|
|||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
{@const subscribed = profile.current.user?.follows.some(
|
{@const subscribed = profile.current.user?.follows.some(
|
||||||
i => i.community.id == community_view.community.id,
|
(i) => i.community.id == community_view.community.id,
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
disabled={loading.subscribing}
|
disabled={loading.subscribing}
|
||||||
@@ -209,21 +210,15 @@
|
|||||||
onclick={() => subscribe(community_view)}
|
onclick={() => subscribe(community_view)}
|
||||||
class="px-4 relative z-[inherit]"
|
class="px-4 relative z-[inherit]"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
|
icon={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon
|
|
||||||
src={community_view.subscribed == 'Subscribed' ? Check : Plus}
|
|
||||||
mini
|
|
||||||
size="16"
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
{subscribed
|
{subscribed
|
||||||
? $t('cards.community.subscribed')
|
? $t('cards.community.subscribed')
|
||||||
: $t('cards.community.subscribe')}
|
: $t('cards.community.subscribe')}
|
||||||
</Button>
|
</Button>
|
||||||
{#if client().setFlair}
|
{#if client().setFlair}
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
onclick={() => setFlair = !setFlair}
|
onclick={() => (setFlair = !setFlair)}
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
icon={Tag}
|
icon={Tag}
|
||||||
label={$t('cards.community.flair')}
|
label={$t('cards.community.flair')}
|
||||||
@@ -269,10 +264,8 @@
|
|||||||
size="lg"
|
size="lg"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
block(community_view.community.id, !community_view.blocked)}
|
block(community_view.community.id, !community_view.blocked)}
|
||||||
|
icon={NoSymbol}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={NoSymbol} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{community_view.blocked
|
{community_view.blocked
|
||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
@@ -282,10 +275,8 @@
|
|||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
onclick={() => blockInstance(community_view.community.instance_id)}
|
onclick={() => blockInstance(community_view.community.instance_id)}
|
||||||
|
icon={BuildingOffice2}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={BuildingOffice2} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -312,10 +303,8 @@
|
|||||||
dismissable: true,
|
dismissable: true,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})}
|
})}
|
||||||
|
icon={Fire}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Fire} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -364,7 +353,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={moderators.map(i => ({
|
items={moderators.map((i) => ({
|
||||||
id: i.moderator.id,
|
id: i.moderator.id,
|
||||||
name: i.moderator.display_name || i.moderator.name,
|
name: i.moderator.display_name || i.moderator.name,
|
||||||
url: userLink(i.moderator),
|
url: userLink(i.moderator),
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import ImageInputUpload from '$lib/components/form/ImageInputUpload.svelte'
|
import ImageInputUpload from '$lib/components/form/ImageInputUpload.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient, site } from '$lib/client/lemmy.svelte'
|
import { client, site } from '$lib/client/lemmy.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
|
Label,
|
||||||
MenuButton,
|
MenuButton,
|
||||||
Switch,
|
Switch,
|
||||||
TextInput,
|
TextInput,
|
||||||
toast,
|
toast,
|
||||||
|
Option,
|
||||||
|
Select,
|
||||||
|
Material,
|
||||||
|
Menu,
|
||||||
} from 'mono-svelte'
|
} from 'mono-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 Menu from 'mono-svelte/popover/Menu.svelte'
|
|
||||||
import { GlobeAlt, Icon, MapPin, Plus } from 'svelte-hero-icons'
|
import { GlobeAlt, Icon, MapPin, Plus } from 'svelte-hero-icons'
|
||||||
|
import { Header } from '$lib/components/ui/layout'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = edit
|
const res = edit
|
||||||
? await getClient().editCommunity({
|
? await client().editCommunity({
|
||||||
title: formData.displayName,
|
title: formData.displayName,
|
||||||
description: formData.sidebar,
|
description: formData.sidebar,
|
||||||
nsfw: formData.nsfw,
|
nsfw: formData.nsfw,
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
visibility: formData.visibility,
|
visibility: formData.visibility,
|
||||||
discussion_languages: formData.languages,
|
discussion_languages: formData.languages,
|
||||||
})
|
})
|
||||||
: await getClient().createCommunity({
|
: await client().createCommunity({
|
||||||
name: formData.name,
|
name: formData.name,
|
||||||
title: formData.displayName,
|
title: formData.displayName,
|
||||||
description: formData.sidebar,
|
description: formData.sidebar,
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
if (profile.current.user) {
|
if (profile.current.user) {
|
||||||
const c = profile.current.user.moderates
|
const c = profile.current.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.current.user.moderates[c] = {
|
profile.current.user.moderates[c] = {
|
||||||
@@ -139,14 +139,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
class="flex flex-col gap-4 h-full w-full"
|
class="flex flex-col gap-4 h-full w-full"
|
||||||
>
|
>
|
||||||
{#if formtitle}{@render formtitle()}{:else}
|
{#if formtitle}{@render formtitle()}{:else}
|
||||||
<Header>{$t('routes.createCommunity')}</Header>
|
<Header>{$t('form.post.community')}</Header>
|
||||||
{/if}
|
{/if}
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
|
<Label>{$t('form.profile.languages.title')}</Label>
|
||||||
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
||||||
{#if site.data}
|
{#if site.data}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
</Badge>
|
</Badge>
|
||||||
</button>
|
</button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#each site.data.all_languages.filter(l => !formData.languages?.includes(l.id)) as language (language.id)}
|
{#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={() => {
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
{#each formData.languages ?? [] as languageId, index (languageId)}
|
{#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"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
import { formatRelativeDate } from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte'
|
import { fullCommunityName } from '$lib/util.svelte'
|
||||||
import type {
|
import type {
|
||||||
@@ -14,7 +14,15 @@
|
|||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
SubscribedType,
|
SubscribedType,
|
||||||
} from '$lib/client/types'
|
} from '$lib/client/types'
|
||||||
import { action, Button, Menu, MenuButton, Modal, modal, toast } from 'mono-svelte'
|
import {
|
||||||
|
action,
|
||||||
|
Button,
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
Modal,
|
||||||
|
modal,
|
||||||
|
toast,
|
||||||
|
} from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
BuildingOffice2,
|
BuildingOffice2,
|
||||||
Check,
|
Check,
|
||||||
@@ -61,9 +69,11 @@
|
|||||||
let setFlair = $state(false)
|
let setFlair = $state(false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
<Modal title={$t('cards.community.flair')} bind:open={setFlair}>
|
||||||
<CommunityFlair community={community.id} onsubmit={() => setFlair = !setFlair} />
|
<CommunityFlair
|
||||||
|
community={community.id}
|
||||||
|
onsubmit={() => (setFlair = !setFlair)}
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<EntityHeader
|
<EntityHeader
|
||||||
@@ -119,7 +129,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),
|
||||||
@@ -129,7 +139,12 @@
|
|||||||
/>
|
/>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
<div class={["flex items-center gap-2 h-max w-max", compact == 'lg' && 'lg:hidden']}>
|
<div
|
||||||
|
class={[
|
||||||
|
'flex items-center gap-2 h-max w-max',
|
||||||
|
compact == 'lg' && 'lg:hidden',
|
||||||
|
]}
|
||||||
|
>
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
<Subscribe
|
<Subscribe
|
||||||
community={{
|
community={{
|
||||||
@@ -152,14 +167,8 @@
|
|||||||
}}
|
}}
|
||||||
class="relative z-[inherit]"
|
class="relative z-[inherit]"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
icon={subscribed != 'NotSubscribed' ? Check : Plus}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon
|
|
||||||
src={subscribed != 'NotSubscribed' ? Check : Plus}
|
|
||||||
micro
|
|
||||||
size="16"
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
{subscribed == 'Subscribed' || subscribed == 'Pending'
|
{subscribed == 'Subscribed' || subscribed == 'Pending'
|
||||||
? $t('cards.community.subscribed')
|
? $t('cards.community.subscribed')
|
||||||
: $t('cards.community.subscribe')}
|
: $t('cards.community.subscribe')}
|
||||||
@@ -167,13 +176,19 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Subscribe>
|
</Subscribe>
|
||||||
|
|
||||||
<Button size="custom" class="h-9 aspect-square" rounding="pill" onclick={() => setFlair = !setFlair} aria-label={$t('cards.community.flair')}>
|
<Button
|
||||||
|
size="custom"
|
||||||
|
class="h-9 aspect-square"
|
||||||
|
rounding="pill"
|
||||||
|
onclick={() => (setFlair = !setFlair)}
|
||||||
|
aria-label={$t('cards.community.flair')}
|
||||||
|
>
|
||||||
<Icon src={Tag} size="16" micro />
|
<Icon src={Tag} size="16" micro />
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if profile.current?.user && profile.current.user.moderates
|
{#if profile.current?.user && profile.current.user.moderates
|
||||||
.map(c => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(community.id)}
|
.includes(community.id)}
|
||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@@ -190,11 +205,13 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<Menu placement="top-end">
|
<Menu placement="top-end">
|
||||||
{#snippet target(attachment)}
|
{#snippet target(attachment)}
|
||||||
<Button {@attach attachment} size="custom" rounding="pill" class="h-8.5 aspect-square">
|
<Button
|
||||||
{#snippet prefix()}
|
{@attach attachment}
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
size="custom"
|
||||||
{/snippet}
|
rounding="pill"
|
||||||
</Button>
|
class="h-8.5 aspect-square"
|
||||||
|
icon={EllipsisHorizontal}
|
||||||
|
></Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuButton href="/modlog?community={community.id}">
|
<MenuButton href="/modlog?community={community.id}">
|
||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
@@ -214,10 +231,8 @@
|
|||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
onclick={() => block(community.id, !blocked)}
|
onclick={() => block(community.id, !blocked)}
|
||||||
|
icon={NoSymbol}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={NoSymbol} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{blocked
|
{blocked
|
||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
@@ -227,10 +242,8 @@
|
|||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
onclick={() => blockInstance(community.instance_id)}
|
onclick={() => blockInstance(community.instance_id)}
|
||||||
|
icon={BuildingOffice2}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={BuildingOffice2} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -257,10 +270,8 @@
|
|||||||
dismissable: true,
|
dismissable: true,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})}
|
})}
|
||||||
|
icon={Fire}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Fire} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
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 Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
@@ -8,7 +7,7 @@
|
|||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
import type { CommunityView } from '$lib/client/types'
|
import type { CommunityView } from '$lib/client/types'
|
||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
|
import { CommunityCard } from '.'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community: CommunityView
|
community: CommunityView
|
||||||
@@ -158,7 +158,9 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Subscribe {community}>
|
<Subscribe {community}>
|
||||||
{#snippet children({ subscribe, subscribing })}
|
{#snippet children({ subscribe, subscribing })}
|
||||||
{@const subscribed = isSubscribed(community.subscribed)}
|
{@const subscribed =
|
||||||
|
community.subscribed == 'Subscribed' ||
|
||||||
|
community.subscribed == 'Pending'}
|
||||||
<Button
|
<Button
|
||||||
disabled={subscribing || !profile.current?.jwt}
|
disabled={subscribing || !profile.current?.jwt}
|
||||||
loading={subscribing}
|
loading={subscribing}
|
||||||
@@ -199,10 +201,8 @@
|
|||||||
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
|
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
|
||||||
: 'px-3',
|
: 'px-3',
|
||||||
]}
|
]}
|
||||||
|
icon={subscribed ? Check : Plus}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={subscribed ? Check : Plus} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
<span class={[view == 'compact' && 'hidden', '@md:block']}>
|
<span class={[view == 'compact' && 'hidden', '@md:block']}>
|
||||||
{#if subscribed}
|
{#if subscribed}
|
||||||
{$t('cards.community.subscribed')}
|
{$t('cards.community.subscribed')}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { communityLink } from '$lib/lemmy/generic'
|
import { communityLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import type { Community } from '$lib/client/types'
|
import type { Community } from '$lib/client/types'
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export { default as CommunityCard } from './CommunityCard.svelte'
|
||||||
|
export { default as CommunityFlair } from './CommunityFlair.svelte'
|
||||||
|
export { default as CommunityForm } from './CommunityForm.svelte'
|
||||||
|
export { default as CommunityHeader } from './CommunityHeader.svelte'
|
||||||
|
export { default as CommunityItem } from './CommunityItem.svelte'
|
||||||
|
export { default as CommunityLink } from './CommunityLink.svelte'
|
||||||
|
export { default as CommunityTitle } from './CommunityTitle.svelte'
|
||||||
+11
-11
@@ -2,7 +2,7 @@
|
|||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { PersonView, SiteView, Tagline } from '$lib/client/types'
|
import type { PersonView, SiteView, Tagline } from '$lib/client/types'
|
||||||
import { Badge } from 'mono-svelte'
|
import { Badge } from 'mono-svelte'
|
||||||
@@ -13,18 +13,18 @@
|
|||||||
ServerStack,
|
ServerStack,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
|
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
|
||||||
import EndPlaceholder from '../ui/EndPlaceholder.svelte'
|
import EndPlaceholder from '../../ui/EndPlaceholder.svelte'
|
||||||
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 SidebarButton from '../ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '../../ui/sidebar/SidebarButton.svelte'
|
||||||
import ItemList from './generic/ItemList.svelte'
|
import ItemList from '../generic/ItemList.svelte'
|
||||||
import { optimizeImageURL } from './post/helpers'
|
import { optimizeImageURL } from '../post/helpers'
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<HTMLDivElement> {
|
interface Props extends HTMLAttributes<HTMLDivElement> {
|
||||||
site: SiteView
|
site: SiteView
|
||||||
taglines?: Tagline[] | undefined
|
taglines?: Tagline[]
|
||||||
admins?: PersonView[] | undefined
|
admins?: PersonView[]
|
||||||
version?: string | undefined
|
version?: string
|
||||||
class?: ClassValue
|
class?: ClassValue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={admins.map(i => ({
|
items={admins.map((i) => ({
|
||||||
id: i.person.id,
|
id: i.person.id,
|
||||||
name: i.person.display_name || i.person.name,
|
name: i.person.display_name || i.person.name,
|
||||||
url: userLink(i.person),
|
url: userLink(i.person),
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import type { Person } from '$lib/client/types'
|
|
||||||
import { Button, Modal, toast } from 'mono-svelte'
|
|
||||||
import { Icon, PaperAirplane } from 'svelte-hero-icons'
|
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
open?: boolean
|
|
||||||
user: Person
|
|
||||||
}
|
|
||||||
|
|
||||||
let { open = $bindable(false), user }: Props = $props()
|
|
||||||
|
|
||||||
let message = $state('')
|
|
||||||
|
|
||||||
let loading = $state(false)
|
|
||||||
|
|
||||||
async function sendMessage() {
|
|
||||||
if (!profile.current?.jwt || message == '') return
|
|
||||||
|
|
||||||
loading = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
await getClient().createPrivateMessage({
|
|
||||||
content: message,
|
|
||||||
recipient_id: user.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
toast({
|
|
||||||
content: $t('toast.sentMessage'),
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
|
|
||||||
open = false
|
|
||||||
} catch (err) {
|
|
||||||
toast({
|
|
||||||
content: errorMessage(err as string),
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:open>
|
|
||||||
{#snippet customTitle()}
|
|
||||||
<h1 class="text-2xl font-bold">Message</h1>
|
|
||||||
{/snippet}
|
|
||||||
<form onsubmit={preventDefault(sendMessage)} class="flex flex-col gap-4">
|
|
||||||
<p class="inline-flex flex-row gap-2 items-center">
|
|
||||||
<Icon src={PaperAirplane} size="16" mini />
|
|
||||||
<UserLink avatar {user} />
|
|
||||||
</p>
|
|
||||||
<MarkdownEditor
|
|
||||||
bind:value={message}
|
|
||||||
label={$t('content.message')}
|
|
||||||
rows={4}
|
|
||||||
/>
|
|
||||||
<Button color="primary" size="lg" submit {loading} disabled={loading}>
|
|
||||||
{$t('common.send')}
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</Modal>
|
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
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 } from '$lib/client/types'
|
import type { Community, Person } from '$lib/client/types'
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import { Label, toast, Button, Modal, Switch } from 'mono-svelte'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
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 Duration from '$lib/components/form/Duration.svelte'
|
import Duration from '$lib/components/form/Duration.svelte'
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import { CommunityLink } from '../community'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean
|
open?: boolean
|
||||||
@@ -57,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (community) {
|
if (community) {
|
||||||
await getClient().banFromCommunity({
|
await client().banFromCommunity({
|
||||||
ban: !banned,
|
ban: !banned,
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
person_id: item.id,
|
person_id: item.id,
|
||||||
@@ -66,7 +62,7 @@
|
|||||||
expires: date,
|
expires: date,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await getClient().banPerson({
|
await client().banPerson({
|
||||||
ban: !banned,
|
ban: !banned,
|
||||||
person_id: item.id,
|
person_id: item.id,
|
||||||
reason: reason || undefined,
|
reason: reason || undefined,
|
||||||
@@ -99,7 +95,13 @@
|
|||||||
title={banned ? $t('moderation.ban.unbanning') : $t('moderation.ban.banning')}
|
title={banned ? $t('moderation.ban.unbanning') : $t('moderation.ban.banning')}
|
||||||
>
|
>
|
||||||
{#if item}
|
{#if item}
|
||||||
<form class="flex flex-col gap-4" onsubmit={preventDefault(submit)}>
|
<form
|
||||||
|
class="flex flex-col gap-4"
|
||||||
|
onsubmit={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
submit()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<Avatar url={item.avatar} alt={item.name} width={24} />
|
<Avatar url={item.avatar} alt={item.name} width={24} />
|
||||||
<span class="font-bold">{item.name}</span>
|
<span class="font-bold">{item.name}</span>
|
||||||
@@ -113,16 +115,15 @@
|
|||||||
label={$t('moderation.reason')}
|
label={$t('moderation.reason')}
|
||||||
/>
|
/>
|
||||||
{#if !banned}
|
{#if !banned}
|
||||||
<Checkbox bind:checked={deleteData}>
|
<Switch bind:checked={deleteData}>
|
||||||
{$t('moderation.ban.deleteData')}
|
{$t('moderation.ban.deleteData')}
|
||||||
{#snippet description()}
|
{#snippet description()}
|
||||||
{$t('moderation.ban.warning')}
|
{$t('moderation.ban.warning')}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Checkbox>
|
</Switch>
|
||||||
<div>
|
<Label text={$t('moderation.ban.expires')}>
|
||||||
<SectionTitle>{$t('moderation.ban.expires')}</SectionTitle>
|
|
||||||
<Duration bind:value={expires}></Duration>
|
<Duration bind:value={expires}></Duration>
|
||||||
</div>
|
</Label>
|
||||||
{/if}
|
{/if}
|
||||||
<Button submit color="primary" {loading} disabled={loading} size="lg">
|
<Button submit color="primary" {loading} disabled={loading} size="lg">
|
||||||
{$t('form.submit')}
|
{$t('form.submit')}
|
||||||
|
|||||||
@@ -43,10 +43,7 @@
|
|||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
{/if}
|
{/if}
|
||||||
</MenuDivider>
|
</MenuDivider>
|
||||||
<MenuButton color="danger-subtle" onclick={() => remove(item)}>
|
<MenuButton color="danger-subtle" onclick={() => remove(item)} icon={Trash}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Trash} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{#if isCommentView(item)}
|
{#if isCommentView(item)}
|
||||||
{item.comment.removed
|
{item.comment.removed
|
||||||
? $t('moderation.restore')
|
? $t('moderation.restore')
|
||||||
@@ -59,10 +56,8 @@
|
|||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||||
|
icon={ShieldExclamation}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ShieldExclamation} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{item.creator_banned_from_community
|
{item.creator_banned_from_community
|
||||||
? $t('moderation.ban.unbanFromCommunity')
|
? $t('moderation.ban.unbanFromCommunity')
|
||||||
: $t('moderation.ban.banFromCommunity')}
|
: $t('moderation.ban.banFromCommunity')}
|
||||||
@@ -81,10 +76,8 @@
|
|||||||
)
|
)
|
||||||
).comment_view.comment
|
).comment_view.comment
|
||||||
}}
|
}}
|
||||||
|
icon={Megaphone}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Megaphone} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{item.comment.distinguished
|
{item.comment.distinguished
|
||||||
? $t('moderation.unfeature')
|
? $t('moderation.unfeature')
|
||||||
: $t('moderation.feature')}
|
: $t('moderation.feature')}
|
||||||
@@ -107,10 +100,11 @@
|
|||||||
|
|
||||||
{#if profile.current?.user && isAdmin(profile.current.user)}
|
{#if profile.current?.user && isAdmin(profile.current.user)}
|
||||||
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
<MenuDivider showLabel>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
|
<MenuButton
|
||||||
{#snippet prefix()}
|
color="danger-subtle"
|
||||||
<Icon src={Fire} size="16" mini />
|
onclick={() => remove(item, true)}
|
||||||
{/snippet}
|
icon={Fire}
|
||||||
|
>
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -91,10 +91,8 @@
|
|||||||
color="warning-subtle"
|
color="warning-subtle"
|
||||||
onclick={() => lock(!item.post.locked)}
|
onclick={() => lock(!item.post.locked)}
|
||||||
loading={acting}
|
loading={acting}
|
||||||
|
icon={item.post.locked ? LockOpen : LockClosed}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={item.post.locked ? LockOpen : LockClosed} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{item.post.locked ? $t('moderation.unlock') : $t('moderation.lock')}
|
{item.post.locked ? $t('moderation.unlock') : $t('moderation.lock')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,22 @@
|
|||||||
import { preventDefault, run } from 'svelte/legacy'
|
import { preventDefault, run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
import { getClient } from '$lib/client/lemmy.svelte'
|
||||||
|
import type { CommentView, PostView } from '$lib/client/types'
|
||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
|
||||||
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
|
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import Post from '$lib/components/lemmy/post/Post.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 { getClient } from '$lib/client/lemmy.svelte'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
import { isCommentView, isPostView } from '$lib/lemmy/item.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 type { CommentView, PostView } from '$lib/client/types'
|
|
||||||
import { Button, Modal, Select, Switch, toast } from 'mono-svelte'
|
import { Button, Modal, Select, Switch, toast } from 'mono-svelte'
|
||||||
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 { Fire, Trash } from 'svelte-hero-icons'
|
||||||
|
import { Comment } from '../comment'
|
||||||
|
import { Post } from '../post'
|
||||||
import { amMod, isAdmin } from './moderation'
|
import { amMod, isAdmin } from './moderation'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
@@ -257,10 +257,8 @@
|
|||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
submit
|
submit
|
||||||
|
icon={purge ? Fire : Trash}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={purge ? Fire : Trash} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{#if purge}
|
{#if purge}
|
||||||
{$t('admin.purge')}
|
{$t('admin.purge')}
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
import { preventDefault, run } from 'svelte/legacy'
|
import { preventDefault, run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
|
||||||
import Post from '$lib/components/lemmy/post/Post.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 { getClient } from '$lib/client/lemmy.svelte'
|
import { getClient } from '$lib/client/lemmy.svelte'
|
||||||
@@ -15,6 +13,8 @@
|
|||||||
import { Button, Modal, toast } from 'mono-svelte'
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
|
import { Post } from '../post'
|
||||||
|
import { Comment } from '../comment'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean
|
open: boolean
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
if (isPostView(item))
|
if (isPostView(item))
|
||||||
return await client()
|
return await client()
|
||||||
.listPostLikes({ post_id: item.post.id, limit: 50, page: page })
|
.listPostLikes({ post_id: item.post.id, limit: 50, page: page })
|
||||||
.then(i => i.post_likes)
|
.then((i) => i.post_likes)
|
||||||
if (isCommentView(item))
|
if (isCommentView(item))
|
||||||
return await client()
|
return await client()
|
||||||
.listCommentLikes({
|
.listCommentLikes({
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
limit: 50,
|
limit: 50,
|
||||||
page: page,
|
page: page,
|
||||||
})
|
})
|
||||||
.then(i => i.comment_likes)
|
.then((i) => i.comment_likes)
|
||||||
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import type {
|
import type {
|
||||||
|
Comment,
|
||||||
CommentView,
|
CommentView,
|
||||||
Community,
|
Community,
|
||||||
MyUserInfo,
|
MyUserInfo,
|
||||||
@@ -55,7 +56,7 @@ export const 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,
|
||||||
@@ -65,7 +66,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,
|
||||||
@@ -76,7 +77,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,
|
||||||
@@ -95,7 +96,7 @@ export async function feature(featured: boolean, item: Comment, jwt: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function viewVotes(item: PostView | CommentView) {
|
export async function viewVotes(item: PostView | CommentView) {
|
||||||
modals.update(m => ({
|
modals.update((m) => ({
|
||||||
...m,
|
...m,
|
||||||
votes: {
|
votes: {
|
||||||
open: true,
|
open: true,
|
||||||
@@ -105,7 +106,7 @@ export async function viewVotes(item: PostView | CommentView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) =>
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import PostActions from '$lib/components/lemmy/post/actions/PostActions.svelte'
|
|
||||||
import { mediaType } 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 PostMeta, {
|
|
||||||
parseTags,
|
|
||||||
type Tag,
|
|
||||||
} 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, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import type { PostView } from '$lib/client/types'
|
import type { PostView } from '$lib/client/types'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
import PostBody from './PostBody.svelte'
|
import {
|
||||||
|
type Tag,
|
||||||
|
PostMeta,
|
||||||
|
PostActions,
|
||||||
|
PostMedia,
|
||||||
|
PostBody,
|
||||||
|
parseTags,
|
||||||
|
mediaType,
|
||||||
|
PostMediaCompact,
|
||||||
|
} from '.'
|
||||||
|
|
||||||
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))
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
published={publishedToDate(post.post.published)}
|
published={publishedToDate(post.post.published)}
|
||||||
{badges}
|
{badges}
|
||||||
subscribed={profile.current?.user?.follows
|
subscribed={profile.current?.user?.follows
|
||||||
.map(c => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
? 'Subscribed'
|
? 'Subscribed'
|
||||||
: 'NotSubscribed'}
|
: 'NotSubscribed'}
|
||||||
|
|||||||
@@ -54,9 +54,11 @@ dark:from-zinc-400 dark:via-zinc-400 bg-clip-text z-0 max-h-36`
|
|||||||
onclick={() => (expanded = !expanded)}
|
onclick={() => (expanded = !expanded)}
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
class="text-black dark:text-white absolute z-10 isolate pointer-events-auto bottom-0 {expanded
|
class={[
|
||||||
? 'bg-slate-200/50 dark:bg-zinc-900 border shadow-md'
|
'text-black dark:text-white absolute z-10 isolate pointer-events-auto bottom-0',
|
||||||
: ''} left-1/2 -translate-x-1/2 mb-4"
|
'left-1/2 -translate-x-1/2 mb-4',
|
||||||
|
expanded && 'bg-slate-200/50 dark:bg-zinc-900 shadow-md',
|
||||||
|
]}
|
||||||
title="Expand"
|
title="Expand"
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PostView } from '$lib/client/types'
|
import type { PostView } from '$lib/client/types'
|
||||||
import Post from './Post.svelte'
|
import { Post } from '.'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: PostView
|
post: PostView
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
<script lang="ts" module>
|
<script lang="ts" module>
|
||||||
|
type BadgeType =
|
||||||
|
| 'nsfw'
|
||||||
|
| 'saved'
|
||||||
|
| 'featured'
|
||||||
|
| 'deleted'
|
||||||
|
| 'removed'
|
||||||
|
| 'locked'
|
||||||
|
| 'moderator'
|
||||||
|
| 'admin'
|
||||||
export interface Tag {
|
export interface Tag {
|
||||||
content: string
|
content: string
|
||||||
color?: string
|
color?: string
|
||||||
@@ -11,6 +20,64 @@
|
|||||||
['CW', { content: 'CW', color: '#ff000040' }],
|
['CW', { content: 'CW', color: '#ff000040' }],
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const badgeToData: Map<
|
||||||
|
BadgeType,
|
||||||
|
{
|
||||||
|
icon: IconSource
|
||||||
|
color: 'red-subtle' | 'yellow-subtle' | 'green-subtle'
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
> = new Map([
|
||||||
|
[
|
||||||
|
'nsfw',
|
||||||
|
{
|
||||||
|
icon: ExclamationTriangle,
|
||||||
|
color: 'red-subtle',
|
||||||
|
label: t.get('post.badges.nsfw'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'saved',
|
||||||
|
{
|
||||||
|
icon: Bookmark,
|
||||||
|
color: 'yellow-subtle',
|
||||||
|
label: t.get('post.badges.saved'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'featured',
|
||||||
|
{
|
||||||
|
icon: Megaphone,
|
||||||
|
color: 'green-subtle',
|
||||||
|
label: t.get('post.badges.featured'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'removed',
|
||||||
|
{
|
||||||
|
icon: Trash,
|
||||||
|
color: 'green-subtle',
|
||||||
|
label: t.get('post.badges.removed'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'deleted',
|
||||||
|
{
|
||||||
|
icon: Trash,
|
||||||
|
color: 'red-subtle',
|
||||||
|
label: t.get('post.badges.deleted'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'locked',
|
||||||
|
{
|
||||||
|
icon: LockClosed,
|
||||||
|
color: 'yellow-subtle',
|
||||||
|
label: t.get('post.badges.locked'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
])
|
||||||
|
|
||||||
export const parseTags = (
|
export const parseTags = (
|
||||||
title?: string,
|
title?: string,
|
||||||
): { tags: Tag[]; title?: string } => {
|
): { tags: Tag[]; title?: string } => {
|
||||||
@@ -20,11 +87,11 @@
|
|||||||
|
|
||||||
const newTitle = title
|
const newTitle = title
|
||||||
.toString()
|
.toString()
|
||||||
.replace(/^(\[.[^\]]+\])|(\[.[^\]]+\])$/g, match => {
|
.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) ?? {
|
||||||
@@ -43,7 +110,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import type { Community, Person, SubscribedType } from '$lib/client/types'
|
||||||
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 Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
@@ -52,10 +120,8 @@
|
|||||||
formatRelativeDate,
|
formatRelativeDate,
|
||||||
} from '$lib/components/util/RelativeDate.svelte'
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { instance } from '$lib/instance.svelte'
|
|
||||||
import { settings, type View } from '$lib/settings.svelte'
|
import { settings, type View } from '$lib/settings.svelte'
|
||||||
import type { Community, Person, SubscribedType } from '$lib/client/types'
|
import { Badge, Material, modal, Popover } from 'mono-svelte'
|
||||||
import { Badge, modal, Popover } from 'mono-svelte'
|
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
@@ -69,7 +135,7 @@
|
|||||||
Trash,
|
Trash,
|
||||||
type IconSource,
|
type IconSource,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Material from 'mono-svelte/materials/Material.svelte'
|
import { CommunityLink } from '../community'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community?: Community
|
community?: Community
|
||||||
@@ -83,16 +149,7 @@
|
|||||||
edited?: string
|
edited?: string
|
||||||
view?: View
|
view?: View
|
||||||
// Badges
|
// Badges
|
||||||
badges?: {
|
badges?: Record<BadgeType, boolean>
|
||||||
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
|
||||||
@@ -274,66 +331,18 @@
|
|||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
{#if badges.nsfw}
|
{#each Object.keys(badges)
|
||||||
<Badge label={$t('post.badges.nsfw')} color="red-subtle" allowIconOnly>
|
// filter by ones that are true
|
||||||
{#snippet icon()}
|
.filter((i) => badges[i as BadgeType] == true)
|
||||||
<Icon src={ExclamationTriangle} size="14" micro />
|
// get from predetermined map
|
||||||
{/snippet}
|
.map((i) => badgeToData.get(i as BadgeType))
|
||||||
{$t('post.badges.nsfw')}
|
// remove null
|
||||||
|
.filter((i) => i != undefined) as badge}
|
||||||
|
<Badge label={badge.label} color={badge.color} allowIconOnly
|
||||||
|
>{#snippet icon()}
|
||||||
|
<Icon src={badge.icon} micro size="14" />{/snippet}{badge.label}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/each}
|
||||||
{#if badges.saved}
|
|
||||||
<Badge
|
|
||||||
label={$t('post.badges.saved')}
|
|
||||||
color="yellow-subtle"
|
|
||||||
allowIconOnly
|
|
||||||
>
|
|
||||||
{#snippet icon()}
|
|
||||||
<Icon src={Bookmark} micro size="14" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.badges.saved')}
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
|
||||||
{#if badges.locked}
|
|
||||||
<Badge
|
|
||||||
label={$t('post.badges.locked')}
|
|
||||||
color="yellow-subtle"
|
|
||||||
allowIconOnly
|
|
||||||
>
|
|
||||||
{#snippet icon()}
|
|
||||||
<Icon src={LockClosed} micro size="14" />
|
|
||||||
{/snippet}
|
|
||||||
<span class="max-md:hidden">{$t('post.badges.locked')}</span>
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
|
||||||
{#if badges.removed}
|
|
||||||
<Badge label={$t('post.badges.removed')} color="red-subtle" allowIconOnly>
|
|
||||||
{#snippet icon()}
|
|
||||||
<Icon src={Trash} micro size="14" />
|
|
||||||
{/snippet}
|
|
||||||
<span class="max-md:hidden">{$t('post.badges.removed')}</span>
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
|
||||||
{#if badges.deleted}
|
|
||||||
<Badge label={$t('post.badges.deleted')} color="red-subtle" allowIconOnly>
|
|
||||||
{#snippet icon()}
|
|
||||||
<Icon src={Trash} micro size="14" />
|
|
||||||
{/snippet}
|
|
||||||
<span class="max-md:hidden">{$t('post.badges.deleted')}</span>
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
|
||||||
{#if badges.featured}
|
|
||||||
<Badge
|
|
||||||
label={$t('post.badges.featured')}
|
|
||||||
color="green-subtle"
|
|
||||||
allowIconOnly
|
|
||||||
>
|
|
||||||
{#snippet icon()}
|
|
||||||
<Icon src={Megaphone} micro size="14" />
|
|
||||||
{/snippet}
|
|
||||||
<span class="max-md:hidden">{$t('post.badges.featured')}</span>
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
|
||||||
{@render extraBadges?.()}
|
{@render extraBadges?.()}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -341,8 +350,7 @@
|
|||||||
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
|
{@const useAttachedUrl = settings.posts.titleOpensUrl && postUrl}
|
||||||
<h3
|
<h3
|
||||||
class={[
|
class={[
|
||||||
'max-sm:m-0!',
|
'font-medium max-sm:mt-0!',
|
||||||
'font-medium',
|
|
||||||
titleClass,
|
titleClass,
|
||||||
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
settings.markReadPosts && read && 'text-slate-600 dark:text-zinc-400',
|
||||||
view == 'compact' ? 'text-base' : 'text-lg',
|
view == 'compact' ? 'text-base' : 'text-lg',
|
||||||
@@ -352,10 +360,8 @@
|
|||||||
<a
|
<a
|
||||||
href={useAttachedUrl
|
href={useAttachedUrl
|
||||||
? postUrl
|
? postUrl
|
||||||
: `/post/${encodeURIComponent(instance.data)}/${id}`}
|
: `/post/${encodeURIComponent(profile.current.instance)}/${id}`}
|
||||||
target={useAttachedUrl
|
target={useAttachedUrl ? '_blank' : undefined}
|
||||||
? '_blank'
|
|
||||||
: undefined}
|
|
||||||
rel={useAttachedUrl ? 'noopener noreferrer' : undefined}
|
rel={useAttachedUrl ? 'noopener noreferrer' : undefined}
|
||||||
class="inline-block hover:underline hover:text-primary-900 dark:hover:text-primary-100 transition-colors"
|
class="inline-block hover:underline hover:text-primary-900 dark:hover:text-primary-100 transition-colors"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@
|
|||||||
vote = newVote
|
vote = newVote
|
||||||
|
|
||||||
voteItem(post, newVote)
|
voteItem(post, newVote)
|
||||||
.then(res => ({ upvotes, downvotes, score } = res))
|
.then((res) => ({ upvotes, downvotes, score } = res))
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
toast({ content: errorMessage(e), type: 'error' })
|
toast({ content: errorMessage(e), type: 'error' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { postLink } from '../helpers'
|
import { postLink } from '../helpers'
|
||||||
import PostVote from '../PostVote.svelte'
|
import { PostVote } from '..'
|
||||||
|
|
||||||
let saving = $state(false)
|
let saving = $state(false)
|
||||||
let editing = $state(false)
|
let editing = $state(false)
|
||||||
@@ -61,7 +61,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)
|
||||||
@@ -124,11 +124,8 @@
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
>
|
icon={BugAnt}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={BugAnt} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
|
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
|
||||||
{#await import('$lib/components/lemmy/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
{#await import('$lib/components/lemmy/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
||||||
@@ -164,11 +161,8 @@
|
|||||||
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')}
|
||||||
>
|
icon={post.saved ? BookmarkSlash : Bookmark}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={post.saved ? BookmarkSlash : Bookmark} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
@@ -180,11 +174,8 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="custom"
|
size="custom"
|
||||||
class={buttonSquare}
|
class={buttonSquare}
|
||||||
>
|
icon={EllipsisHorizontal}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet children(open)}
|
{#snippet children(open)}
|
||||||
{#if open}
|
{#if open}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
|
import { PiefedClient } from '$lib/client/piefed/piefed'
|
||||||
|
import type { PostView } from '$lib/client/types'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { deleteItem, markAsRead } from '$lib/lemmy/contentview'
|
import { deleteItem, markAsRead } from '$lib/lemmy/contentview'
|
||||||
import { setSessionStorage } from '$lib/session'
|
import { setSessionStorage } from '$lib/session'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { instanceToURL } from '$lib/util.svelte'
|
import { instanceToURL } from '$lib/util.svelte'
|
||||||
import type { PostView } from '$lib/client/types'
|
|
||||||
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ArrowTopRightOnSquare,
|
ArrowTopRightOnSquare,
|
||||||
@@ -15,7 +17,6 @@
|
|||||||
EyeSlash,
|
EyeSlash,
|
||||||
Flag,
|
Flag,
|
||||||
GlobeAlt,
|
GlobeAlt,
|
||||||
Icon,
|
|
||||||
MapPin,
|
MapPin,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
Share,
|
Share,
|
||||||
@@ -24,8 +25,6 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { report } from '../../moderation/moderation'
|
import { report } from '../../moderation/moderation'
|
||||||
import { hidePost } from '../helpers'
|
import { hidePost } from '../helpers'
|
||||||
import { client } from '$lib/client/lemmy.svelte'
|
|
||||||
import { PiefedClient } from '$lib/client/piefed/piefed'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: PostView
|
post: PostView
|
||||||
@@ -52,10 +51,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton onclick={() => (editing = true)}>
|
<MenuButton onclick={() => (editing = true)} icon={PencilSquare}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={PencilSquare} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.edit')}
|
{$t('post.actions.more.edit')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -65,10 +61,8 @@
|
|||||||
if (profile.current?.jwt)
|
if (profile.current?.jwt)
|
||||||
post.read = await markAsRead(post.post, !post.read)
|
post.read = await markAsRead(post.post, !post.read)
|
||||||
}}
|
}}
|
||||||
|
icon={post.read ? EyeSlash : Eye}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={post.read ? EyeSlash : Eye} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{post.read
|
{post.read
|
||||||
? $t('post.actions.more.markUnread')
|
? $t('post.actions.more.markUnread')
|
||||||
: $t('post.actions.more.markRead')}
|
: $t('post.actions.more.markRead')}
|
||||||
@@ -78,10 +72,8 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => share()}
|
onclick={() => share()}
|
||||||
class={['flex-1', !post.post.local && 'rounded-r-lg']}
|
class={['flex-1', !post.post.local && 'rounded-r-lg']}
|
||||||
|
icon={Share}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Share} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if !post.post.local}
|
{#if !post.post.local}
|
||||||
@@ -94,27 +86,13 @@
|
|||||||
size="custom"
|
size="custom"
|
||||||
class="w-6 h-6 self-center"
|
class="w-6 h-6 self-center"
|
||||||
data-autoclose="false"
|
data-autoclose="false"
|
||||||
>
|
icon={EllipsisHorizontal}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon
|
|
||||||
src={EllipsisHorizontal}
|
|
||||||
size="16"
|
|
||||||
micro
|
|
||||||
class="text-slate-600 dark:text-zinc-400"
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
<MenuButton onclick={() => share(true)}>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={GlobeAlt} size="16" micro />
|
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
<MenuButton onclick={() => share(true)} icon={GlobeAlt}>
|
||||||
{$t('filter.location.global')}
|
{$t('filter.location.global')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton onclick={() => share(false)}>
|
<MenuButton onclick={() => share(false)} icon={MapPin}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={MapPin} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('filter.location.local')}
|
{$t('filter.location.local')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
@@ -141,10 +119,8 @@
|
|||||||
|
|
||||||
goto('/create/post?crosspost=true')
|
goto('/create/post?crosspost=true')
|
||||||
}}
|
}}
|
||||||
|
icon={ArrowTopRightOnSquare}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ArrowTopRightOnSquare} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.crosspost')}
|
{$t('post.actions.more.crosspost')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if profile.current.user && post.creator.id == profile.current.user.local_user_view.person.id}
|
{#if profile.current.user && post.creator.id == profile.current.user.local_user_view.person.id}
|
||||||
@@ -154,10 +130,8 @@
|
|||||||
post.post.deleted = await deleteItem(post, !post.post.deleted)
|
post.post.deleted = await deleteItem(post, !post.post.deleted)
|
||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
|
icon={Trash}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Trash} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{post.post.deleted
|
{post.post.deleted
|
||||||
? $t('post.actions.more.restore')
|
? $t('post.actions.more.restore')
|
||||||
: $t('post.actions.more.delete')}
|
: $t('post.actions.more.delete')}
|
||||||
@@ -177,19 +151,14 @@
|
|||||||
if (hidden) onhide?.(hidden)
|
if (hidden) onhide?.(hidden)
|
||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
|
icon={XMark}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={XMark} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{post.hidden
|
{post.hidden
|
||||||
? $t('post.actions.more.unhide')
|
? $t('post.actions.more.unhide')
|
||||||
: $t('post.actions.more.hide')}
|
: $t('post.actions.more.hide')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuButton onclick={() => report(post)} color="danger-subtle">
|
<MenuButton onclick={() => report(post)} color="danger-subtle" icon={Flag}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Flag} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('moderation.report')}
|
{$t('moderation.report')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
import type { PostView } from '$lib/client/types'
|
||||||
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 '$lib/client/types'
|
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
import { ArchiveBox, Icon, Plus } from 'svelte-hero-icons'
|
import { ArchiveBox, Plus } from 'svelte-hero-icons'
|
||||||
|
import { Post } from '..'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
posts: PostView[]
|
posts: PostView[]
|
||||||
@@ -26,10 +26,7 @@
|
|||||||
title="No posts"
|
title="No posts"
|
||||||
description="There are no posts that match this filter."
|
description="There are no posts that match this filter."
|
||||||
>
|
>
|
||||||
<Button href="/communities">
|
<Button href="/communities" icon={Plus}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Plus} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
<span>Follow some communities</span>
|
<span>Follow some communities</span>
|
||||||
</Button>
|
</Button>
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<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 VirtualList from '$lib/components/render/VirtualList.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'
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { SvelteSet } from 'svelte/reactivity'
|
import { SvelteSet } from 'svelte/reactivity'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
import { Post } from '..'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
posts: PostView[]
|
posts: PostView[]
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
const abortLoad = new AbortController()
|
const abortLoad = new AbortController()
|
||||||
let seenIds = new SvelteSet<number>(
|
let seenIds = new SvelteSet<number>(
|
||||||
feedData.posts.posts.map(post => post.post.id),
|
feedData.posts.posts.map((post) => post.post.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
async function loadMore() {
|
async function loadMore() {
|
||||||
@@ -80,7 +80,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 @@
|
|||||||
|
|
||||||
feedData.cursor.next = newPosts.next_page
|
feedData.cursor.next = newPosts.next_page
|
||||||
feedData.posts.posts.push(
|
feedData.posts.posts.push(
|
||||||
...newPosts.posts.filter(post => {
|
...newPosts.posts.filter((post) => {
|
||||||
if (seenIds.has(post.post.id)) return false
|
if (seenIds.has(post.post.id)) return false
|
||||||
seenIds.add(post.post.id)
|
seenIds.add(post.post.id)
|
||||||
return true
|
return true
|
||||||
@@ -107,7 +107,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
|
||||||
@@ -147,7 +147,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)
|
||||||
@@ -181,10 +181,12 @@
|
|||||||
title={$t('routes.frontpage.empty.title')}
|
title={$t('routes.frontpage.empty.title')}
|
||||||
description={$t('routes.frontpage.empty.description')}
|
description={$t('routes.frontpage.empty.description')}
|
||||||
>
|
>
|
||||||
<Button href="/communities" rounding="pill" color="primary">
|
<Button
|
||||||
{#snippet prefix()}
|
href="/communities"
|
||||||
<Icon src={ArrowTopRightOnSquare} size="16" mini />
|
rounding="pill"
|
||||||
{/snippet}
|
color="primary"
|
||||||
|
icon={ArrowTopRightOnSquare}
|
||||||
|
>
|
||||||
{$t('nav.communities')}
|
{$t('nav.communities')}
|
||||||
</Button>
|
</Button>
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
@@ -265,10 +267,7 @@
|
|||||||
community_name: feedData.community_name ?? 'undefined',
|
community_name: feedData.community_name ?? 'undefined',
|
||||||
})}
|
})}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<Button color="tertiary">
|
<Button color="tertiary" icon={ChevronDoubleUp}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ChevronDoubleUp} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('routes.post.scrollToTop')}
|
{$t('routes.post.scrollToTop')}
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import type { PostView } from '$lib/client/types'
|
|
||||||
import { SvelteMap, SvelteSet } from 'svelte/reactivity'
|
|
||||||
|
|
||||||
export type PostViewWithCrossposts = PostView & {
|
|
||||||
withCrossposts: true
|
|
||||||
crossposts: PostView[]
|
|
||||||
}
|
|
||||||
export type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
|
|
||||||
|
|
||||||
export const combineCrossposts = (
|
|
||||||
posts: PostView[],
|
|
||||||
): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => {
|
|
||||||
const urlMap = new SvelteMap<
|
|
||||||
string,
|
|
||||||
PostViewWithCrossposts | PostViewWithoutCrossposts
|
|
||||||
>()
|
|
||||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
|
||||||
const seenUrls = new SvelteSet<string>()
|
|
||||||
|
|
||||||
posts?.forEach(post => {
|
|
||||||
if (
|
|
||||||
!post ||
|
|
||||||
(settings.hidePosts.deleted && post.post.deleted) ||
|
|
||||||
(settings.hidePosts.removed && post.post.removed)
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if (!post?.post?.url) {
|
|
||||||
results.push(post)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const existing = urlMap.get(post.post.url)
|
|
||||||
if (existing) {
|
|
||||||
existing.withCrossposts = true
|
|
||||||
if (existing.withCrossposts) {
|
|
||||||
existing.crossposts = [...(existing.crossposts || []), post]
|
|
||||||
}
|
|
||||||
|
|
||||||
urlMap.set(post.post.url, existing)
|
|
||||||
} else {
|
|
||||||
urlMap.set(post.post.url, post)
|
|
||||||
results.push(post)
|
|
||||||
}
|
|
||||||
seenUrls.add(post.post.url)
|
|
||||||
})
|
|
||||||
|
|
||||||
return results
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import { Header } from '$lib/components/ui/layout'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { client, site } from '$lib/client/lemmy.svelte'
|
import { client, site } from '$lib/client/lemmy.svelte'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
TextArea,
|
TextArea,
|
||||||
TextInput,
|
TextInput,
|
||||||
toast,
|
toast,
|
||||||
|
Option,
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
import {
|
import {
|
||||||
ArrowPath,
|
ArrowPath,
|
||||||
@@ -96,15 +96,7 @@
|
|||||||
let communities: Community[] = $state([])
|
let communities: Community[] = $state([])
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (editingPost) {
|
if (editingPost) Object.assign(data, editingPost)
|
||||||
data.url = editingPost.url ?? ''
|
|
||||||
data.body = editingPost.body ?? ''
|
|
||||||
data.title = editingPost.name
|
|
||||||
data.nsfw = editingPost.nsfw
|
|
||||||
data.alt_text = editingPost.alt_text
|
|
||||||
data.thumbnail = editingPost.thumbnail_url
|
|
||||||
data.language_id = editingPost.language_id.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (passedCommunity) {
|
if (passedCommunity) {
|
||||||
data.community = passedCommunity
|
data.community = passedCommunity
|
||||||
@@ -116,12 +108,11 @@
|
|||||||
limit: 40,
|
limit: 40,
|
||||||
})
|
})
|
||||||
|
|
||||||
communities = list.communities.map(c => c.community)
|
communities = list.communities.map((c) => c.community)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
// @ts-expect-error TODO get rid of sessionStorage stuff
|
|
||||||
if (saveDraft) setSessionStorage('postDraft', data)
|
if (saveDraft) setSessionStorage('postDraft', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -134,7 +125,6 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!data.title || !profile.current?.jwt) return
|
|
||||||
if (data.url && data.url != '') {
|
if (data.url && data.url != '') {
|
||||||
try {
|
try {
|
||||||
new URL(data.url)
|
new URL(data.url)
|
||||||
@@ -209,7 +199,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({
|
||||||
@@ -254,7 +244,7 @@
|
|||||||
{#await import('$lib/components/form/ImageInputModal.svelte') then { default: UploadModal }}
|
{#await import('$lib/components/form/ImageInputModal.svelte') then { default: UploadModal }}
|
||||||
<UploadModal
|
<UploadModal
|
||||||
bind:open={uploadingImage}
|
bind:open={uploadingImage}
|
||||||
bind:imageUrl={() => '', v => (data.url = v)}
|
bind:imageUrl={() => '', (v) => (data.url = v)}
|
||||||
/>
|
/>
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -262,7 +252,7 @@
|
|||||||
{#if addAltText}
|
{#if addAltText}
|
||||||
<Modal title={$t('form.post.altText')} bind:open={addAltText}>
|
<Modal title={$t('form.post.altText')} bind:open={addAltText}>
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
addAltText = !addAltText
|
addAltText = !addAltText
|
||||||
}}
|
}}
|
||||||
@@ -277,7 +267,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
@@ -298,7 +288,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
|
||||||
@@ -370,10 +360,8 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
color={data.alt_text ? 'primary' : 'ghost'}
|
color={data.alt_text ? 'primary' : 'ghost'}
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
>
|
icon={ChatBubbleBottomCenterText}
|
||||||
{#snippet prefix()}
|
>{$t('form.post.altText')}
|
||||||
<Icon src={ChatBubbleBottomCenterText} size="15" micro />
|
|
||||||
{/snippet}{$t('form.post.altText')}
|
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
@@ -382,10 +370,8 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
|
icon={Photo}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Photo} size="15" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('form.post.uploadImage')}
|
{$t('form.post.uploadImage')}
|
||||||
</Button>
|
</Button>
|
||||||
{#if generation.generatable}
|
{#if generation.generatable}
|
||||||
@@ -396,10 +382,8 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
class="text-xs"
|
class="text-xs"
|
||||||
|
icon={Sparkles}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Sparkles} size="15" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('form.post.generateTitle')}
|
{$t('form.post.generateTitle')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { instance } from '$lib/instance.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image'
|
|
||||||
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
|
|
||||||
import type { CommentView, PersonView, Post } from '$lib/client/types'
|
import type { CommentView, PersonView, Post } from '$lib/client/types'
|
||||||
|
import {
|
||||||
|
canParseUrl,
|
||||||
|
findClosestNumber,
|
||||||
|
isImage,
|
||||||
|
isVideo,
|
||||||
|
} from '$lib/util.svelte'
|
||||||
|
|
||||||
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
|
||||||
@@ -57,14 +61,15 @@ export const isYoutubeLink = (url?: string): RegExpMatchArray | null => {
|
|||||||
return url?.match?.(YOUTUBE_REGEX)
|
return url?.match?.(YOUTUBE_REGEX)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const postLink = (post: Post) =>
|
export function postLink(post: Post) {
|
||||||
`/post/${encodeURIComponent(instance.data)}/${post.id}`
|
return `/post/${encodeURIComponent(profile.current.instance)}/${post.id}`
|
||||||
|
}
|
||||||
|
|
||||||
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): MediaType => {
|
export function mediaType(url?: string): MediaType {
|
||||||
if (url) {
|
if (!url) return 'none'
|
||||||
if (isImage(url)) return 'image'
|
if (isImage(url)) return 'image'
|
||||||
if (isVideo(url)) return 'iframe'
|
if (isVideo(url)) return 'iframe'
|
||||||
if (isYoutubeLink(url)) return 'iframe'
|
if (isYoutubeLink(url)) return 'iframe'
|
||||||
@@ -72,9 +77,7 @@ export const mediaType = (url?: string): MediaType => {
|
|||||||
return 'none'
|
return 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'none'
|
export function iframeType(url: string): IframeType {
|
||||||
}
|
|
||||||
export const iframeType = (url: string): IframeType => {
|
|
||||||
if (isVideo(url)) return 'video'
|
if (isVideo(url)) return 'video'
|
||||||
if (isYoutubeLink(url)) return 'youtube'
|
if (isYoutubeLink(url)) return 'youtube'
|
||||||
return 'none'
|
return 'none'
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export { default as Post } from './Post.svelte'
|
||||||
|
export { default as PostBody } from './PostBody.svelte'
|
||||||
|
export { default as PostItem } from './PostItem.svelte'
|
||||||
|
export { default as PostMeta } from './PostMeta.svelte'
|
||||||
|
export { default as PostVote } from './PostVote.svelte'
|
||||||
|
export { default as PostMedia } from './media/PostMedia.svelte'
|
||||||
|
export { default as PostMediaCompact } from './media/PostMediaCompact.svelte'
|
||||||
|
export { default as PostImage } from './media/PostImage.svelte'
|
||||||
|
export { default as PostIframe } from './media/PostIframe.svelte'
|
||||||
|
export { default as PostLink } from './link/PostLink.svelte'
|
||||||
|
export { default as VirtualFeed } from './feed/VirtualFeed.svelte'
|
||||||
|
export { default as PostFeed } from './feed/PostFeed.svelte'
|
||||||
|
export { default as PostForm } from './form/PostForm.svelte'
|
||||||
|
export { default as PostActions } from './actions/PostActions.svelte'
|
||||||
|
|
||||||
|
export {
|
||||||
|
type Tag,
|
||||||
|
parseTags,
|
||||||
|
textToTag,
|
||||||
|
default as PostsMeta,
|
||||||
|
} from './PostMeta.svelte'
|
||||||
|
|
||||||
|
export * from './helpers'
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
let { post, blur = false }: Props = $props()
|
let { post, blur = false }: Props = $props()
|
||||||
|
|
||||||
let imageLoaded: boolean | null = $state(null)
|
let imageLoaded: boolean | null = $state(null)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
imageLoaded = false
|
imageLoaded = false
|
||||||
})
|
})
|
||||||
@@ -88,11 +87,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,13 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
|
||||||
iframeType,
|
|
||||||
type MediaType,
|
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import type { Post } from '$lib/client/types'
|
import type { Post } from '$lib/client/types'
|
||||||
import PostIframe from './PostIframe.svelte'
|
import {
|
||||||
import PostImage from './PostImage.svelte'
|
PostImage,
|
||||||
|
PostIframe,
|
||||||
|
PostLink,
|
||||||
|
type MediaType,
|
||||||
|
iframeType,
|
||||||
|
} from '..'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
view?: View
|
view?: View
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { bestImageURL, postLink, type MediaType } from '..'
|
||||||
bestImageURL,
|
|
||||||
postLink,
|
|
||||||
type MediaType,
|
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import type { Post } from '$lib/client/types'
|
import type { Post } from '$lib/client/types'
|
||||||
import { modal } from 'mono-svelte'
|
import { modal, Button } from 'mono-svelte'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
|
||||||
import {
|
import {
|
||||||
DocumentText,
|
DocumentText,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Search
|
<Search
|
||||||
search={async q => {
|
search={async (q) => {
|
||||||
const users = (
|
const users = (
|
||||||
await getClient(instance).search({
|
await getClient(instance).search({
|
||||||
q: q || ' ',
|
q: q || ' ',
|
||||||
@@ -39,15 +39,15 @@
|
|||||||
listing_type: listing_type,
|
listing_type: listing_type,
|
||||||
sort: 'TopAll',
|
sort: 'TopAll',
|
||||||
})
|
})
|
||||||
).users.map(c => c.person)
|
).users.map((c) => c.person)
|
||||||
|
|
||||||
if (hideOwnUser) {
|
if (hideOwnUser) {
|
||||||
const myself = profile.current.user?.local_user_view.person.id
|
const myself = profile.current.user?.local_user_view.person.id
|
||||||
return users.filter(c => c.id != myself)
|
return users.filter((c) => c.id != myself)
|
||||||
}
|
}
|
||||||
return users
|
return users
|
||||||
}}
|
}}
|
||||||
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,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import { userLink } from '$lib/lemmy/generic'
|
import { userLink } from '$lib/util.svelte'
|
||||||
import type { PersonView } from '$lib/client/types'
|
import type { PersonView } from '$lib/client/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
rows = 2,
|
rows = 2,
|
||||||
// should be preprocess instead
|
// should be preprocess instead
|
||||||
beforePreview = input => input,
|
beforePreview = (input) => input,
|
||||||
previewing = $bindable(false),
|
previewing = $bindable(false),
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
customLabel,
|
customLabel,
|
||||||
@@ -125,8 +125,8 @@
|
|||||||
<Modal title={$t('form.post.uploadImage')} bind:open={uploadingImage}>
|
<Modal title={$t('form.post.uploadImage')} bind:open={uploadingImage}>
|
||||||
<ImageAttachForm
|
<ImageAttachForm
|
||||||
bind:image
|
bind:image
|
||||||
onupload={e => {
|
onupload={(e) => {
|
||||||
e.forEach(i => {
|
e.forEach((i) => {
|
||||||
wrapSelection(`\n\n`, '')
|
wrapSelection(`\n\n`, '')
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -293,7 +293,7 @@
|
|||||||
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) {
|
||||||
handleKeydown(e)
|
handleKeydown(e)
|
||||||
@@ -306,7 +306,7 @@
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
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/')) {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
iframeType,
|
iframeType,
|
||||||
mediaType,
|
mediaType,
|
||||||
optimizeImageURL,
|
optimizeImageURL,
|
||||||
} from '$lib/components/lemmy/post/helpers'
|
PostIframe,
|
||||||
import PostIframe from '$lib/components/lemmy/post/media/PostIframe.svelte'
|
} from '$lib/components/lemmy/post'
|
||||||
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getContext } from 'svelte'
|
import { getContext } from 'svelte'
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ const regexes = {
|
|||||||
/**
|
/**
|
||||||
* Convert links to photon links
|
* Convert links to photon links
|
||||||
*/
|
*/
|
||||||
export const photonify = link => {
|
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
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
}
|
}
|
||||||
}, debounceResize)
|
}, debounceResize)
|
||||||
|
|
||||||
const observer = new ResizeObserver(entries => {
|
const observer = new ResizeObserver((entries) => {
|
||||||
debouncedUpdate(entries)
|
debouncedUpdate(entries)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (virtualListEl && browser) {
|
if (virtualListEl && browser) {
|
||||||
Array.from(virtualListEl.children).forEach(node => {
|
Array.from(virtualListEl.children).forEach((node) => {
|
||||||
const indexAttr = node.getAttribute('data-index')
|
const indexAttr = node.getAttribute('data-index')
|
||||||
if (indexAttr === null) return
|
if (indexAttr === null) return
|
||||||
const index = Number(indexAttr)
|
const index = Number(indexAttr)
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
<svelte:window
|
<svelte:window
|
||||||
bind:scrollY={
|
bind:scrollY={
|
||||||
() => (useWindow ? scrollY : 0),
|
() => (useWindow ? scrollY : 0),
|
||||||
v => {
|
(v) => {
|
||||||
if (useWindow) scrollY = v
|
if (useWindow) scrollY = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,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>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { Button, Material, toast } from 'mono-svelte'
|
import { Button, Material, toast } from 'mono-svelte'
|
||||||
import { focusTrap } from 'svelte-focus-trap'
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { Icon, Share, XMark } from 'svelte-hero-icons'
|
import { Share, XMark } from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fade, scale } from 'svelte/transition'
|
import { fade, scale } from 'svelte/transition'
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
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
|
||||||
@@ -55,7 +55,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={() => {
|
||||||
@@ -66,22 +66,16 @@
|
|||||||
size="square-lg"
|
size="square-lg"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
aria-label={$t('post.actions.more.share')}
|
aria-label={$t('post.actions.more.share')}
|
||||||
>
|
icon={Share}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={Share} size="20" micro />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
onclick={() => history.back()}
|
onclick={() => history.back()}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="square-lg"
|
size="square-lg"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
aria-label={$t('common.back')}
|
aria-label={$t('common.back')}
|
||||||
>
|
icon={XMark}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={XMark} size="20" micro />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
</Material>
|
</Material>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,16 +21,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if content != '-1'}
|
{#if content != '-1'}
|
||||||
<div class="flex flex-col {clazz}">
|
<dl class={['flex flex-col', clazz]}>
|
||||||
<span class="text-slate-600 dark:text-zinc-400 text-xs {labelClass}">
|
<dt class={['text-slate-600 dark:text-zinc-400 text-xs', labelClass]}>
|
||||||
{label}
|
{label}
|
||||||
</span>
|
</dt>
|
||||||
<span class="text-base {contentClass}">
|
<dd class={['text-base', contentClass]}>
|
||||||
{#if formatted}
|
{#if formatted}
|
||||||
<FormattedNumber number={Number(content)} />
|
<FormattedNumber number={Number(content)} />
|
||||||
{:else}
|
{:else}
|
||||||
{content}
|
{content}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</dd>
|
||||||
</div>
|
</dl>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import type { HTMLAttributes } from 'svelte/elements'
|
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
|
||||||
small?: boolean
|
|
||||||
class?: string
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let { small = false, class: clazz = '', children, ...rest }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<span {...rest} class="{!small ? 'text-lg' : 'text-xs'} font-medium {clazz}">
|
|
||||||
{@render children?.()}
|
|
||||||
</span>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
interface Props {
|
|
||||||
class?: string
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let { class: clazz = '', children }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<aside
|
|
||||||
class="break-words flex shrink
|
|
||||||
flex-col gap-4 px-6 max-w-full w-full h-full
|
|
||||||
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {clazz}"
|
|
||||||
>
|
|
||||||
{@render children?.()}
|
|
||||||
</aside>
|
|
||||||
File renamed without changes.
@@ -2,7 +2,7 @@
|
|||||||
import { navigating } from '$app/state'
|
import { navigating } from '$app/state'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { Button, TextInput } from 'mono-svelte'
|
import { Button, TextInput } from 'mono-svelte'
|
||||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
import { MagnifyingGlass } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
query?: string | null
|
query?: string | null
|
||||||
@@ -30,9 +30,6 @@
|
|||||||
title="Search"
|
title="Search"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
loading={navigating.to?.route.id == '/search'}
|
loading={navigating.to?.route.id == '/search'}
|
||||||
>
|
icon={MagnifyingGlass}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={MagnifyingGlass} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export { default as Header } from './pages/Header.svelte'
|
||||||
|
export { default as Tabs } from './pages/Tabs.svelte'
|
||||||
|
export { default as CommonList } from './CommonList.svelte'
|
||||||
|
export { default as SearchBar } from './SearchBar.svelte'
|
||||||
|
export { default as Shell } from './Shell.svelte'
|
||||||
|
export { default as Pageination } from './Pageination.svelte'
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let matchType = $derived<('search' | 'pathname')[]>(
|
let matchType = $derived<('search' | 'pathname')[]>(
|
||||||
routes.map(i =>
|
routes.map((i) =>
|
||||||
new URL(`https://example.com${i.href}`)?.search != ''
|
new URL(`https://example.com${i.href}`)?.search != ''
|
||||||
? 'search'
|
? 'search'
|
||||||
: 'pathname',
|
: 'pathname',
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
const hrefSearch = new Set(href.searchParams.values())
|
const hrefSearch = new Set(href.searchParams.values())
|
||||||
// checks if there is any
|
// checks if there is any
|
||||||
const usePathname = !routes.some(
|
const usePathname = !routes.some(
|
||||||
i =>
|
(i) =>
|
||||||
new Set(
|
new Set(
|
||||||
new URL(`https://example.com${i.href}`).searchParams.values(),
|
new URL(`https://example.com${i.href}`).searchParams.values(),
|
||||||
).intersection(currentSearch).size > 0,
|
).intersection(currentSearch).size > 0,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -79,7 +79,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}
|
{/if}
|
||||||
{#if amModOfAny(profile.current?.user)}
|
{#if amModOfAny(profile.current?.user)}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
isAdmin,
|
isAdmin,
|
||||||
} from '$lib/components/lemmy/moderation/moderation'
|
} from '$lib/components/lemmy/moderation/moderation'
|
||||||
|
|
||||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
import SiteCard from '$lib/components/lemmy/instance/InstanceCard.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { site } from '$lib/client/lemmy.svelte'
|
import { site } from '$lib/client/lemmy.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { theme } from '$lib/ui/colors.svelte'
|
import { theme } from '$lib/ui/theme/theme.svelte'
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Button,
|
Button,
|
||||||
@@ -66,10 +66,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
<MenuButton href="/inbox">
|
<MenuButton href="/inbox" icon={Inbox}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Inbox} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('profile.inbox')}
|
{$t('profile.inbox')}
|
||||||
{#if $notifications.inbox > 0}
|
{#if $notifications.inbox > 0}
|
||||||
<Badge color="red-subtle" class="text-xs ml-auto font-bold py-0.5!">
|
<Badge color="red-subtle" class="text-xs ml-auto font-bold py-0.5!">
|
||||||
@@ -94,43 +91,25 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuDivider>{$t('profile.profile')}</MenuDivider>
|
<MenuDivider>{$t('profile.profile')}</MenuDivider>
|
||||||
<MenuButton href="/profile">
|
<MenuButton href="/profile" icon={UserCircle}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={UserCircle} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('profile.profile')}
|
{$t('profile.profile')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton href="/saved">
|
<MenuButton href="/saved" icon={Bookmark}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Bookmark} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('profile.saved')}
|
{$t('profile.saved')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{:else}
|
{:else}
|
||||||
<MenuButton href="/accounts/login">
|
<MenuButton href="/accounts/login" icon={ArrowLeftOnRectangle}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={ArrowLeftOnRectangle} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.login')}
|
{$t('account.login')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton href="/signup">
|
<MenuButton href="/signup" icon={Identification}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Identification} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.signup')}
|
{$t('account.signup')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
<MenuButton href="/accounts">
|
<MenuButton href="/accounts" icon={UserGroup}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={UserGroup} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.accounts')}
|
{$t('account.accounts')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
||||||
<MenuButton href="/settings">
|
<MenuButton href="/settings" icon={Cog6Tooth}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Cog6Tooth} micro size="16" />
|
|
||||||
{/snippet}
|
|
||||||
{$t('nav.menu.settings')}
|
{$t('nav.menu.settings')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<Select bind:value={theme.colorScheme} size="sm" placement="bottom">
|
<Select bind:value={theme.colorScheme} size="sm" placement="bottom">
|
||||||
@@ -158,19 +137,11 @@
|
|||||||
</Option>
|
</Option>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Select>
|
</Select>
|
||||||
<MenuButton href="/theme">
|
<MenuButton href="/theme" icon={Swatch}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Swatch} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('nav.menu.theme')}
|
{$t('nav.menu.theme')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if settings.debugInfo}
|
{#if settings.debugInfo}
|
||||||
<MenuButton href="/util">
|
<MenuButton href="/util" icon={BugAnt}>Debug</MenuButton>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={BugAnt} mini size="16" />
|
|
||||||
{/snippet}
|
|
||||||
Debug
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
{/if}
|
||||||
<li class="flex flex-col px-2 py-1 mx-auto my-1 text-xs w-full">
|
<li class="flex flex-col px-2 py-1 mx-auto my-1 text-xs w-full">
|
||||||
<div class="flex flex-row gap-2 w-full items-center">
|
<div class="flex flex-row gap-2 w-full items-center">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
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 { theme } from '$lib/ui/theme/theme.svelte'
|
||||||
import { fuzzySearch } from '$lib/util.svelte'
|
import { fuzzySearch } from '$lib/util.svelte'
|
||||||
import { TextInput } from 'mono-svelte'
|
import { TextInput } from 'mono-svelte'
|
||||||
import { createEventDispatcher, onMount } from 'svelte'
|
import { createEventDispatcher, onMount } from 'svelte'
|
||||||
@@ -55,16 +55,16 @@
|
|||||||
|
|
||||||
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),
|
||||||
@@ -72,7 +72,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 {
|
||||||
@@ -80,11 +80,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,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)
|
||||||
@@ -137,10 +137,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)
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
let flattenedActions = $derived(
|
let flattenedActions = $derived(
|
||||||
filteredGroups.flatMap(group => group.actions),
|
filteredGroups.flatMap((group) => group.actions),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
>
|
>
|
||||||
<CommandItem
|
<CommandItem
|
||||||
{action}
|
{action}
|
||||||
onclick={e => {
|
onclick={(e) => {
|
||||||
if (action.href) {
|
if (action.href) {
|
||||||
togglePalette()
|
togglePalette()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { type ResumableItem } from '$lib/lemmy/item'
|
import { type ResumableItem } from '$lib/lemmy/item'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { theme, type ThemeData } from '$lib/ui/colors.svelte'
|
import { theme, type ThemeData } from '$lib/ui/theme/theme.svelte'
|
||||||
import { fullCommunityName } from '$lib/util.svelte'
|
import { fullCommunityName } from '$lib/util.svelte'
|
||||||
import {
|
import {
|
||||||
ArrowRightOnRectangle,
|
ArrowRightOnRectangle,
|
||||||
@@ -73,7 +73,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 +306,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 +379,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),
|
||||||
@@ -400,7 +400,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(
|
||||||
|
|||||||
@@ -48,7 +48,10 @@
|
|||||||
<div class="font-medium">{profile.current.username}</div>
|
<div class="font-medium">{profile.current.username}</div>
|
||||||
{#if !LINKED_INSTANCE_URL}
|
{#if !LINKED_INSTANCE_URL}
|
||||||
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
||||||
<span class="capitalize">{profile.current.client?.name ?? DEFAULT_CLIENT_TYPE.name}</span> • {profile.current.instance}
|
<span class="capitalize"
|
||||||
|
>{profile.current.client?.name ?? DEFAULT_CLIENT_TYPE.name}</span
|
||||||
|
>
|
||||||
|
• {profile.current.instance}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -75,7 +78,10 @@
|
|||||||
<div class="font-medium text-sm">{p.username}</div>
|
<div class="font-medium text-sm">{p.username}</div>
|
||||||
{#if !LINKED_INSTANCE_URL}
|
{#if !LINKED_INSTANCE_URL}
|
||||||
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
<div class="text-xs text-slate-500 dark:text-zinc-500">
|
||||||
<span class="capitalize">{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}</span> • {p.instance}
|
<span class="capitalize"
|
||||||
|
>{p.client?.name ?? DEFAULT_CLIENT_TYPE.name}</span
|
||||||
|
>
|
||||||
|
• {p.instance}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -95,10 +101,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/each}
|
{/each}
|
||||||
<MenuButton href="/accounts">
|
<MenuButton href="/accounts" icon={UserGroup}>
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={UserGroup} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('account.accounts')}
|
{$t('account.accounts')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
@@ -4,9 +4,9 @@
|
|||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { communityLink } from '$lib/lemmy/generic'
|
import { communityLink } from '$lib/util.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { theme } from '$lib/ui/colors.svelte'
|
import { theme } from '$lib/ui/theme/theme.svelte'
|
||||||
import { Badge, Option, Select } from 'mono-svelte'
|
import { Badge, Option, Select } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
ArrowLeftOnRectangle,
|
ArrowLeftOnRectangle,
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<ItemList
|
||||||
items={profile.current.user.moderates.map(i => ({
|
items={profile.current.user.moderates.map((i) => ({
|
||||||
id: i.community.id,
|
id: i.community.id,
|
||||||
name: i.community.title,
|
name: i.community.title,
|
||||||
url: communityLink(i.community),
|
url: communityLink(i.community),
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<ItemList
|
<ItemList
|
||||||
items={profile.current.user.follows.map(i => ({
|
items={profile.current.user.follows.map((i) => ({
|
||||||
id: i.community.id,
|
id: i.community.id,
|
||||||
name: i.community.title,
|
name: i.community.title,
|
||||||
url: communityLink(i.community),
|
url: communityLink(i.community),
|
||||||
|
|||||||
@@ -947,5 +947,9 @@
|
|||||||
"title": "Add a post title",
|
"title": "Add a post title",
|
||||||
"body": "What do you have to say?",
|
"body": "What do you have to say?",
|
||||||
"comments": "Join the conversation"
|
"comments": "Join the conversation"
|
||||||
|
},
|
||||||
|
"class": {
|
||||||
|
"moderator": "Moderator",
|
||||||
|
"admin": "Administrator"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { fullCommunityName } from '$lib/util.svelte'
|
|
||||||
import type { Community, Person } from '$lib/client/types'
|
|
||||||
|
|
||||||
export const communityLink = (community: Community, prefix: string = '') =>
|
|
||||||
`${prefix}/c/${fullCommunityName(community.name, community.actor_id)}`
|
|
||||||
|
|
||||||
export const userLink = (person: Person, prefix: string = '') =>
|
|
||||||
`${prefix}/u/${person.name}@${new URL(person.actor_id).hostname}`
|
|
||||||
@@ -92,8 +92,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()
|
||||||
@@ -107,9 +107,9 @@ export const resumables = resumableStore()
|
|||||||
|
|
||||||
export function addFavorite(item: Community, add: boolean = true) {
|
export function addFavorite(item: Community, add: boolean = true) {
|
||||||
const favs = profile.current.favorites ?? []
|
const favs = profile.current.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)
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-26
@@ -1,30 +1,29 @@
|
|||||||
import { profile, type ProfileInfo } from '$lib/auth.svelte'
|
import { profile, type ProfileInfo } from '$lib/auth.svelte'
|
||||||
import { getClient } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { trycatch } from '$lib/util.svelte'
|
|
||||||
import type { Community, MyUserInfo } from '$lib/client/types'
|
import type { Community, MyUserInfo } from '$lib/client/types'
|
||||||
|
|
||||||
// TODO obliterate this file
|
// TODO obliterate this file
|
||||||
|
export async function blockUser(block: boolean, id: number) {
|
||||||
export const blockUser = async (block: boolean, id: number) => {
|
|
||||||
const auth = profile.current?.jwt
|
const auth = profile.current?.jwt
|
||||||
|
|
||||||
if (!auth) throw new Error('Unauthorized')
|
if (!auth) throw new Error('Unauthorized')
|
||||||
|
|
||||||
await getClient().blockPerson({
|
await client().blockPerson({
|
||||||
block: block,
|
block: block,
|
||||||
person_id: id,
|
person_id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const isBlocked = (me: MyUserInfo, user: number) =>
|
export function isBlocked(me: MyUserInfo, user: number) {
|
||||||
me.person_blocks.map(b => b.target.id).includes(user)
|
return me.person_blocks.map((b) => b.target.id).includes(user)
|
||||||
|
}
|
||||||
|
|
||||||
export const addSubscription = (
|
export function addSubscription(
|
||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true,
|
subscribe: boolean = true,
|
||||||
) => {
|
) {
|
||||||
const index = profile.current.user?.follows
|
const index = profile.current.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) {
|
||||||
@@ -37,19 +36,6 @@ export const addSubscription = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addAdmin = async (handle: string, added: boolean) =>
|
export function hasFavorite(profile: ProfileInfo, id: number): boolean {
|
||||||
trycatch(async () => {
|
return profile.favorites?.map((i) => i.id).includes(id) ?? false
|
||||||
const user = await getClient().resolveObject({
|
}
|
||||||
q: handle,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!user.person) throw new Error('No user found')
|
|
||||||
|
|
||||||
return await getClient().addAdmin({
|
|
||||||
added: added,
|
|
||||||
person_id: user.person.person.id,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
export const hasFavorite = (profile: ProfileInfo, id: number): boolean =>
|
|
||||||
profile.favorites?.map(i => i.id).includes(id) ?? false
|
|
||||||
@@ -73,6 +73,7 @@
|
|||||||
children?: Snippet
|
children?: Snippet
|
||||||
suffix?: Snippet
|
suffix?: Snippet
|
||||||
onclick?: HTMLButtonAttributes['onclick']
|
onclick?: HTMLButtonAttributes['onclick']
|
||||||
|
icon?: IconSource
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { Props as ButtonProps }
|
export type { Props as ButtonProps }
|
||||||
@@ -87,6 +88,7 @@
|
|||||||
|
|
||||||
import Spinner from '../loader/Spinner.svelte'
|
import Spinner from '../loader/Spinner.svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let {
|
let {
|
||||||
loading = false,
|
loading = false,
|
||||||
@@ -103,6 +105,7 @@
|
|||||||
prefix,
|
prefix,
|
||||||
children,
|
children,
|
||||||
suffix,
|
suffix,
|
||||||
|
icon,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
@@ -136,6 +139,8 @@
|
|||||||
<Spinner width={loaderWidth ?? 16} />
|
<Spinner width={loaderWidth ?? 16} />
|
||||||
{:else if prefix}
|
{:else if prefix}
|
||||||
{@render prefix?.()}
|
{@render prefix?.()}
|
||||||
|
{:else if icon}
|
||||||
|
<Icon src={icon} size="16" mini />
|
||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{@render suffix?.()}
|
{@render suffix?.()}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
interface Props {
|
|
||||||
defaultValue?: boolean
|
|
||||||
checked?: boolean | undefined
|
|
||||||
inlineDescription?: boolean
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
description?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
defaultValue = false,
|
|
||||||
checked = $bindable(defaultValue),
|
|
||||||
inlineDescription = false,
|
|
||||||
children,
|
|
||||||
description,
|
|
||||||
}: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<label
|
|
||||||
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
|
|
||||||
>
|
|
||||||
<input type="checkbox" bind:checked class="cursor-pointer" />
|
|
||||||
<div
|
|
||||||
class="inline-flex {inlineDescription
|
|
||||||
? 'flex-row'
|
|
||||||
: 'flex-col'} font-medium gap-1"
|
|
||||||
>
|
|
||||||
{@render children?.()}
|
|
||||||
{#if description}
|
|
||||||
<span class="font-normal text-slate-600 dark:text-zinc-400">
|
|
||||||
{@render description?.()}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</label>
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
|
||||||
import Label from '../forms/Label.svelte'
|
|
||||||
import { generateID } from '../forms/helper.js'
|
|
||||||
import TextInput from './TextInput.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
accept?: string
|
|
||||||
files?: FileList | undefined | null
|
|
||||||
label?: string | undefined
|
|
||||||
id?: string
|
|
||||||
url?: string | undefined
|
|
||||||
customLabel?: import('svelte').Snippet
|
|
||||||
}
|
|
||||||
|
|
||||||
let {
|
|
||||||
accept = 'image/*',
|
|
||||||
files = $bindable(),
|
|
||||||
label = undefined,
|
|
||||||
id = generateID(),
|
|
||||||
url = undefined,
|
|
||||||
customLabel,
|
|
||||||
}: Props = $props()
|
|
||||||
|
|
||||||
let dragover = $state(false)
|
|
||||||
|
|
||||||
let previewURL = $derived(files ? URL.createObjectURL(files[0]) : undefined)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex flex-col">
|
|
||||||
{#if customLabel || label}
|
|
||||||
<Label for={id} text={label} class="mb-1">
|
|
||||||
{@render customLabel?.()}
|
|
||||||
</Label>
|
|
||||||
{/if}
|
|
||||||
<label
|
|
||||||
class={[
|
|
||||||
'flex flex-col items-center justify-center px-8 py-4 mx-auto w-full rounded-xl',
|
|
||||||
'border border-slate-200 dark:border-zinc-800 border-dashed hover:border-slate-300 hover:dark:border-zinc-700',
|
|
||||||
'cursor-pointer min-h-36 transition-colors bg-white dark:bg-zinc-950',
|
|
||||||
dragover && 'border-sky-500 text-sky-500',
|
|
||||||
]}
|
|
||||||
ondrop={event => {
|
|
||||||
event.preventDefault()
|
|
||||||
files = event.dataTransfer?.files ?? null
|
|
||||||
}}
|
|
||||||
ondragover={event => {
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
if (event.dataTransfer) {
|
|
||||||
event.dataTransfer.dropEffect = 'copy'
|
|
||||||
dragover = true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
ondragleave={e => {
|
|
||||||
e.preventDefault()
|
|
||||||
dragover = false
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#if files}
|
|
||||||
<!-- svelte-ignore a11y_missing_attribute -->
|
|
||||||
<img
|
|
||||||
src={previewURL}
|
|
||||||
onload={() => {
|
|
||||||
if (previewURL) URL.revokeObjectURL(previewURL)
|
|
||||||
}}
|
|
||||||
class="w-full max-w-sm h-full rounded-lg"
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<Icon
|
|
||||||
src={DocumentPlus}
|
|
||||||
class="text-slate-400 dark:text-zinc-500"
|
|
||||||
size="36"
|
|
||||||
solid
|
|
||||||
/>
|
|
||||||
<p class="text-slate-600 dark:text-zinc-400 font-medium">Attach a file</p>
|
|
||||||
{/if}
|
|
||||||
<input type="file" bind:files {accept} class="hidden" />
|
|
||||||
</label>
|
|
||||||
{#if url != undefined}
|
|
||||||
<TextInput
|
|
||||||
class="rounded-t-none border-t-0 rounded-xl"
|
|
||||||
placeholder="https://example.com/img1.png"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label
|
<svelte:element
|
||||||
|
this={text || customText ? 'label' : 'h3'}
|
||||||
{...rest}
|
{...rest}
|
||||||
for={forID}
|
for={forID}
|
||||||
class={['text-sm text-slate-800 dark:text-zinc-200 font-medium', clazz]}
|
class={['text-sm text-slate-800 dark:text-zinc-200 font-medium', clazz]}
|
||||||
@@ -33,4 +34,4 @@
|
|||||||
{@render customText?.()}
|
{@render customText?.()}
|
||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</label>
|
</svelte:element>
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
const context = getContext<SelectContext>('select')
|
const context = getContext<SelectContext>('select')
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if ($locale || !context.options.find(v => v == option)) {
|
if ($locale || !context.options.find((v) => v == option)) {
|
||||||
const index = context.options.findIndex(i => i.value == option.value)
|
const index = context.options.findIndex((i) => i.value == option.value)
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
context.options.splice(index, 1, option)
|
context.options.splice(index, 1, option)
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
const index = context.options.findIndex(i => i.value == option.value)
|
const index = context.options.findIndex((i) => i.value == option.value)
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
context.options.splice(index, 1)
|
context.options.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,8 +93,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet selectTarget(attachment: Attachment)}
|
{#snippet selectTarget(attachment: Attachment)}
|
||||||
<Label text={label} customText={customLabel} class={['space-y-1 relative', baseClass]}>
|
<Label
|
||||||
<div class="relative" role="presentation">
|
text={label}
|
||||||
|
customText={customLabel}
|
||||||
|
class={['space-y-1 relative', baseClass]}
|
||||||
|
>
|
||||||
|
<div class="relative w-max max-w-full" role="presentation">
|
||||||
<select
|
<select
|
||||||
{@attach attachment}
|
{@attach attachment}
|
||||||
{...rest}
|
{...rest}
|
||||||
@@ -109,10 +113,10 @@
|
|||||||
clazz,
|
clazz,
|
||||||
]}
|
]}
|
||||||
bind:value
|
bind:value
|
||||||
onmousedown={e => {
|
onmousedown={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
onkeypress={e => {
|
onkeypress={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
open = !open
|
open = !open
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ export { default as TextInput } from './forms/TextInput.svelte'
|
|||||||
export { default as TextArea } from './forms/TextArea.svelte'
|
export { default as TextArea } from './forms/TextArea.svelte'
|
||||||
export { default as Select } from './forms/select/Select.svelte'
|
export { default as Select } from './forms/select/Select.svelte'
|
||||||
export { default as Option } from './forms/select/Option.svelte'
|
export { default as Option } from './forms/select/Option.svelte'
|
||||||
export { default as ImageInput } from './forms/ImageInput.svelte'
|
|
||||||
|
|
||||||
export { default as Checkbox } from './forms/Checkbox.svelte'
|
|
||||||
export { default as Switch } from './forms/Switch.svelte'
|
export { default as Switch } from './forms/Switch.svelte'
|
||||||
|
|
||||||
export { default as Popover } from './popover/Popover.svelte'
|
export { default as Popover } from './popover/Popover.svelte'
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { pushState, replaceState } from '$app/navigation'
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
import { focusTrap } from 'svelte-focus-trap'
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { Icon, XMark } from 'svelte-hero-icons'
|
import { XMark } from 'svelte-hero-icons'
|
||||||
import { backOut } from 'svelte/easing'
|
import { backOut } from 'svelte/easing'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
import { fade, scale } from 'svelte/transition'
|
import { fade, scale } from 'svelte/transition'
|
||||||
import { Button } from '../index.js'
|
import { Button } from '../index.js'
|
||||||
import Portal from '../popover/Portal.svelte'
|
import Portal from '../popover/Portal.svelte'
|
||||||
import type { Snippet } from 'svelte'
|
|
||||||
import { page } from '$app/state'
|
|
||||||
import { pushState, replaceState } from '$app/navigation'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
action?: string | undefined
|
action?: string | undefined
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
if (!isInHistory && open) {
|
if (!isInHistory && open) {
|
||||||
replaceState('', {
|
replaceState('', {
|
||||||
openModals: currentModals.filter(id => id !== modalId),
|
openModals: currentModals.filter((id) => id !== modalId),
|
||||||
})
|
})
|
||||||
hasHistoryEntry = false
|
hasHistoryEntry = false
|
||||||
open = false
|
open = false
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
flex flex-col items-center justify-center backdrop-blur-xs
|
flex flex-col items-center justify-center backdrop-blur-xs
|
||||||
bg-white/50 dark:bg-black/50 box-border p-4"
|
bg-white/50 dark:bg-black/50 box-border p-4"
|
||||||
transition:fade|global={{ duration: 100 }}
|
transition:fade|global={{ duration: 100 }}
|
||||||
onclick={e => {
|
onclick={(e) => {
|
||||||
// @ts-expect-error html node hell
|
// @ts-expect-error html node hell
|
||||||
if (!el.contains(e.target)) onclose()
|
if (!el.contains(e.target)) onclose()
|
||||||
}}
|
}}
|
||||||
@@ -110,11 +110,8 @@ bg-white/50 dark:bg-black/50 box-border p-4"
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
onclick={() => onclose()}
|
onclick={() => onclose()}
|
||||||
>
|
icon={XMark}
|
||||||
{#snippet prefix()}
|
></Button>
|
||||||
<Icon src={XMark} size="20" mini />
|
|
||||||
{/snippet}
|
|
||||||
</Button>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if title !== null}
|
{#if title !== null}
|
||||||
<h1 class="font-semibold text-xl max-w-full">
|
<h1 class="font-semibold text-xl max-w-full">
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const menuAttach: Attachment = element => {
|
const menuAttach: Attachment = (element) => {
|
||||||
const e = element as HTMLButtonElement
|
const e = element as HTMLButtonElement
|
||||||
|
|
||||||
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
||||||
|
|||||||
@@ -70,13 +70,13 @@
|
|||||||
<TextInput
|
<TextInput
|
||||||
{@attach attachment}
|
{@attach attachment}
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
oninput={e => {
|
oninput={(e) => {
|
||||||
searching = true
|
searching = true
|
||||||
openMenu = true
|
openMenu = true
|
||||||
oninput?.(e)
|
oninput?.(e)
|
||||||
debounceFunc()
|
debounceFunc()
|
||||||
}}
|
}}
|
||||||
onfocus={e => {
|
onfocus={(e) => {
|
||||||
searching = true
|
searching = true
|
||||||
openMenu = true
|
openMenu = true
|
||||||
oninput?.(e)
|
oninput?.(e)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<button
|
<button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
toast.action?.()
|
toast.action?.()
|
||||||
toasts.update(toasts => toasts.filter(t => t.id != toast.id))
|
toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
|
||||||
}}
|
}}
|
||||||
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer"
|
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer"
|
||||||
>
|
>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
toasts.update(toasts => toasts.filter(t => t.id != toast.id))
|
toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
|
||||||
}}
|
}}
|
||||||
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer text-slate-600 dark:text-zinc-400"
|
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer text-slate-600 dark:text-zinc-400"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ export function toast({
|
|||||||
}) {
|
}) {
|
||||||
let id = 0
|
let id = 0
|
||||||
|
|
||||||
toasts.update(toasts => {
|
toasts.update((toasts) => {
|
||||||
id = Math.max(0, ...toasts.map(t => t.id)) + 1
|
id = Math.max(0, ...toasts.map((t) => t.id)) + 1
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...toasts,
|
...toasts,
|
||||||
@@ -58,11 +58,11 @@ export function toast({
|
|||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toasts.update(toasts => toasts.filter(toast => toast.id != id))
|
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||||
}, duration)
|
}, duration)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeToast = (id: number) =>
|
export const removeToast = (id: number) =>
|
||||||
toasts.update(toasts => toasts.filter(toast => toast.id != id))
|
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||||
Loaded 100 of 193 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user