prettier: format project
This commit is contained in:
94 files changed
+261
-252
No files matched your search
+20
-20
@@ -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<number>(res => res(0))
|
||||
: new Promise<number>((res) => res(0))
|
||||
|
||||
const applicationsPromise = admin
|
||||
? getClient()
|
||||
.getUnreadRegistrationApplicationCount()
|
||||
.then(res => res.registration_applications)
|
||||
.then((res) => res.registration_applications)
|
||||
.catch(() => 0)
|
||||
: new Promise<number>(res => res(0))
|
||||
: new Promise<number>((res) => res(0))
|
||||
|
||||
const [unreads, reports, applications] = await Promise.all([
|
||||
unreadsPromise,
|
||||
|
||||
@@ -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),
|
||||
})),
|
||||
|
||||
@@ -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!),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface BlockInstanceResponse {
|
||||
blocked: boolean;
|
||||
blocked: boolean
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface CaptchaResponse {
|
||||
png: string;
|
||||
wav: string;
|
||||
uuid: string;
|
||||
png: string
|
||||
wav: string
|
||||
uuid: string
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface GenerateTotpSecretResponse {
|
||||
totp_secret_url: string;
|
||||
totp_secret_url: string
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface GetSiteMetadata {
|
||||
url: string;
|
||||
url: string
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface GetUnreadCountResponse {
|
||||
replies: number;
|
||||
mentions: number;
|
||||
private_messages: number;
|
||||
replies: number
|
||||
mentions: number
|
||||
private_messages: number
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||
registration_applications: number;
|
||||
registration_applications: number
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface SuccessResponse {
|
||||
success: boolean;
|
||||
success: boolean
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export interface UpdateTotpResponse {
|
||||
enabled: boolean;
|
||||
enabled: boolean
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -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'),
|
||||
)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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}
|
||||
<form
|
||||
class="flex flex-col gap-4"
|
||||
onsubmit={e => {
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
upload()
|
||||
}}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
{#if customUrl}
|
||||
<form
|
||||
onsubmit={e => {
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
if (!imageUrl) throw new Error('missing imageurl')
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
{:else}
|
||||
<ImageAttachForm
|
||||
multiple={false}
|
||||
onupload={uploaded => {
|
||||
onupload={(uploaded) => {
|
||||
open = false
|
||||
passedImageUrl = uploaded[0]
|
||||
}}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
{#if type == 'community'}
|
||||
<Search
|
||||
search={async q => {
|
||||
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 @@
|
||||
</Search>
|
||||
{:else if type == 'instance'}
|
||||
<Search
|
||||
search={async q => {
|
||||
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}
|
||||
>
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
</span>
|
||||
{/snippet}
|
||||
<ItemList
|
||||
items={admins.map(i => ({
|
||||
items={admins.map((i) => ({
|
||||
id: i.person.id,
|
||||
name: i.person.display_name || i.person.name,
|
||||
url: userLink(i.person),
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
<div>{$t('form.edit')}</div>
|
||||
{/snippet}
|
||||
<form
|
||||
onsubmit={e => {
|
||||
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: [],
|
||||
|
||||
@@ -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)}
|
||||
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
||||
<Comments
|
||||
bind:nodes={() => [nodes[index]], v => (nodes[index] = v[0])}
|
||||
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
||||
{post}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</script>
|
||||
|
||||
<form
|
||||
onsubmit={e => {
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
submit()
|
||||
}}
|
||||
|
||||
@@ -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 []
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export const modals = writable<Modals>({
|
||||
})
|
||||
|
||||
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) =>
|
||||
|
||||
@@ -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'}
|
||||
|
||||
@@ -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' })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
const abortLoad = new AbortController()
|
||||
let seenIds = new SvelteSet<number>(
|
||||
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)
|
||||
|
||||
@@ -18,7 +18,7 @@ export const combineCrossposts = (
|
||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||
const seenUrls = new SvelteSet<string>()
|
||||
|
||||
posts?.forEach(post => {
|
||||
posts?.forEach((post) => {
|
||||
if (
|
||||
!post ||
|
||||
(settings.hidePosts.deleted && post.post.deleted) ||
|
||||
|
||||
@@ -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 }}
|
||||
<UploadModal
|
||||
bind:open={uploadingImage}
|
||||
bind:imageUrl={() => '', v => (data.url = v)}
|
||||
bind:imageUrl={() => '', (v) => (data.url = v)}
|
||||
/>
|
||||
{/await}
|
||||
{/if}
|
||||
@@ -262,7 +262,7 @@
|
||||
{#if addAltText}
|
||||
<Modal title={$t('form.post.altText')} bind:open={addAltText}>
|
||||
<form
|
||||
onsubmit={e => {
|
||||
onsubmit={(e) => {
|
||||
e.preventDefault()
|
||||
addAltText = !addAltText
|
||||
}}
|
||||
@@ -277,7 +277,7 @@
|
||||
{/if}
|
||||
|
||||
<form
|
||||
onsubmit={e => {
|
||||
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
|
||||
|
||||
@@ -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}
|
||||
<Button
|
||||
onclick={e => {
|
||||
onclick={(e) => {
|
||||
e.stopPropagation()
|
||||
modal({
|
||||
title: 'Alt',
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</script>
|
||||
|
||||
<Search
|
||||
search={async q => {
|
||||
search={async (q) => {
|
||||
const users = (
|
||||
await getClient(instance).search({
|
||||
q: q || ' ',
|
||||
@@ -39,15 +39,15 @@
|
||||
listing_type: listing_type,
|
||||
sort: 'TopAll',
|
||||
})
|
||||
).users.map(c => c.person)
|
||||
).users.map((c) => c.person)
|
||||
|
||||
if (hideOwnUser) {
|
||||
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
|
||||
}}
|
||||
extractName={c => `${c.name}@${new URL(c.actor_id).hostname}`}
|
||||
extractName={(c) => `${c.name}@${new URL(c.actor_id).hostname}`}
|
||||
bind:query={q}
|
||||
{...rest}
|
||||
>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
disabled = false,
|
||||
rows = 2,
|
||||
// should be preprocess instead
|
||||
beforePreview = input => input,
|
||||
beforePreview = (input) => input,
|
||||
previewing = $bindable(false),
|
||||
class: clazz = '',
|
||||
customLabel,
|
||||
@@ -125,8 +125,8 @@
|
||||
<Modal title={$t('form.post.uploadImage')} bind:open={uploadingImage}>
|
||||
<ImageAttachForm
|
||||
bind:image
|
||||
onupload={e => {
|
||||
e.forEach(i => {
|
||||
onupload={(e) => {
|
||||
e.forEach((i) => {
|
||||
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"
|
||||
bind:value
|
||||
bind:element={textArea}
|
||||
onkeydown={e => {
|
||||
onkeydown={(e) => {
|
||||
if (disabled) return
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
handleKeydown(e)
|
||||
@@ -306,7 +306,7 @@
|
||||
}
|
||||
}}
|
||||
oninput={adjustHeight}
|
||||
onpaste={e => {
|
||||
onpaste={(e) => {
|
||||
if (!e.clipboardData?.files) return
|
||||
const files = Array.from(e.clipboardData.files)
|
||||
if (files[0]?.type.startsWith('image/')) {
|
||||
|
||||
@@ -101,7 +101,7 @@ const regexes = {
|
||||
/**
|
||||
* Convert links to photon links
|
||||
*/
|
||||
export const photonify = link => {
|
||||
export const photonify = (link) => {
|
||||
if (regexes.community.test(link)) {
|
||||
const match = link.match(regexes.community)
|
||||
if (!match) return
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
}
|
||||
}, debounceResize)
|
||||
|
||||
const observer = new ResizeObserver(entries => {
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
debouncedUpdate(entries)
|
||||
})
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
onMount(() => {
|
||||
if (virtualListEl && browser) {
|
||||
Array.from(virtualListEl.children).forEach(node => {
|
||||
Array.from(virtualListEl.children).forEach((node) => {
|
||||
const indexAttr = node.getAttribute('data-index')
|
||||
if (indexAttr === null) return
|
||||
const index = Number(indexAttr)
|
||||
@@ -207,7 +207,7 @@
|
||||
<svelte:window
|
||||
bind:scrollY={
|
||||
() => (useWindow ? scrollY : 0),
|
||||
v => {
|
||||
(v) => {
|
||||
if (useWindow) scrollY = v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
}: Props = $props()
|
||||
|
||||
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>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
flex flex-col z-100 backdrop-blur-xs"
|
||||
transition:fade={{ duration: 150 }}
|
||||
onclick={() => history.back()}
|
||||
onkeydown={e => {
|
||||
onkeydown={(e) => {
|
||||
if (e.key == 'Escape') history.back()
|
||||
}}
|
||||
use:focusTrap
|
||||
@@ -55,7 +55,7 @@
|
||||
rounding="full"
|
||||
padding="none"
|
||||
color="uniform"
|
||||
onclick={e => e.stopPropagation()}
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
onclick={() => {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
}: Props = $props()
|
||||
|
||||
let matchType = $derived<('search' | 'pathname')[]>(
|
||||
routes.map(i =>
|
||||
routes.map((i) =>
|
||||
new URL(`https://example.com${i.href}`)?.search != ''
|
||||
? 'search'
|
||||
: 'pathname',
|
||||
@@ -39,7 +39,7 @@
|
||||
const hrefSearch = new Set(href.searchParams.values())
|
||||
// checks if there is any
|
||||
const usePathname = !routes.some(
|
||||
i =>
|
||||
(i) =>
|
||||
new Set(
|
||||
new URL(`https://example.com${i.href}`).searchParams.values(),
|
||||
).intersection(currentSearch).size > 0,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
icon,
|
||||
href,
|
||||
adaptive = true,
|
||||
isSelectedFilter = path => href != undefined && path == href,
|
||||
isSelectedFilter = (path) => href != undefined && path == href,
|
||||
class: clazz = '',
|
||||
customIcon,
|
||||
children,
|
||||
|
||||
@@ -55,16 +55,16 @@
|
||||
|
||||
if (term.length < 1) {
|
||||
if (breadcrumbs.length <= 0) {
|
||||
filteredGroups = groups.map(group => ({
|
||||
filteredGroups = groups.map((group) => ({
|
||||
...group,
|
||||
actions: flattenActions(group.actions, false),
|
||||
}))
|
||||
}
|
||||
} else {
|
||||
filteredGroups = groups
|
||||
.map(group => {
|
||||
.map((group) => {
|
||||
const scoredActions = flattenActions(group.actions)
|
||||
.map(action => ({
|
||||
.map((action) => ({
|
||||
...action,
|
||||
score: Math.max(
|
||||
fuzzySearch(action.name, term),
|
||||
@@ -72,7 +72,7 @@
|
||||
action.detail ? fuzzySearch(action.detail, term) : -1,
|
||||
),
|
||||
}))
|
||||
.filter(action => action.score > 0)
|
||||
.filter((action) => action.score > 0)
|
||||
.sort((a, b) => b.score - a.score)
|
||||
|
||||
return {
|
||||
@@ -80,11 +80,11 @@
|
||||
actions: scoredActions,
|
||||
score: Math.max(
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@
|
||||
actions: Action[],
|
||||
subaction: boolean = true,
|
||||
): Action[] {
|
||||
return actions.flatMap(action => [
|
||||
return actions.flatMap((action) => [
|
||||
action,
|
||||
...(action.subActions && subaction
|
||||
? flattenActions(action.subActions)
|
||||
@@ -137,10 +137,10 @@
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.ctrlKey) {
|
||||
const actions = groups
|
||||
.flatMap(g => g.actions)
|
||||
.filter(a => a.shortcut != undefined)
|
||||
.flatMap((g) => g.actions)
|
||||
.filter((a) => a.shortcut != undefined)
|
||||
|
||||
actions.forEach(a => {
|
||||
actions.forEach((a) => {
|
||||
if (event.key === a.shortcut) {
|
||||
event.preventDefault()
|
||||
if (a.href) goto(a.href)
|
||||
@@ -220,7 +220,7 @@
|
||||
})
|
||||
|
||||
let flattenedActions = $derived(
|
||||
filteredGroups.flatMap(group => group.actions),
|
||||
filteredGroups.flatMap((group) => group.actions),
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -269,7 +269,7 @@
|
||||
>
|
||||
<CommandItem
|
||||
{action}
|
||||
onclick={e => {
|
||||
onclick={(e) => {
|
||||
if (action.href) {
|
||||
togglePalette()
|
||||
return
|
||||
|
||||
@@ -73,7 +73,7 @@ export function getGroups(
|
||||
return [
|
||||
{
|
||||
name: t.get('nav.commands.recents'),
|
||||
actions: resumables.map(r => ({
|
||||
actions: resumables.map((r) => ({
|
||||
name: r.name,
|
||||
icon: r.avatar ?? PencilSquare,
|
||||
href: r.url,
|
||||
@@ -306,7 +306,7 @@ export function getGroups(
|
||||
},
|
||||
{
|
||||
name: t.get('account.accounts'),
|
||||
actions: profiles.map(p => ({
|
||||
actions: profiles.map((p) => ({
|
||||
name: p.username ?? t.get('account.guest'),
|
||||
icon: p.avatar ?? UserCircle,
|
||||
detail: p.instance,
|
||||
@@ -379,7 +379,7 @@ export function getGroups(
|
||||
{
|
||||
name: t.get('nav.commands.setTheme'),
|
||||
icon: Swatch,
|
||||
subActions: td.themes.map(th => ({
|
||||
subActions: td.themes.map((th) => ({
|
||||
name: t.get('nav.commands.setThemeTo', { default: th.name }),
|
||||
icon: Swatch,
|
||||
handle: () => (theme.data.currentTheme = th.id),
|
||||
@@ -400,7 +400,7 @@ export function getGroups(
|
||||
{
|
||||
name: t.get('profile.subscribed'),
|
||||
actions:
|
||||
profile.user?.follows.map(f => ({
|
||||
profile.user?.follows.map((f) => ({
|
||||
icon: f.community.icon,
|
||||
name: f.community.title,
|
||||
href: `/c/${fullCommunityName(
|
||||
|
||||
@@ -92,8 +92,8 @@ function resumableStore(limit: number = 10) {
|
||||
set,
|
||||
update,
|
||||
add: (item: ResumableItem) => {
|
||||
update(resumables => {
|
||||
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item)))
|
||||
update((resumables) => {
|
||||
if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
|
||||
return resumables
|
||||
resumables.unshift(item)
|
||||
if (resumables.length > limit) resumables.pop()
|
||||
@@ -107,9 +107,9 @@ export const resumables = resumableStore()
|
||||
|
||||
export function addFavorite(item: Community, add: boolean = true) {
|
||||
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) {
|
||||
favs.splice(favs.map(c => c.id).indexOf(item.id), 1)
|
||||
favs.splice(favs.map((c) => c.id).indexOf(item.id), 1)
|
||||
} else {
|
||||
favs.unshift(item)
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ export const blockUser = async (block: boolean, id: number) => {
|
||||
}
|
||||
|
||||
export const isBlocked = (me: MyUserInfo, user: number) =>
|
||||
me.person_blocks.map(b => b.target.id).includes(user)
|
||||
me.person_blocks.map((b) => b.target.id).includes(user)
|
||||
|
||||
export const addSubscription = (
|
||||
community: Community,
|
||||
subscribe: boolean = true,
|
||||
) => {
|
||||
const index = profile.current.user?.follows
|
||||
.map(f => f.community.id)
|
||||
.map((f) => f.community.id)
|
||||
.indexOf(community.id)
|
||||
|
||||
if (subscribe && index == -1) {
|
||||
@@ -52,4 +52,4 @@ export const addAdmin = async (handle: string, added: boolean) =>
|
||||
})
|
||||
|
||||
export const hasFavorite = (profile: ProfileInfo, id: number): boolean =>
|
||||
profile.favorites?.map(i => i.id).includes(id) ?? false
|
||||
profile.favorites?.map((i) => i.id).includes(id) ?? false
|
||||
@@ -40,11 +40,11 @@
|
||||
'cursor-pointer min-h-36 transition-colors bg-white dark:bg-zinc-950',
|
||||
dragover && 'border-sky-500 text-sky-500',
|
||||
]}
|
||||
ondrop={event => {
|
||||
ondrop={(event) => {
|
||||
event.preventDefault()
|
||||
files = event.dataTransfer?.files ?? null
|
||||
}}
|
||||
ondragover={event => {
|
||||
ondragover={(event) => {
|
||||
event.preventDefault()
|
||||
|
||||
if (event.dataTransfer) {
|
||||
@@ -52,7 +52,7 @@
|
||||
dragover = true
|
||||
}
|
||||
}}
|
||||
ondragleave={e => {
|
||||
ondragleave={(e) => {
|
||||
e.preventDefault()
|
||||
dragover = false
|
||||
}}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
const context = getContext<SelectContext>('select')
|
||||
|
||||
$effect(() => {
|
||||
if ($locale || !context.options.find(v => v == option)) {
|
||||
const index = context.options.findIndex(i => i.value == option.value)
|
||||
if ($locale || !context.options.find((v) => v == option)) {
|
||||
const index = context.options.findIndex((i) => i.value == option.value)
|
||||
|
||||
if (index != -1) {
|
||||
context.options.splice(index, 1, option)
|
||||
@@ -44,7 +44,7 @@
|
||||
})
|
||||
|
||||
onDestroy(() => {
|
||||
const index = context.options.findIndex(i => i.value == option.value)
|
||||
const index = context.options.findIndex((i) => i.value == option.value)
|
||||
if (index != -1) {
|
||||
context.options.splice(index, 1)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
if (!isInHistory && open) {
|
||||
replaceState('', {
|
||||
openModals: currentModals.filter(id => id !== modalId),
|
||||
openModals: currentModals.filter((id) => id !== modalId),
|
||||
})
|
||||
hasHistoryEntry = false
|
||||
open = false
|
||||
@@ -85,7 +85,7 @@
|
||||
flex flex-col items-center justify-center backdrop-blur-xs
|
||||
bg-white/50 dark:bg-black/50 box-border p-4"
|
||||
transition:fade|global={{ duration: 100 }}
|
||||
onclick={e => {
|
||||
onclick={(e) => {
|
||||
// @ts-expect-error html node hell
|
||||
if (!el.contains(e.target)) onclose()
|
||||
}}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
},
|
||||
})
|
||||
|
||||
const menuAttach: Attachment = element => {
|
||||
const menuAttach: Attachment = (element) => {
|
||||
const e = element as HTMLButtonElement
|
||||
|
||||
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<button
|
||||
onclick={() => {
|
||||
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"
|
||||
>
|
||||
@@ -78,7 +78,7 @@
|
||||
{/if}
|
||||
<button
|
||||
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"
|
||||
>
|
||||
|
||||
@@ -40,8 +40,8 @@ export function toast({
|
||||
}) {
|
||||
let id = 0
|
||||
|
||||
toasts.update(toasts => {
|
||||
id = Math.max(0, ...toasts.map(t => t.id)) + 1
|
||||
toasts.update((toasts) => {
|
||||
id = Math.max(0, ...toasts.map((t) => t.id)) + 1
|
||||
|
||||
return [
|
||||
...toasts,
|
||||
@@ -58,11 +58,11 @@ export function toast({
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
toasts.update(toasts => toasts.filter(toast => toast.id != id))
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
}, duration)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
export const removeToast = (id: number) =>
|
||||
toasts.update(toasts => toasts.filter(toast => toast.id != id))
|
||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||
@@ -53,7 +53,7 @@ export function rgbToHex(rgbString: string): string {
|
||||
return rgbString
|
||||
}
|
||||
|
||||
const [r, g, b] = rgb.map(val => {
|
||||
const [r, g, b] = rgb.map((val) => {
|
||||
const num = parseInt(val, 10)
|
||||
if (isNaN(num) || num < 0 || num > 255) {
|
||||
return 0
|
||||
@@ -71,7 +71,7 @@ export function rgbToHex(rgbString: string): string {
|
||||
$effect.root(() => {
|
||||
$effect(() => {
|
||||
if (browser) {
|
||||
const filteredThemes = theme.data.themes.filter(t => t.id > 0)
|
||||
const filteredThemes = theme.data.themes.filter((t) => t.id > 0)
|
||||
localStorage.setItem(
|
||||
'theme.data',
|
||||
JSON.stringify({
|
||||
@@ -118,7 +118,7 @@ class ThemeState {
|
||||
},
|
||||
)
|
||||
#current = $derived(
|
||||
this.#data.themes.find(i => i.id == this.#data.currentTheme) ??
|
||||
this.#data.themes.find((i) => i.id == this.#data.currentTheme) ??
|
||||
getDefaultTheme(),
|
||||
)
|
||||
#colorScheme = $state<ColorScheme>(configuredColorScheme as ColorScheme)
|
||||
@@ -129,7 +129,7 @@ class ThemeState {
|
||||
}
|
||||
set current(value) {
|
||||
if (!value) return
|
||||
const index = this.#data.themes.findIndex(i => i.id == value?.id)
|
||||
const index = this.#data.themes.findIndex((i) => i.id == value?.id)
|
||||
this.#data.themes[index] = value
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const searchParam = (
|
||||
...deleteKeys: string[]
|
||||
) => {
|
||||
url.searchParams.set(key, value)
|
||||
deleteKeys.forEach(k => url.searchParams.delete(k))
|
||||
deleteKeys.forEach((k) => url.searchParams.delete(k))
|
||||
goto(url, {
|
||||
invalidateAll: true,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user