From cbd27a38a01028c72e41081ba21c60fa793d5627 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Sat, 6 Sep 2025 22:25:07 -0700 Subject: [PATCH 1/6] prettier: format project --- .prettierrc | 13 ++++-- src/lib/auth.svelte.ts | 40 +++++++++---------- src/lib/client/piefed/piefed.ts | 8 ++-- src/lib/client/piefed/rewrite.ts | 12 +++--- .../types/schemas/BlockInstanceResponse.ts | 2 +- .../client/types/schemas/CaptchaResponse.ts | 6 +-- .../schemas/GenerateTotpSecretResponse.ts | 2 +- .../client/types/schemas/GetSiteMetadata.ts | 2 +- .../types/schemas/GetUnreadCountResponse.ts | 6 +-- ...eadRegistrationApplicationCountResponse.ts | 2 +- src/lib/client/types/schemas/LoginResponse.ts | 6 +-- .../client/types/schemas/SuccessResponse.ts | 2 +- .../types/schemas/UpdateTotpResponse.ts | 2 +- .../components/error/ErrorContainer.svelte | 4 +- .../components/form/ImageAttachForm.svelte | 10 ++--- .../components/form/ImageInputModal.svelte | 4 +- .../lemmy/ObjectAutocomplete.svelte | 12 +++--- src/lib/components/lemmy/SiteCard.svelte | 2 +- .../components/lemmy/comment/Comment.svelte | 4 +- .../comment/CommentListVirtualizer.svelte | 6 +-- .../lemmy/comment/CommentTree.svelte | 2 +- .../lemmy/community/CommunityFlair.svelte | 2 +- .../lemmy/moderation/ViewVotesModal.svelte | 4 +- .../components/lemmy/moderation/moderation.ts | 10 ++--- src/lib/components/lemmy/post/Post.svelte | 4 +- src/lib/components/lemmy/post/PostVote.svelte | 4 +- .../lemmy/post/feed/VirtualFeed.svelte | 10 ++--- .../lemmy/post/feed/crosspost.svelte.ts | 2 +- .../lemmy/post/form/PostForm.svelte | 12 +++--- .../lemmy/post/media/PostImage.svelte | 4 +- .../lemmy/user/UserAutocomplete.svelte | 8 ++-- .../components/markdown/MarkdownEditor.svelte | 10 ++--- .../components/markdown/renderers/plugins.js | 2 +- src/lib/components/render/VirtualList.svelte | 6 +-- src/lib/components/ui/Avatar.svelte | 2 +- src/lib/components/ui/ExpandableImage.svelte | 4 +- .../components/ui/layout/pages/Tabs.svelte | 4 +- src/lib/components/ui/navbar/NavButton.svelte | 2 +- .../ui/navbar/commands/Commands.svelte | 24 +++++------ .../ui/navbar/commands/actions.svelte.ts | 8 ++-- src/lib/lemmy/item.ts | 8 ++-- src/lib/lemmy/user.ts | 6 +-- src/lib/mono/forms/ImageInput.svelte | 6 +-- src/lib/mono/forms/select/Option.svelte | 6 +-- src/lib/mono/modal/Modal.svelte | 4 +- src/lib/mono/popover/Popover.svelte | 2 +- src/lib/mono/toast/Toast.svelte | 4 +- src/lib/mono/toast/toasts.ts | 8 ++-- src/lib/ui/colors.svelte.ts | 8 ++-- src/lib/util.svelte.ts | 2 +- src/routes/+page.svelte | 4 +- src/routes/admin/applications/+page.svelte | 2 +- .../admin/applications/Application.svelte | 2 +- src/routes/admin/media/+page.svelte | 4 +- src/routes/admin/taglines/+page.svelte | 2 +- src/routes/c/[name]/+page.svelte | 8 ++-- .../c/[name]/settings/team/+page.svelte | 4 +- .../[instance]/[id]/confirm/+page.svelte | 2 +- src/routes/communities/+page.svelte | 6 +-- src/routes/create/post/+page.svelte | 2 +- src/routes/inbox/+page.svelte | 4 +- src/routes/inbox/+page.ts | 4 +- src/routes/inbox/InboxItem.svelte | 4 +- src/routes/inbox/messages/+page.svelte | 12 +++--- .../messages/[user_id=integer]/+page.svelte | 4 +- src/routes/instances/blocked/+page.svelte | 2 +- src/routes/instances/linked/+page.svelte | 2 +- src/routes/login/+page.svelte | 4 +- src/routes/login/guest/+page.svelte | 6 +-- src/routes/moderation/+page.svelte | 6 +-- src/routes/moderation/Report.svelte | 12 +++--- .../moderation/c/[id=integer]/+page.svelte | 2 +- src/routes/moderation/c/[id=integer]/+page.ts | 2 +- src/routes/modlog/+page.svelte | 10 ++--- .../post/[instance]/[id=integer]/+page.svelte | 4 +- .../post/[instance]/[id=integer]/+page.ts | 6 +-- .../[id=integer]/CommentProvider.svelte | 4 +- .../[id=integer]/confirm/+page.svelte | 2 +- .../profile/(local_user)/blocks/+page.svelte | 8 ++-- .../(local_user)/password/+layout.svelte | 2 +- .../(local_user)/password/2fa/+page.svelte | 2 +- .../(local_user)/password/change/+page.svelte | 2 +- .../(local_user)/password/delete/+page.svelte | 2 +- src/routes/profile/media/+page.svelte | 4 +- src/routes/saved/+page.svelte | 2 +- src/routes/search/+page.svelte | 6 +-- src/routes/settings/Setting.svelte | 2 +- src/routes/settings/ToggleSetting.svelte | 4 +- src/routes/settings/moderation/+page.svelte | 2 +- src/routes/signup/+page.svelte | 2 +- src/routes/signup/[instance]/+page.svelte | 2 +- src/routes/theme/+page.svelte | 14 +++---- src/routes/theme/ThemePreset.svelte | 4 +- src/service-worker.ts | 6 +-- 94 files changed, 261 insertions(+), 252 deletions(-) diff --git a/.prettierrc b/.prettierrc index 32a99389..ee14eb69 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,9 +1,16 @@ { - "arrowParens": "avoid", + "arrowParens": "always", "tabWidth": 2, "semi": false, "singleQuote": true, - "htmlWhitespaceSensitivity": "ignore", + "htmlWhitespaceSensitivity": "css", "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 } diff --git a/src/lib/auth.svelte.ts b/src/lib/auth.svelte.ts index 73ebb0c1..12e6aae6 100644 --- a/src/lib/auth.svelte.ts +++ b/src/lib/auth.svelte.ts @@ -61,8 +61,8 @@ const getCookie = (key: string): string | undefined => { return document?.cookie ?.split(';') - .map(c => c.trim()) - .find(c => c.split('=')?.[0] == key) + .map((c) => c.trim()) + .find((c) => c.split('=')?.[0] == key) ?.split('=')?.[1] } @@ -82,7 +82,7 @@ class Profile { }, ) #current = $derived( - this.meta.profiles.find(i => i.id == this.meta.profile) ?? + this.meta.profiles.find((i) => i.id == this.meta.profile) ?? this.getDefaultProfile(), ) @@ -123,7 +123,7 @@ class Profile { setInterval( () => { if (profile.current.jwt) - this.checkInbox().then(res => notifications.update(() => res)) + this.checkInbox().then((res) => notifications.update(() => res)) }, 4 * 60 * 1000, ) @@ -165,7 +165,7 @@ class Profile { } set current(value) { 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 } @@ -200,7 +200,7 @@ class Profile { site.data = undefined client({ instanceURL: this.#current.instance }) .getSite() - .then(res => (site.data = res)) + .then((res) => (site.data = res)) } } @@ -226,8 +226,8 @@ class Profile { async add(jwt: string, instance: string, type: ClientType) { const user = await userFromJwt(jwt, instance) - .then(u => u) - .catch(err => { + .then((u) => u) + .catch((err) => { toast({ content: errorMessage(err as string), type: 'error' }) }) if (!user?.user) { @@ -237,7 +237,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.profiles.unshift({ id: id, @@ -253,7 +253,7 @@ class Profile { remove(id: number) { this.meta.profiles.splice( - this.meta.profiles.findIndex(p => p.id == id), + this.meta.profiles.findIndex((p) => p.id == id), 1, ) if (id == this.meta.profile) this.meta.profile = -1 @@ -261,7 +261,7 @@ class Profile { move(id: number, up: boolean) { 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, index, @@ -277,7 +277,7 @@ class Profile { $effect(() => { const serialized = { ...this.meta, - profiles: this.meta.profiles.map(p => serializeUser(p)), + profiles: this.meta.profiles.map((p) => serializeUser(p)), } setFromStorage('profileData', serialized) @@ -292,7 +292,7 @@ class Profile { $effect(() => { this.fetchUserData().then(() => { if (this.current.jwt) - this.checkInbox().then(res => notifications.update(() => res)) + this.checkInbox().then((res) => notifications.update(() => res)) }) }) }) @@ -325,11 +325,11 @@ async function userFromJwt( ) const site = await sitePromise - .then(r => { + .then((r) => { clearTimeout(timer) return r }) - .catch(e => { + .catch((e) => { toast({ content: `Failed to contact the instance. ${e}` }) }) @@ -360,27 +360,27 @@ function serializeUser(user: ProfileInfo): ProfileInfo { async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) { const unreadsPromise = getClient() .getUnreadCount() - .then(res => res.mentions + res.private_messages + res.replies) + .then((res) => res.mentions + res.private_messages + res.replies) .catch(() => 0) const reportsPromise = mod ? getClient() .getReportCount({}) .then( - res => + (res) => res.comment_reports + res.post_reports + (res.private_message_reports ?? 0), ) .catch(() => 0) - : new Promise(res => res(0)) + : new Promise((res) => res(0)) const applicationsPromise = admin ? getClient() .getUnreadRegistrationApplicationCount() - .then(res => res.registration_applications) + .then((res) => res.registration_applications) .catch(() => 0) - : new Promise(res => res(0)) + : new Promise((res) => res(0)) const [unreads, reports, applications] = await Promise.all([ unreadsPromise, diff --git a/src/lib/client/piefed/piefed.ts b/src/lib/client/piefed/piefed.ts index 05bd6ec1..10d83f8c 100644 --- a/src/lib/client/piefed/piefed.ts +++ b/src/lib/client/piefed/piefed.ts @@ -113,7 +113,7 @@ export class PiefedClient implements BaseClient { return { community_view: toCommunityView(response.community_view), cross_posts: response.cross_posts.map(toPostView), - moderators: response.moderators.map(i => ({ + moderators: response.moderators.map((i) => ({ community: toCommunity(i.community), moderator: toPerson(i.moderator), })), @@ -261,7 +261,7 @@ export class PiefedClient implements BaseClient { return { ...response, community_view: toCommunityView(response.community_view), - moderators: response.moderators.map(i => ({ + moderators: response.moderators.map((i) => ({ community: toCommunity(i.community), moderator: toPerson(i.moderator), })), @@ -380,7 +380,7 @@ export class PiefedClient implements BaseClient { ).data! return { - moderators: response.moderators.map(i => ({ + moderators: response.moderators.map((i) => ({ community: toCommunity(i.community), moderator: toPerson(i.moderator), })), @@ -731,7 +731,7 @@ export class PiefedClient implements BaseClient { return { comments: response.comments.map(toCommentView), - moderates: response.moderates.map(i => ({ + moderates: response.moderates.map((i) => ({ community: toCommunity(i.community), moderator: toPerson(i.moderator), })), diff --git a/src/lib/client/piefed/rewrite.ts b/src/lib/client/piefed/rewrite.ts index 769ca84c..bdf36a80 100644 --- a/src/lib/client/piefed/rewrite.ts +++ b/src/lib/client/piefed/rewrite.ts @@ -86,7 +86,7 @@ export function toMyUser( ): MyUserInfo { return { ...myUser, - community_blocks: myUser.community_blocks.map(i => ({ + community_blocks: myUser.community_blocks.map((i) => ({ community: toCommunity(i.community), person: toPerson(i.person), })), @@ -101,23 +101,23 @@ export function toMyUser( }, person: toPerson(myUser.local_user_view.person), }, - follows: myUser.follows.map(i => ({ + follows: myUser.follows.map((i) => ({ follower: toPerson(i.follower), community: toCommunity(i.community), })), - moderates: myUser.moderates.map(i => ({ + moderates: myUser.moderates.map((i) => ({ community: toCommunity(i.community), moderator: toPerson(i.moderator), })), - instance_blocks: myUser.instance_blocks.map(i => ({ + instance_blocks: myUser.instance_blocks.map((i) => ({ instance: i.instance, person: toPerson(i.person), })), - person_blocks: myUser.person_blocks.map(i => ({ + person_blocks: myUser.person_blocks.map((i) => ({ person: toPerson(i.person), target: toPerson(i.target), })), - discussion_languages: myUser.discussion_languages.map(i => i.id!), + discussion_languages: myUser.discussion_languages.map((i) => i.id!), } } diff --git a/src/lib/client/types/schemas/BlockInstanceResponse.ts b/src/lib/client/types/schemas/BlockInstanceResponse.ts index a9a1f886..ba645ed5 100644 --- a/src/lib/client/types/schemas/BlockInstanceResponse.ts +++ b/src/lib/client/types/schemas/BlockInstanceResponse.ts @@ -1,3 +1,3 @@ export interface BlockInstanceResponse { - blocked: boolean; + blocked: boolean } diff --git a/src/lib/client/types/schemas/CaptchaResponse.ts b/src/lib/client/types/schemas/CaptchaResponse.ts index 60537f31..d3550f58 100644 --- a/src/lib/client/types/schemas/CaptchaResponse.ts +++ b/src/lib/client/types/schemas/CaptchaResponse.ts @@ -1,5 +1,5 @@ export interface CaptchaResponse { - png: string; - wav: string; - uuid: string; + png: string + wav: string + uuid: string } diff --git a/src/lib/client/types/schemas/GenerateTotpSecretResponse.ts b/src/lib/client/types/schemas/GenerateTotpSecretResponse.ts index 6487ed95..c7f08418 100644 --- a/src/lib/client/types/schemas/GenerateTotpSecretResponse.ts +++ b/src/lib/client/types/schemas/GenerateTotpSecretResponse.ts @@ -1,3 +1,3 @@ export interface GenerateTotpSecretResponse { - totp_secret_url: string; + totp_secret_url: string } diff --git a/src/lib/client/types/schemas/GetSiteMetadata.ts b/src/lib/client/types/schemas/GetSiteMetadata.ts index e655e89b..ea5cb055 100644 --- a/src/lib/client/types/schemas/GetSiteMetadata.ts +++ b/src/lib/client/types/schemas/GetSiteMetadata.ts @@ -1,3 +1,3 @@ export interface GetSiteMetadata { - url: string; + url: string } diff --git a/src/lib/client/types/schemas/GetUnreadCountResponse.ts b/src/lib/client/types/schemas/GetUnreadCountResponse.ts index afd20066..9311d98f 100644 --- a/src/lib/client/types/schemas/GetUnreadCountResponse.ts +++ b/src/lib/client/types/schemas/GetUnreadCountResponse.ts @@ -1,5 +1,5 @@ export interface GetUnreadCountResponse { - replies: number; - mentions: number; - private_messages: number; + replies: number + mentions: number + private_messages: number } diff --git a/src/lib/client/types/schemas/GetUnreadRegistrationApplicationCountResponse.ts b/src/lib/client/types/schemas/GetUnreadRegistrationApplicationCountResponse.ts index d1a82db2..432c861a 100644 --- a/src/lib/client/types/schemas/GetUnreadRegistrationApplicationCountResponse.ts +++ b/src/lib/client/types/schemas/GetUnreadRegistrationApplicationCountResponse.ts @@ -1,3 +1,3 @@ export interface GetUnreadRegistrationApplicationCountResponse { - registration_applications: number; + registration_applications: number } diff --git a/src/lib/client/types/schemas/LoginResponse.ts b/src/lib/client/types/schemas/LoginResponse.ts index 425733fb..c72e4bec 100644 --- a/src/lib/client/types/schemas/LoginResponse.ts +++ b/src/lib/client/types/schemas/LoginResponse.ts @@ -1,5 +1,5 @@ export interface LoginResponse { - jwt?: string; - registration_created: boolean; - verify_email_sent: boolean; + jwt?: string + registration_created: boolean + verify_email_sent: boolean } diff --git a/src/lib/client/types/schemas/SuccessResponse.ts b/src/lib/client/types/schemas/SuccessResponse.ts index e0dd3705..f43a513f 100644 --- a/src/lib/client/types/schemas/SuccessResponse.ts +++ b/src/lib/client/types/schemas/SuccessResponse.ts @@ -1,3 +1,3 @@ export interface SuccessResponse { - success: boolean; + success: boolean } diff --git a/src/lib/client/types/schemas/UpdateTotpResponse.ts b/src/lib/client/types/schemas/UpdateTotpResponse.ts index eaa16512..c1a3de6d 100644 --- a/src/lib/client/types/schemas/UpdateTotpResponse.ts +++ b/src/lib/client/types/schemas/UpdateTotpResponse.ts @@ -1,3 +1,3 @@ export interface UpdateTotpResponse { - enabled: boolean; + enabled: boolean } diff --git a/src/lib/components/error/ErrorContainer.svelte b/src/lib/components/error/ErrorContainer.svelte index 260bddad..88db397c 100644 --- a/src/lib/components/error/ErrorContainer.svelte +++ b/src/lib/components/error/ErrorContainer.svelte @@ -11,7 +11,7 @@ } export function clearErrorScope(scope: string | null | undefined) { - errors = errors.filter(error => error.scope != scope) + errors = errors.filter((error) => error.scope != scope) } @@ -32,7 +32,7 @@ let { scope = undefined, class: clazz = '' }: Props = $props() let scopedErrors = $derived( - errors.filter(e => e.scope == scope || e.scope == 'global'), + errors.filter((e) => e.scope == scope || e.scope == 'global'), ) diff --git a/src/lib/components/form/ImageAttachForm.svelte b/src/lib/components/form/ImageAttachForm.svelte index 7547917b..f9b4c936 100644 --- a/src/lib/components/form/ImageAttachForm.svelte +++ b/src/lib/components/form/ImageAttachForm.svelte @@ -36,19 +36,19 @@ try { const uploaded = ( await Promise.all( - Array.from(image).map(i => + Array.from(image).map((i) => uploadImage(i, profile.current.instance, profile.current.jwt!) - .then(uploaded => { + .then((uploaded) => { progress += 1 / (image?.length ?? 0) return uploaded }) - .catch(err => { + .catch((err) => { toast({ content: errorMessage(err), type: 'error' }) return 'Failed to upload' }), ), ) - ).filter(i => i != undefined) + ).filter((i) => i != undefined) if (!uploaded) throw new Error('Image upload returned undefined') @@ -72,7 +72,7 @@ {/if}
{ + onsubmit={(e) => { e.preventDefault() upload() }} diff --git a/src/lib/components/form/ImageInputModal.svelte b/src/lib/components/form/ImageInputModal.svelte index d93b1456..58045c45 100644 --- a/src/lib/components/form/ImageInputModal.svelte +++ b/src/lib/components/form/ImageInputModal.svelte @@ -35,7 +35,7 @@ {#if customUrl} { + onsubmit={(e) => { e.preventDefault() if (!imageUrl) throw new Error('missing imageurl') @@ -60,7 +60,7 @@ {:else} { + onupload={(uploaded) => { open = false passedImageUrl = uploaded[0] }} diff --git a/src/lib/components/lemmy/ObjectAutocomplete.svelte b/src/lib/components/lemmy/ObjectAutocomplete.svelte index d52deca3..90107304 100644 --- a/src/lib/components/lemmy/ObjectAutocomplete.svelte +++ b/src/lib/components/lemmy/ObjectAutocomplete.svelte @@ -34,7 +34,7 @@ {#if type == 'community'} { + search={async (q) => { const results = await getClient(instance).search({ q: q || ' ', type_: 'Communities', @@ -43,9 +43,9 @@ 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} {...rest} > @@ -79,16 +79,16 @@ {:else if type == 'instance'} { + search={async (q) => { const results = (await instances) || {} return q ? (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} {...rest} > diff --git a/src/lib/components/lemmy/SiteCard.svelte b/src/lib/components/lemmy/SiteCard.svelte index 90f27416..6e70dab5 100644 --- a/src/lib/components/lemmy/SiteCard.svelte +++ b/src/lib/components/lemmy/SiteCard.svelte @@ -147,7 +147,7 @@ {/snippet} ({ + items={admins.map((i) => ({ id: i.person.id, name: i.person.display_name || i.person.name, url: userLink(i.person), diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index 27d48715..58e98aaf 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -94,7 +94,7 @@
{$t('form.edit')}
{/snippet} { + onsubmit={(e) => { e.preventDefault() save(replying ? 'reply' : 'edit') }} @@ -262,7 +262,7 @@ label={$t('comment.reply')} {postId} parentId={node.comment_view.comment.id} - oncomment={e => { + oncomment={(e) => { node.children = [ { children: [], diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index a7d16901..bfd701f6 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -19,8 +19,8 @@ }, 100) } - const observer = new ResizeObserver(entries => { - entries.forEach(entry => { + const observer = new ResizeObserver((entries) => { + entries.forEach((entry) => { if (offsetEl) { initialOffset = entry.target.getBoundingClientRect().top + window.scrollY @@ -50,7 +50,7 @@ {#snippet item(index)}
[nodes[index]], v => (nodes[index] = v[0])} + bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])} {post} />
diff --git a/src/lib/components/lemmy/comment/CommentTree.svelte b/src/lib/components/lemmy/comment/CommentTree.svelte index ac3d254c..b75b674c 100644 --- a/src/lib/components/lemmy/comment/CommentTree.svelte +++ b/src/lib/components/lemmy/comment/CommentTree.svelte @@ -54,7 +54,7 @@ // 0.18.2 -> 0.18.3 broke this // so i'm adding this check 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) { diff --git a/src/lib/components/lemmy/community/CommunityFlair.svelte b/src/lib/components/lemmy/community/CommunityFlair.svelte index ac71112c..5949b5d1 100644 --- a/src/lib/components/lemmy/community/CommunityFlair.svelte +++ b/src/lib/components/lemmy/community/CommunityFlair.svelte @@ -33,7 +33,7 @@ { + onsubmit={(e) => { e.preventDefault() submit() }} diff --git a/src/lib/components/lemmy/moderation/ViewVotesModal.svelte b/src/lib/components/lemmy/moderation/ViewVotesModal.svelte index d3696909..43857a8f 100644 --- a/src/lib/components/lemmy/moderation/ViewVotesModal.svelte +++ b/src/lib/components/lemmy/moderation/ViewVotesModal.svelte @@ -29,7 +29,7 @@ if (isPostView(item)) return await client() .listPostLikes({ post_id: item.post.id, limit: 50, page: page }) - .then(i => i.post_likes) + .then((i) => i.post_likes) if (isCommentView(item)) return await client() .listCommentLikes({ @@ -37,7 +37,7 @@ limit: 50, page: page, }) - .then(i => i.comment_likes) + .then((i) => i.comment_likes) return [] } diff --git a/src/lib/components/lemmy/moderation/moderation.ts b/src/lib/components/lemmy/moderation/moderation.ts index ba7d5515..89a4ae1e 100644 --- a/src/lib/components/lemmy/moderation/moderation.ts +++ b/src/lib/components/lemmy/moderation/moderation.ts @@ -55,7 +55,7 @@ export const modals = writable({ }) export function report(item: PostView | CommentView | PrivateMessageView) { - modals.update(m => ({ + modals.update((m) => ({ ...m, reporting: { open: true, @@ -65,7 +65,7 @@ export function report(item: PostView | CommentView | PrivateMessageView) { } export function remove(item: SubmissionView, purge: boolean = false) { - modals.update(m => ({ + modals.update((m) => ({ ...m, removing: { open: true, @@ -76,7 +76,7 @@ export function remove(item: SubmissionView, purge: boolean = false) { } export function ban(banned: boolean, item: Person, community?: Community) { - modals.update(m => ({ + modals.update((m) => ({ ...m, banning: { open: true, @@ -95,7 +95,7 @@ export async function feature(featured: boolean, item: Comment, jwt: string) { } export async function viewVotes(item: PostView | CommentView) { - modals.update(m => ({ + modals.update((m) => ({ ...m, votes: { open: true, @@ -105,7 +105,7 @@ export async function viewVotes(item: PostView | CommentView) { } 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)) export const amModOfAny = (me?: MyUserInfo) => diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 2c5a5f90..0c844c3f 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -15,7 +15,7 @@ import PostBody from './PostBody.svelte' 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 if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw)) @@ -94,7 +94,7 @@ published={publishedToDate(post.post.published)} {badges} subscribed={profile.current?.user?.follows - .map(c => c.community.id) + .map((c) => c.community.id) .includes(post.community.id) ? 'Subscribed' : 'NotSubscribed'} diff --git a/src/lib/components/lemmy/post/PostVote.svelte b/src/lib/components/lemmy/post/PostVote.svelte index b8993f8a..a7d409eb 100644 --- a/src/lib/components/lemmy/post/PostVote.svelte +++ b/src/lib/components/lemmy/post/PostVote.svelte @@ -76,8 +76,8 @@ vote = newVote voteItem(post, newVote) - .then(res => ({ upvotes, downvotes, score } = res)) - .catch(e => { + .then((res) => ({ upvotes, downvotes, score } = res)) + .catch((e) => { toast({ content: errorMessage(e), type: 'error' }) }) } diff --git a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte index 2090c79a..fc6f1814 100644 --- a/src/lib/components/lemmy/post/feed/VirtualFeed.svelte +++ b/src/lib/components/lemmy/post/feed/VirtualFeed.svelte @@ -54,7 +54,7 @@ const abortLoad = new AbortController() let seenIds = new SvelteSet( - feedData.posts.posts.map(post => post.post.id), + feedData.posts.posts.map((post) => post.post.id), ) async function loadMore() { @@ -80,7 +80,7 @@ sort: feedData.sort, type_: feedData.type_, }) - .catch(e => { + .catch((e) => { throw new Error(e) }) @@ -90,7 +90,7 @@ feedData.cursor.next = newPosts.next_page feedData.posts.posts.push( - ...newPosts.posts.filter(post => { + ...newPosts.posts.filter((post) => { if (seenIds.has(post.post.id)) return false seenIds.add(post.post.id) return true @@ -107,7 +107,7 @@ } const callback: IntersectionObserverCallback = (entries, observer) => { - entries.forEach(entry => { + entries.forEach((entry) => { if (!entry.isIntersecting) return const element = entry.target as HTMLElement @@ -147,7 +147,7 @@ const feed = document.getElementById('feed') if (!feed) return - new MutationObserver(mutations => { + new MutationObserver((mutations) => { mutations.forEach(({ addedNodes, removedNodes }) => { addedNodes.forEach(observePost) removedNodes.forEach(unobservePost) diff --git a/src/lib/components/lemmy/post/feed/crosspost.svelte.ts b/src/lib/components/lemmy/post/feed/crosspost.svelte.ts index b6449b39..742502ad 100644 --- a/src/lib/components/lemmy/post/feed/crosspost.svelte.ts +++ b/src/lib/components/lemmy/post/feed/crosspost.svelte.ts @@ -18,7 +18,7 @@ export const combineCrossposts = ( const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = [] const seenUrls = new SvelteSet() - posts?.forEach(post => { + posts?.forEach((post) => { if ( !post || (settings.hidePosts.deleted && post.post.deleted) || diff --git a/src/lib/components/lemmy/post/form/PostForm.svelte b/src/lib/components/lemmy/post/form/PostForm.svelte index 030d7711..7dc790d1 100644 --- a/src/lib/components/lemmy/post/form/PostForm.svelte +++ b/src/lib/components/lemmy/post/form/PostForm.svelte @@ -116,7 +116,7 @@ limit: 40, }) - communities = list.communities.map(c => c.community) + communities = list.communities.map((c) => c.community) } }) @@ -209,7 +209,7 @@ if (res.metadata.description) data.body = res.metadata.description .split('\n') - .map(l => `> ${l}`) + .map((l) => `> ${l}`) .join('\n') toast({ @@ -254,7 +254,7 @@ {#await import('$lib/components/form/ImageInputModal.svelte') then { default: UploadModal }} '', v => (data.url = v)} + bind:imageUrl={() => '', (v) => (data.url = v)} /> {/await} {/if} @@ -262,7 +262,7 @@ {#if addAltText} { + onsubmit={(e) => { e.preventDefault() addAltText = !addAltText }} @@ -277,7 +277,7 @@ {/if} { + onsubmit={(e) => { e.preventDefault() submit() }} @@ -298,7 +298,7 @@ listing_type="All" label={$t('form.post.community')} required - onselect={e => { + onselect={(e) => { const c = e if (!c) { data.community = null diff --git a/src/lib/components/lemmy/post/media/PostImage.svelte b/src/lib/components/lemmy/post/media/PostImage.svelte index f0e07764..be13dbf8 100644 --- a/src/lib/components/lemmy/post/media/PostImage.svelte +++ b/src/lib/components/lemmy/post/media/PostImage.svelte @@ -88,11 +88,11 @@ 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 *: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} diff --git a/src/lib/components/lemmy/community/CommunityForm.svelte b/src/lib/components/lemmy/community/CommunityForm.svelte index ff772e53..ea888edc 100644 --- a/src/lib/components/lemmy/community/CommunityForm.svelte +++ b/src/lib/components/lemmy/community/CommunityForm.svelte @@ -3,25 +3,25 @@ import { profile } from '$lib/auth.svelte.js' import ImageInputUpload from '$lib/components/form/ImageInputUpload.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 { getClient, site } from '$lib/client/lemmy.svelte' + import { client, site } from '$lib/client/lemmy.svelte' import { errorMessage } from '$lib/lemmy/error' import { addSubscription } from '$lib/lemmy/user.js' import { Badge, Button, + Label, MenuButton, Switch, TextInput, toast, + Option, + Select, + Material, + Menu } 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 { Header } from '$lib/components/ui/layout' interface Props { /** @@ -68,7 +68,7 @@ try { const res = edit - ? await getClient().editCommunity({ + ? await client().editCommunity({ title: formData.displayName, description: formData.sidebar, nsfw: formData.nsfw, @@ -79,7 +79,7 @@ visibility: formData.visibility, discussion_languages: formData.languages, }) - : await getClient().createCommunity({ + : await client().createCommunity({ name: formData.name, title: formData.displayName, description: formData.sidebar, @@ -146,7 +146,7 @@ class="flex flex-col gap-4 h-full w-full" > {#if formtitle}{@render formtitle()}{:else} -
{$t('routes.createCommunity')}
+
{$t('form.post.community')}
{/if}
- {$t('form.profile.languages.title')} + {#if site.data}
diff --git a/src/lib/components/lemmy/community/CommunityItem.svelte b/src/lib/components/lemmy/community/CommunityItem.svelte index c06a5a7c..180226ed 100644 --- a/src/lib/components/lemmy/community/CommunityItem.svelte +++ b/src/lib/components/lemmy/community/CommunityItem.svelte @@ -1,6 +1,5 @@ - - - {@render children?.()} - diff --git a/src/lib/components/ui/StickyCard.svelte b/src/lib/components/ui/StickyCard.svelte deleted file mode 100644 index 08578fa6..00000000 --- a/src/lib/components/ui/StickyCard.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/src/lib/components/ui/Pageination.svelte b/src/lib/components/ui/layout/Pageination.svelte similarity index 100% rename from src/lib/components/ui/Pageination.svelte rename to src/lib/components/ui/layout/Pageination.svelte diff --git a/src/routes/search/SearchBar.svelte b/src/lib/components/ui/layout/SearchBar.svelte similarity index 100% rename from src/routes/search/SearchBar.svelte rename to src/lib/components/ui/layout/SearchBar.svelte diff --git a/src/lib/components/ui/layout/index.ts b/src/lib/components/ui/layout/index.ts new file mode 100644 index 00000000..efb51d71 --- /dev/null +++ b/src/lib/components/ui/layout/index.ts @@ -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' diff --git a/src/lib/components/ui/navbar/Profile.svelte b/src/lib/components/ui/navbar/Profile.svelte index d4f4b7bd..fbabdc05 100644 --- a/src/lib/components/ui/navbar/Profile.svelte +++ b/src/lib/components/ui/navbar/Profile.svelte @@ -6,7 +6,7 @@ isAdmin, } 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 { site } from '$lib/client/lemmy.svelte' import { settings } from '$lib/settings.svelte' diff --git a/src/lib/mono/forms/Label.svelte b/src/lib/mono/forms/Label.svelte index cd8d106f..f8dd41ed 100644 --- a/src/lib/mono/forms/Label.svelte +++ b/src/lib/mono/forms/Label.svelte @@ -22,7 +22,8 @@ }: Props = $props() -