prettier: format project
This commit is contained in:
94 files changed
+261
-252
No files matched your search
+10
-3
@@ -1,9 +1,16 @@
|
|||||||
{
|
{
|
||||||
"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
|
||||||
}
|
}
|
||||||
+20
-20
@@ -61,8 +61,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 +82,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 +123,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 +165,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 +200,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 +226,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 +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.profile = id
|
||||||
this.meta.profiles.unshift({
|
this.meta.profiles.unshift({
|
||||||
id: id,
|
id: id,
|
||||||
@@ -253,7 +253,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 +261,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 +277,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 +292,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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -325,11 +325,11 @@ async function userFromJwt(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const site = await sitePromise
|
const site = await sitePromise
|
||||||
.then(r => {
|
.then((r) => {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
return r
|
return r
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
toast({ content: `Failed to contact the instance. ${e}` })
|
toast({ content: `Failed to contact the instance. ${e}` })
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -360,27 +360,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,
|
||||||
|
|||||||
@@ -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),
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -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]
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -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}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -94,7 +94,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')
|
||||||
}}
|
}}
|
||||||
@@ -262,7 +262,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: [],
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -54,7 +54,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) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -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 []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,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 +65,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 +76,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 +95,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 +105,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) =>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
import PostBody from './PostBody.svelte'
|
import PostBody from './PostBody.svelte'
|
||||||
|
|
||||||
function getTagRule(tags: Tag[]): 'blur-sm' | 'hide' | undefined {
|
function getTagRule(tags: Tag[]): 'blur-sm' | 'hide' | undefined {
|
||||||
const tagContent = tags.map(t => t.content.toLowerCase())
|
const tagContent = tags.map((t) => t.content.toLowerCase())
|
||||||
|
|
||||||
let rule: 'blur-sm' | 'hide' | undefined
|
let rule: 'blur-sm' | 'hide' | undefined
|
||||||
if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw))
|
if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw))
|
||||||
@@ -94,7 +94,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'}
|
||||||
|
|||||||
@@ -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' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const combineCrossposts = (
|
|||||||
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||||
const seenUrls = new SvelteSet<string>()
|
const seenUrls = new SvelteSet<string>()
|
||||||
|
|
||||||
posts?.forEach(post => {
|
posts?.forEach((post) => {
|
||||||
if (
|
if (
|
||||||
!post ||
|
!post ||
|
||||||
(settings.hidePosts.deleted && post.post.deleted) ||
|
(settings.hidePosts.deleted && post.post.deleted) ||
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
limit: 40,
|
limit: 40,
|
||||||
})
|
})
|
||||||
|
|
||||||
communities = list.communities.map(c => c.community)
|
communities = list.communities.map((c) => c.community)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -209,7 +209,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 +254,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 +262,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 +277,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
submit()
|
submit()
|
||||||
}}
|
}}
|
||||||
@@ -298,7 +298,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
|
||||||
|
|||||||
@@ -88,11 +88,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',
|
||||||
|
|||||||
@@ -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}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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/')) {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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={() => {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ export const blockUser = async (block: boolean, id: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const isBlocked = (me: MyUserInfo, user: number) =>
|
export const isBlocked = (me: MyUserInfo, user: number) =>
|
||||||
me.person_blocks.map(b => b.target.id).includes(user)
|
me.person_blocks.map((b) => b.target.id).includes(user)
|
||||||
|
|
||||||
export const addSubscription = (
|
export const addSubscription = (
|
||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true,
|
subscribe: boolean = true,
|
||||||
) => {
|
) => {
|
||||||
const index = profile.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) {
|
||||||
@@ -52,4 +52,4 @@ export const addAdmin = async (handle: string, added: boolean) =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const hasFavorite = (profile: ProfileInfo, id: number): 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',
|
'cursor-pointer min-h-36 transition-colors bg-white dark:bg-zinc-950',
|
||||||
dragover && 'border-sky-500 text-sky-500',
|
dragover && 'border-sky-500 text-sky-500',
|
||||||
]}
|
]}
|
||||||
ondrop={event => {
|
ondrop={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
files = event.dataTransfer?.files ?? null
|
files = event.dataTransfer?.files ?? null
|
||||||
}}
|
}}
|
||||||
ondragover={event => {
|
ondragover={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
if (event.dataTransfer) {
|
if (event.dataTransfer) {
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
dragover = true
|
dragover = true
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
ondragleave={e => {
|
ondragleave={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
dragover = false
|
dragover = false
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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))
|
||||||
@@ -53,7 +53,7 @@ export function rgbToHex(rgbString: string): string {
|
|||||||
return rgbString
|
return rgbString
|
||||||
}
|
}
|
||||||
|
|
||||||
const [r, g, b] = rgb.map(val => {
|
const [r, g, b] = rgb.map((val) => {
|
||||||
const num = parseInt(val, 10)
|
const num = parseInt(val, 10)
|
||||||
if (isNaN(num) || num < 0 || num > 255) {
|
if (isNaN(num) || num < 0 || num > 255) {
|
||||||
return 0
|
return 0
|
||||||
@@ -71,7 +71,7 @@ export function rgbToHex(rgbString: string): string {
|
|||||||
$effect.root(() => {
|
$effect.root(() => {
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const filteredThemes = theme.data.themes.filter(t => t.id > 0)
|
const filteredThemes = theme.data.themes.filter((t) => t.id > 0)
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
'theme.data',
|
'theme.data',
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -118,7 +118,7 @@ class ThemeState {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
#current = $derived(
|
#current = $derived(
|
||||||
this.#data.themes.find(i => i.id == this.#data.currentTheme) ??
|
this.#data.themes.find((i) => i.id == this.#data.currentTheme) ??
|
||||||
getDefaultTheme(),
|
getDefaultTheme(),
|
||||||
)
|
)
|
||||||
#colorScheme = $state<ColorScheme>(configuredColorScheme as ColorScheme)
|
#colorScheme = $state<ColorScheme>(configuredColorScheme as ColorScheme)
|
||||||
@@ -129,7 +129,7 @@ class ThemeState {
|
|||||||
}
|
}
|
||||||
set current(value) {
|
set current(value) {
|
||||||
if (!value) return
|
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
|
this.#data.themes[index] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const searchParam = (
|
|||||||
...deleteKeys: string[]
|
...deleteKeys: string[]
|
||||||
) => {
|
) => {
|
||||||
url.searchParams.set(key, value)
|
url.searchParams.set(key, value)
|
||||||
deleteKeys.forEach(k => url.searchParams.delete(k))
|
deleteKeys.forEach((k) => url.searchParams.delete(k))
|
||||||
goto(url, {
|
goto(url, {
|
||||||
invalidateAll: true,
|
invalidateAll: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
{:then feed}
|
{:then feed}
|
||||||
<FeedComponent
|
<FeedComponent
|
||||||
bind:posts={feed.posts.posts}
|
bind:posts={feed.posts.posts}
|
||||||
bind:feedData={() => feed, v => (postFeeds.value.main.data = v)}
|
bind:feedData={() => feed, (v) => (postFeeds.value.main.data = v)}
|
||||||
feedId="main"
|
feedId="main"
|
||||||
/>
|
/>
|
||||||
<svelte:element
|
<svelte:element
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<Pageination
|
<Pageination
|
||||||
cursor={{ next: feed.cursor.next }}
|
cursor={{ next: feed.cursor.next }}
|
||||||
href={page =>
|
href={(page) =>
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
||||||
back={false}
|
back={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if data.applications?.value.length >= 40}
|
{#if data.applications?.value.length >= 40}
|
||||||
<div class="mt-auto">
|
<div class="mt-auto">
|
||||||
<Pageination page={data.page} href={page => `?page=${page}`} />
|
<Pageination page={data.page} href={(page) => `?page=${page}`} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
} else {
|
} else {
|
||||||
reviewing = true
|
reviewing = true
|
||||||
while (reviewing) {
|
while (reviewing) {
|
||||||
await new Promise(res => setTimeout(res, 1000))
|
await new Promise((res) => setTimeout(res, 1000))
|
||||||
}
|
}
|
||||||
if (!denying) {
|
if (!denying) {
|
||||||
denyReason = ''
|
denyReason = ''
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
ondelete={() => {
|
ondelete={() => {
|
||||||
data.images.value = data.images.value.toSpliced(
|
data.images.value = data.images.value.toSpliced(
|
||||||
data.images.value.findIndex(
|
data.images.value.findIndex(
|
||||||
i =>
|
(i) =>
|
||||||
i.local_image.pictrs_delete_token ==
|
i.local_image.pictrs_delete_token ==
|
||||||
image.local_image.pictrs_delete_token,
|
image.local_image.pictrs_delete_token,
|
||||||
),
|
),
|
||||||
@@ -34,6 +34,6 @@
|
|||||||
{#if data.images.value.length == 20}
|
{#if data.images.value.length == 20}
|
||||||
<Pageination
|
<Pageination
|
||||||
page={Number(page.url.searchParams.get('page')) || 1}
|
page={Number(page.url.searchParams.get('page')) || 1}
|
||||||
href={page => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<Button
|
<Button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
taglines.splice(
|
taglines.splice(
|
||||||
taglines.findIndex(i => i == tagline),
|
taglines.findIndex((i) => i == tagline),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -84,9 +84,9 @@
|
|||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
{#if profile.current.user}
|
{#if profile.current.user}
|
||||||
{#if !data.community.value.discussion_languages.every( l => profile.current.user?.discussion_languages.includes(l), ) && profile.current.user.discussion_languages.length > 0}
|
{#if !data.community.value.discussion_languages.every( (l) => profile.current.user?.discussion_languages.includes(l), ) && profile.current.user.discussion_languages.length > 0}
|
||||||
{@const missing = data.community.value.discussion_languages.filter(
|
{@const missing = data.community.value.discussion_languages.filter(
|
||||||
i => !profile.current.user?.discussion_languages.includes(i),
|
(i) => !profile.current.user?.discussion_languages.includes(i),
|
||||||
)}
|
)}
|
||||||
<Note class="p-1! pl-3! flex-col md:flex-row">
|
<Note class="p-1! pl-3! flex-col md:flex-row">
|
||||||
<div>{$t('routes.community.languageWarning')}</div>
|
<div>{$t('routes.community.languageWarning')}</div>
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
<a href="/profile/settings#languages" class="inline-block w-max">
|
<a href="/profile/settings#languages" class="inline-block w-max">
|
||||||
<Badge color="blue-subtle">
|
<Badge color="blue-subtle">
|
||||||
<Icon src={Plus} size="16" micro />
|
<Icon src={Plus} size="16" micro />
|
||||||
{allLanguages.find(i => language == i.id)?.name}
|
{allLanguages.find((i) => language == i.id)?.name}
|
||||||
</Badge>
|
</Badge>
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
<Pageination
|
<Pageination
|
||||||
page={data.page}
|
page={data.page}
|
||||||
cursor={{ next: data.cursor.next }}
|
cursor={{ next: data.cursor.next }}
|
||||||
href={page =>
|
href={(page) =>
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
||||||
>
|
>
|
||||||
<span class="flex flex-row items-center gap-1">
|
<span class="flex flex-row items-center gap-1">
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</CommonList>
|
</CommonList>
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
addModerator()
|
addModerator()
|
||||||
}}
|
}}
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
onselect={p => (formData.newModerator = p.id)}
|
onselect={(p) => (formData.newModerator = p.id)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if profile.meta.profiles}
|
{#if profile.meta.profiles}
|
||||||
{@const filtered = profile.meta.profiles.filter(
|
{@const filtered = profile.meta.profiles.filter(
|
||||||
i => i.instance == page.params.instance,
|
(i) => i.instance == page.params.instance,
|
||||||
)}
|
)}
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<div class="font-medium text-sm">
|
<div class="font-medium text-sm">
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
onkeydown={e => {
|
onkeydown={(e) => {
|
||||||
if (e.target == document.body) searchElement?.focus()
|
if (e.target == document.body) searchElement?.focus()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
>
|
>
|
||||||
{#if !LINKED_INSTANCE_URL}
|
{#if !LINKED_INSTANCE_URL}
|
||||||
{@const instanceSet = new Set(
|
{@const instanceSet = new Set(
|
||||||
profile.meta.profiles.map(i => i.instance),
|
profile.meta.profiles.map((i) => i.instance),
|
||||||
)}
|
)}
|
||||||
{#if instanceSet.size > 1}
|
{#if instanceSet.size > 1}
|
||||||
<Option disabled data-label="true">—</Option>
|
<Option disabled data-label="true">—</Option>
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
<Fixate placement="bottom">
|
<Fixate placement="bottom">
|
||||||
<Pageination
|
<Pageination
|
||||||
page={Number(page.url.searchParams.get('page')) || 1}
|
page={Number(page.url.searchParams.get('page')) || 1}
|
||||||
href={c => `?page=${c}`}
|
href={(c) => `?page=${c}`}
|
||||||
/>
|
/>
|
||||||
</Fixate>
|
</Fixate>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
url: undefined,
|
url: undefined,
|
||||||
}}
|
}}
|
||||||
passedCommunity={community}
|
passedCommunity={community}
|
||||||
onsubmit={e => goto(`/post/${e.post.id}`)}
|
onsubmit={(e) => goto(`/post/${e.post.id}`)}
|
||||||
>
|
>
|
||||||
{#snippet formtitle()}{/snippet}
|
{#snippet formtitle()}{/snippet}
|
||||||
</PostForm>
|
</PostForm>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
class="relative w-max"
|
class="relative w-max"
|
||||||
bind:value={
|
bind:value={
|
||||||
() => data.unreadOnly.value.toString(),
|
() => data.unreadOnly.value.toString(),
|
||||||
v => (data.unreadOnly.value = v == 'true')
|
(v) => (data.unreadOnly.value = v == 'true')
|
||||||
}
|
}
|
||||||
onchange={() =>
|
onchange={() =>
|
||||||
searchParam(
|
searchParam(
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
|
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
|
||||||
)}
|
)}
|
||||||
page={data.page}
|
page={data.page}
|
||||||
href={page => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
/>
|
/>
|
||||||
</Fixate>
|
</Fixate>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -61,10 +61,10 @@ export async function load({ url, fetch }) {
|
|||||||
|
|
||||||
const totalNotifs =
|
const totalNotifs =
|
||||||
type == 'all'
|
type == 'all'
|
||||||
? data.filter(i => i.type != 'private_message' && !i.read).length
|
? data.filter((i) => i.type != 'private_message' && !i.read).length
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
notifications.update(i => ({
|
notifications.update((i) => ({
|
||||||
applications: i.applications,
|
applications: i.applications,
|
||||||
reports: i.reports,
|
reports: i.reports,
|
||||||
inbox: totalNotifs,
|
inbox: totalNotifs,
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
color={item.read ? 'secondary' : 'primary'}
|
color={item.read ? 'secondary' : 'primary'}
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
onclick={e => {
|
onclick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
markAsRead(!item.read)
|
markAsRead(!item.read)
|
||||||
}}
|
}}
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
color={item.read ? 'secondary' : 'primary'}
|
color={item.read ? 'secondary' : 'primary'}
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
onclick={e => {
|
onclick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
markAsRead(!item.read)
|
markAsRead(!item.read)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
function filterDuplicates<T, K>(array: T[], predicate: (item: T) => K): T[] {
|
function filterDuplicates<T, K>(array: T[], predicate: (item: T) => K): T[] {
|
||||||
const seen = new SvelteSet()
|
const seen = new SvelteSet()
|
||||||
return array.filter(element => {
|
return array.filter((element) => {
|
||||||
const value = predicate(element)
|
const value = predicate(element)
|
||||||
if (seen.has(value)) {
|
if (seen.has(value)) {
|
||||||
return false
|
return false
|
||||||
@@ -50,13 +50,13 @@
|
|||||||
function conversationPreviews(
|
function conversationPreviews(
|
||||||
conversations: PrivateMessageView[],
|
conversations: PrivateMessageView[],
|
||||||
): ConversationPreview[] {
|
): ConversationPreview[] {
|
||||||
const deduplicated = filterDuplicates(conversations, i =>
|
const deduplicated = filterDuplicates(conversations, (i) =>
|
||||||
getOtherPartyId(i),
|
getOtherPartyId(i),
|
||||||
)
|
)
|
||||||
|
|
||||||
return deduplicated
|
return deduplicated
|
||||||
.filter(c => c.creator.id != c.recipient.id) // you messaged yourself
|
.filter((c) => c.creator.id != c.recipient.id) // you messaged yourself
|
||||||
.map(i => ({
|
.map((i) => ({
|
||||||
user:
|
user:
|
||||||
i.creator.id != profile.current.user?.local_user_view.person.id
|
i.creator.id != profile.current.user?.local_user_view.person.id
|
||||||
? i.creator
|
? i.creator
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
hideOwnUser={true}
|
hideOwnUser={true}
|
||||||
onselect={u =>
|
onselect={(u) =>
|
||||||
goto(
|
goto(
|
||||||
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
|
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
|
||||||
)}
|
)}
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
<Pageination
|
<Pageination
|
||||||
page={data.page}
|
page={data.page}
|
||||||
hasMore={res.private_messages.length == 50}
|
hasMore={res.private_messages.length == 50}
|
||||||
href={current => `/inbox/messages?page=${current}`}
|
href={(current) => `/inbox/messages?page=${current}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
data.message.value = {
|
data.message.value = {
|
||||||
private_messages: data.message.value.private_messages.toSpliced(
|
private_messages: data.message.value.private_messages.toSpliced(
|
||||||
data.message.value.private_messages.findLastIndex(
|
data.message.value.private_messages.findLastIndex(
|
||||||
i => i.private_message.id == id,
|
(i) => i.private_message.id == id,
|
||||||
),
|
),
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
? 'flex flex-col'
|
? 'flex flex-col'
|
||||||
: 'flex-row h-14 items-center',
|
: 'flex-row h-14 items-center',
|
||||||
]}
|
]}
|
||||||
onsubmit={async e => {
|
onsubmit={async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
const res = await sendMessage(textbox.message)
|
const res = await sendMessage(textbox.message)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
function triggerFilter(filter: string) {
|
function triggerFilter(filter: string) {
|
||||||
if (!passedData.blocked) return
|
if (!passedData.blocked) return
|
||||||
loading = true
|
loading = true
|
||||||
data.blocked = passedData.blocked.filter(i => i.domain.includes(filter))
|
data.blocked = passedData.blocked.filter((i) => i.domain.includes(filter))
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
function triggerFilter(filter: string) {
|
function triggerFilter(filter: string) {
|
||||||
if (!passedData.linked) return
|
if (!passedData.linked) return
|
||||||
loading = true
|
loading = true
|
||||||
data.linked = passedData.linked.filter(i => i.domain.includes(filter))
|
data.linked = passedData.linked.filter((i) => i.domain.includes(filter))
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
<div class="max-w-xl w-full mx-auto h-max my-auto">
|
<div class="max-w-xl w-full mx-auto h-max my-auto">
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
logIn()
|
logIn()
|
||||||
}}
|
}}
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
if (data.client.name == 'lemmy') return 'lemmyv3'
|
if (data.client.name == 'lemmy') return 'lemmyv3'
|
||||||
else return 'piefedvalpha'
|
else return 'piefedvalpha'
|
||||||
},
|
},
|
||||||
v => {
|
(v) => {
|
||||||
if (v == 'lemmyv3')
|
if (v == 'lemmyv3')
|
||||||
data.client = { name: 'lemmy', baseUrl: '/api/v3' }
|
data.client = { name: 'lemmy', baseUrl: '/api/v3' }
|
||||||
else data.client = { name: 'piefed', baseUrl: '/api/alpha' }
|
else data.client = { name: 'piefed', baseUrl: '/api/alpha' }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
client: ClientType
|
client: ClientType
|
||||||
}>({
|
}>({
|
||||||
instance: '',
|
instance: '',
|
||||||
username: `${$t('account.guest')} ${profile.meta.profiles.filter(p => p.jwt == undefined).length + 1}`,
|
username: `${$t('account.guest')} ${profile.meta.profiles.filter((p) => p.jwt == undefined).length + 1}`,
|
||||||
loading: false,
|
loading: false,
|
||||||
client: DEFAULT_CLIENT_TYPE,
|
client: DEFAULT_CLIENT_TYPE,
|
||||||
})
|
})
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = Math.max(...profile.meta.profiles.map(i => i.id)) + 1
|
const id = Math.max(...profile.meta.profiles.map((i) => i.id)) + 1
|
||||||
profile.meta.profiles.push({
|
profile.meta.profiles.push({
|
||||||
id: id,
|
id: id,
|
||||||
instance: form.instance,
|
instance: form.instance,
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
if (form.client.name == 'lemmy') return 'lemmyv3'
|
if (form.client.name == 'lemmy') return 'lemmyv3'
|
||||||
else return 'piefedvalpha'
|
else return 'piefedvalpha'
|
||||||
},
|
},
|
||||||
v => {
|
(v) => {
|
||||||
if (v == 'lemmyv3')
|
if (v == 'lemmyv3')
|
||||||
form.client = { name: 'lemmy', baseUrl: '/api/v3' }
|
form.client = { name: 'lemmy', baseUrl: '/api/v3' }
|
||||||
else form.client = { name: 'piefed', baseUrl: '/api/alpha' }
|
else form.client = { name: 'piefed', baseUrl: '/api/alpha' }
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
batch.progress = 0
|
batch.progress = 0
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
data.items?.value.map(report => {
|
data.items?.value.map((report) => {
|
||||||
report.map(r => {
|
report.map((r) => {
|
||||||
switch (r.type) {
|
switch (r.type) {
|
||||||
case 'comment': {
|
case 'comment': {
|
||||||
const promise = client().resolveCommentReport({
|
const promise = client().resolveCommentReport({
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
<Fixate placement="bottom">
|
<Fixate placement="bottom">
|
||||||
<Pageination
|
<Pageination
|
||||||
page={data.page}
|
page={data.page}
|
||||||
href={current => `?page=${current}`}
|
href={(current) => `?page=${current}`}
|
||||||
hasMore={data.items.value.length >= 20}
|
hasMore={data.items.value.length >= 20}
|
||||||
/>
|
/>
|
||||||
</Fixate>
|
</Fixate>
|
||||||
|
|||||||
@@ -31,13 +31,13 @@
|
|||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 'comment': {
|
case 'comment': {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
items.map(async i =>
|
items.map(async (i) =>
|
||||||
getClient()
|
getClient()
|
||||||
.resolveCommentReport({
|
.resolveCommentReport({
|
||||||
report_id: i.id,
|
report_id: i.id,
|
||||||
resolved: !i.resolved,
|
resolved: !i.resolved,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
i.resolved = res.comment_report_view.comment_report.resolved
|
i.resolved = res.comment_report_view.comment_report.resolved
|
||||||
i.resolver = res.comment_report_view.resolver
|
i.resolver = res.comment_report_view.resolver
|
||||||
$notifications.reports += i.resolved ? -1 : 1
|
$notifications.reports += i.resolved ? -1 : 1
|
||||||
@@ -49,13 +49,13 @@
|
|||||||
}
|
}
|
||||||
case 'post': {
|
case 'post': {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
items.map(async i =>
|
items.map(async (i) =>
|
||||||
getClient()
|
getClient()
|
||||||
.resolvePostReport({
|
.resolvePostReport({
|
||||||
report_id: i.id,
|
report_id: i.id,
|
||||||
resolved: !i.resolved,
|
resolved: !i.resolved,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
i.resolved = res.post_report_view.post_report.resolved
|
i.resolved = res.post_report_view.post_report.resolved
|
||||||
|
|
||||||
i.resolver = res.post_report_view.resolver
|
i.resolver = res.post_report_view.resolver
|
||||||
@@ -69,13 +69,13 @@
|
|||||||
}
|
}
|
||||||
case 'message': {
|
case 'message': {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
items.map(async i =>
|
items.map(async (i) =>
|
||||||
getClient()
|
getClient()
|
||||||
.resolvePrivateMessageReport({
|
.resolvePrivateMessageReport({
|
||||||
report_id: i.id,
|
report_id: i.id,
|
||||||
resolved: !i.resolved,
|
resolved: !i.resolved,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
i.resolved =
|
i.resolved =
|
||||||
res.private_message_report_view.private_message_report.resolved
|
res.private_message_report_view.private_message_report.resolved
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
bind:selected={banFromCommunity}
|
bind:selected={banFromCommunity}
|
||||||
/>
|
/>
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
onselect={p =>
|
onselect={(p) =>
|
||||||
ban(banFromCommunity, p, data.community.community_view.community)}
|
ban(banFromCommunity, p, data.community.community_view.community)}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export async function load({ params, fetch }) {
|
|||||||
limit: 5,
|
limit: 5,
|
||||||
page: 1,
|
page: 1,
|
||||||
})
|
})
|
||||||
.then(i =>
|
.then((i) =>
|
||||||
[
|
[
|
||||||
...i.banned_from_community,
|
...i.banned_from_community,
|
||||||
...i.removed_comments,
|
...i.removed_comments,
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
label="Instance"
|
label="Instance"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
q={page.url.searchParams.get('instance') || ''}
|
q={page.url.searchParams.get('instance') || ''}
|
||||||
onselect={e =>
|
onselect={(e) =>
|
||||||
searchParam(
|
searchParam(
|
||||||
page.url,
|
page.url,
|
||||||
'instance',
|
'instance',
|
||||||
@@ -200,7 +200,7 @@
|
|||||||
label="Community"
|
label="Community"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
q={page.url.searchParams.get('community') ? 'Selected' : ''}
|
q={page.url.searchParams.get('community') ? 'Selected' : ''}
|
||||||
onselect={e =>
|
onselect={(e) =>
|
||||||
searchParam(page.url, 'community', e?.id.toString() ?? '', 'page')}
|
searchParam(page.url, 'community', e?.id.toString() ?? '', 'page')}
|
||||||
/>
|
/>
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
q={page.url.searchParams.get('user')
|
q={page.url.searchParams.get('user')
|
||||||
? (data.filters.user ?? 'Selected')
|
? (data.filters.user ?? 'Selected')
|
||||||
: ''}
|
: ''}
|
||||||
onselect={e =>
|
onselect={(e) =>
|
||||||
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
||||||
/>
|
/>
|
||||||
{#if profile.current?.user && isAdmin(profile.current?.user)}
|
{#if profile.current?.user && isAdmin(profile.current?.user)}
|
||||||
@@ -228,7 +228,7 @@
|
|||||||
q={page.url.searchParams.get('mod_id')
|
q={page.url.searchParams.get('mod_id')
|
||||||
? (data.filters.moderator ?? 'Selected')
|
? (data.filters.moderator ?? 'Selected')
|
||||||
: ''}
|
: ''}
|
||||||
onselect={e =>
|
onselect={(e) =>
|
||||||
searchParam(page.url, 'mod_id', e?.id.toString() ?? '', 'page')}
|
searchParam(page.url, 'mod_id', e?.id.toString() ?? '', 'page')}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -294,7 +294,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Pageination page={data.page} href={page => `?page=${page}`} />
|
<Pageination page={data.page} href={(page) => `?page=${page}`} />
|
||||||
{:else}
|
{:else}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
title="No results"
|
title="No results"
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
data.post.value.meta.then(
|
data.post.value.meta.then(
|
||||||
res => (data.post.value.post_view = res.post_view),
|
(res) => (data.post.value.post_view = res.post_view),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
community={data.post.value.post_view.community}
|
community={data.post.value.post_view.community}
|
||||||
user={data.post.value.post_view.creator}
|
user={data.post.value.post_view.creator}
|
||||||
subscribed={profile.current.user?.follows.find(
|
subscribed={profile.current.user?.follows.find(
|
||||||
i => i.community.id == data.post.value.post_view.community.id,
|
(i) => i.community.id == data.post.value.post_view.community.id,
|
||||||
)
|
)
|
||||||
? 'Subscribed'
|
? 'Subscribed'
|
||||||
: 'NotSubscribed'}
|
: 'NotSubscribed'}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ function findInFeed(
|
|||||||
}
|
}
|
||||||
| undefined {
|
| undefined {
|
||||||
const index = postFeeds.value[feedId]?.data.posts.posts.findIndex(
|
const index = postFeeds.value[feedId]?.data.posts.posts.findIndex(
|
||||||
i => i.post.id == postId,
|
(i) => i.post.id == postId,
|
||||||
)
|
)
|
||||||
|
|
||||||
if ((index ?? -1) == -1) return
|
if ((index ?? -1) == -1) return
|
||||||
@@ -105,7 +105,7 @@ export async function load({ params, url, fetch }) {
|
|||||||
|
|
||||||
const partialPost: PartialPost = {
|
const partialPost: PartialPost = {
|
||||||
post_view: cachedPost ? cachedPost.post_view : (await post).post_view,
|
post_view: cachedPost ? cachedPost.post_view : (await post).post_view,
|
||||||
meta: post.then(i => ({
|
meta: post.then((i) => ({
|
||||||
...i,
|
...i,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ export async function load({ params, url, fetch }) {
|
|||||||
sidebar: {
|
sidebar: {
|
||||||
component: CommunityCard,
|
component: CommunityCard,
|
||||||
props: {
|
props: {
|
||||||
community_view: post.then(i => i.community_view),
|
community_view: post.then((i) => i.community_view),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
!(
|
!(
|
||||||
profile.current?.user?.local_user_view.local_user.admin ||
|
profile.current?.user?.local_user_view.local_user.admin ||
|
||||||
profile.current?.user?.moderates
|
profile.current?.user?.moderates
|
||||||
.map(c => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
)}
|
)}
|
||||||
onclick={() => (commenting = true)}
|
onclick={() => (commenting = true)}
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<CommentForm
|
<CommentForm
|
||||||
postId={post.post.id}
|
postId={post.post.id}
|
||||||
oncomment={comment => {
|
oncomment={(comment) => {
|
||||||
comments.comments.unshift(comment.comment_view)
|
comments.comments.unshift(comment.comment_view)
|
||||||
}}
|
}}
|
||||||
onfocus={() => (commenting = true)}
|
onfocus={() => (commenting = true)}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if profile.meta.profiles}
|
{#if profile.meta.profiles}
|
||||||
{@const filtered = profile.meta.profiles.filter(
|
{@const filtered = profile.meta.profiles.filter(
|
||||||
i => i.instance == page.params.instance,
|
(i) => i.instance == page.params.instance,
|
||||||
)}
|
)}
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<div class="font-medium text-sm">
|
<div class="font-medium text-sm">
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
if (!profile.current?.jwt) return
|
if (!profile.current?.jwt) return
|
||||||
|
|
||||||
data.person_blocks.splice(
|
data.person_blocks.splice(
|
||||||
data.person_blocks.findIndex(i => i.target.id == item.target.id),
|
data.person_blocks.findIndex((i) => i.target.id == item.target.id),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
// hack to get reactivity working
|
// hack to get reactivity working
|
||||||
@@ -49,7 +49,9 @@
|
|||||||
if (!profile.current?.jwt) return
|
if (!profile.current?.jwt) return
|
||||||
|
|
||||||
data.community_blocks.splice(
|
data.community_blocks.splice(
|
||||||
data.community_blocks.findIndex(i => i.community.id == item.community.id),
|
data.community_blocks.findIndex(
|
||||||
|
(i) => i.community.id == item.community.id,
|
||||||
|
),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@
|
|||||||
|
|
||||||
data.my_user.instance_blocks.splice(
|
data.my_user.instance_blocks.splice(
|
||||||
data.my_user.instance_blocks.findIndex(
|
data.my_user.instance_blocks.findIndex(
|
||||||
i => i.instance.id == item.instance.id,
|
(i) => i.instance.id == item.instance.id,
|
||||||
),
|
),
|
||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
{routes.find(r => page.url.pathname == r.href)?.name ??
|
{routes.find((r) => page.url.pathname == r.href)?.name ??
|
||||||
$t('routes.profile.credentials')}
|
$t('routes.profile.credentials')}
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
<Tabs style="subpage" margin={false} {routes}></Tabs>
|
<Tabs style="subpage" margin={false} {routes}></Tabs>
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<form
|
<form
|
||||||
class="flex flex-col gap-2 w-full"
|
class="flex flex-col gap-2 w-full"
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
twofa(!(totpEnabled == true), true)
|
twofa(!(totpEnabled == true), true)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
changePassword()
|
changePassword()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
deleteAccount(4)
|
deleteAccount(4)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
ondelete={() => {
|
ondelete={() => {
|
||||||
data.images.value = data.images.value.toSpliced(
|
data.images.value = data.images.value.toSpliced(
|
||||||
data.images.value.findIndex(
|
data.images.value.findIndex(
|
||||||
i =>
|
(i) =>
|
||||||
i.local_image.pictrs_delete_token ==
|
i.local_image.pictrs_delete_token ==
|
||||||
image.local_image.pictrs_delete_token,
|
image.local_image.pictrs_delete_token,
|
||||||
),
|
),
|
||||||
@@ -33,6 +33,6 @@
|
|||||||
{#if data.images.value.length == 20}
|
{#if data.images.value.length == 20}
|
||||||
<Pageination
|
<Pageination
|
||||||
page={Number(page.url.searchParams.get('page')) || 1}
|
page={Number(page.url.searchParams.get('page')) || 1}
|
||||||
href={page => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<Fixate placement="bottom">
|
<Fixate placement="bottom">
|
||||||
<Pageination
|
<Pageination
|
||||||
hasMore={data.data.length == 40}
|
hasMore={data.data.length == 40}
|
||||||
href={page => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
page={data.page}
|
page={data.page}
|
||||||
/>
|
/>
|
||||||
</Fixate>
|
</Fixate>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
onkeydown={e => {
|
onkeydown={(e) => {
|
||||||
if (e.target == document.body) searchElement?.focus()
|
if (e.target == document.body) searchElement?.focus()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
jwt={profile.current?.jwt}
|
jwt={profile.current?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
onselect={c =>
|
onselect={(c) =>
|
||||||
searchParam(page.url, 'community', c?.id || undefined, 'page')}
|
searchParam(page.url, 'community', c?.id || undefined, 'page')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
{#if data.results.value.length > 0}
|
{#if data.results.value.length > 0}
|
||||||
<Pageination
|
<Pageination
|
||||||
bind:page={data.filters.value.page}
|
bind:page={data.filters.value.page}
|
||||||
href={page => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
mainClass,
|
mainClass,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{#if Object.values(supportedPlatforms).some(v => v == false)}
|
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
{#if supportedPlatforms.desktop}
|
{#if supportedPlatforms.desktop}
|
||||||
<Badge>
|
<Badge>
|
||||||
|
|||||||
@@ -39,12 +39,12 @@
|
|||||||
<li
|
<li
|
||||||
class="flex flex-col w-full justify-between gap-2 max-w-full setting @container/setting"
|
class="flex flex-col w-full justify-between gap-2 max-w-full setting @container/setting"
|
||||||
>
|
>
|
||||||
{#if Object.values(supportedPlatforms).some(v => v == false) || beta}
|
{#if Object.values(supportedPlatforms).some((v) => v == false) || beta}
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
{#if beta}
|
{#if beta}
|
||||||
<Badge>Beta</Badge>
|
<Badge>Beta</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if Object.values(supportedPlatforms).some(v => v == false)}
|
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
||||||
{#if supportedPlatforms.desktop}
|
{#if supportedPlatforms.desktop}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
label="Content"
|
label="Content"
|
||||||
images={false}
|
images={false}
|
||||||
previewButton
|
previewButton
|
||||||
beforePreview={input =>
|
beforePreview={(input) =>
|
||||||
removalTemplate(input, {
|
removalTemplate(input, {
|
||||||
postTitle: '<Example post>',
|
postTitle: '<Example post>',
|
||||||
communityLink: '[!community@example.com]()',
|
communityLink: '[!community@example.com]()',
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
try {
|
try {
|
||||||
const res: Instance[] = (
|
const res: Instance[] = (
|
||||||
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
|
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
|
||||||
r => r.json(),
|
(r) => r.json(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.filter((i: Instance) => i.fed)
|
.filter((i: Instance) => i.fed)
|
||||||
|
|||||||
@@ -300,7 +300,7 @@
|
|||||||
<ErrorContainer scope={page.url.pathname} />
|
<ErrorContainer scope={page.url.pathname} />
|
||||||
<h2 class="font-medium text-3xl">{$t('toast.verifyEmail')}</h2>
|
<h2 class="font-medium text-3xl">{$t('toast.verifyEmail')}</h2>
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
verifiedEmail()
|
verifiedEmail()
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
<button
|
<button
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
const newTheme = {
|
const newTheme = {
|
||||||
id: Math.max(...themeData.data.themes.map(t => t.id)) + 1,
|
id: Math.max(...themeData.data.themes.map((t) => t.id)) + 1,
|
||||||
colors: getDefaultColors(),
|
colors: getDefaultColors(),
|
||||||
name: $t('routes.theme.preset.new'),
|
name: $t('routes.theme.preset.new'),
|
||||||
}
|
}
|
||||||
@@ -170,10 +170,10 @@
|
|||||||
</Header>
|
</Header>
|
||||||
<ColorSwatch
|
<ColorSwatch
|
||||||
value={themeData.current.colors.primary?.[900]}
|
value={themeData.current.colors.primary?.[900]}
|
||||||
onchange={e => {
|
onchange={(e) => {
|
||||||
themeData.current.colors.primary[900] = e
|
themeData.current.colors.primary[900] = e
|
||||||
}}
|
}}
|
||||||
oncontextmenu={e => {
|
oncontextmenu={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
themeData.current.colors.primary[900] = defaultColors.primary[900]
|
themeData.current.colors.primary[900] = defaultColors.primary[900]
|
||||||
|
|
||||||
@@ -183,10 +183,10 @@
|
|||||||
/>
|
/>
|
||||||
<ColorSwatch
|
<ColorSwatch
|
||||||
value={themeData.current.colors.primary?.[100]}
|
value={themeData.current.colors.primary?.[100]}
|
||||||
onchange={e => {
|
onchange={(e) => {
|
||||||
themeData.current.colors.primary[100] = e
|
themeData.current.colors.primary[100] = e
|
||||||
}}
|
}}
|
||||||
oncontextmenu={e => {
|
oncontextmenu={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
themeData.current.colors.primary[100] = defaultColors.primary[100]
|
themeData.current.colors.primary[100] = defaultColors.primary[100]
|
||||||
|
|
||||||
@@ -221,10 +221,10 @@
|
|||||||
<!--@ts-ignore-->
|
<!--@ts-ignore-->
|
||||||
<ColorSwatch
|
<ColorSwatch
|
||||||
bind:value={themeData.current.colors[category][shade]}
|
bind:value={themeData.current.colors[category][shade]}
|
||||||
onchange={e => {
|
onchange={(e) => {
|
||||||
themeData.current.colors[category][shade] = e
|
themeData.current.colors[category][shade] = e
|
||||||
}}
|
}}
|
||||||
oncontextmenu={e => {
|
oncontextmenu={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
themeData.current.colors[category][shade] =
|
themeData.current.colors[category][shade] =
|
||||||
defaultColors[category][shade]
|
defaultColors[category][shade]
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<div class="px-4 py-2 flex items-center gap-1 justify-between">
|
<div class="px-4 py-2 flex items-center gap-1 justify-between">
|
||||||
{#if editingName}
|
{#if editingName}
|
||||||
<form
|
<form
|
||||||
onsubmit={e => {
|
onsubmit={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
editingName = false
|
editingName = false
|
||||||
}}
|
}}
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
type: 'danger',
|
type: 'danger',
|
||||||
action: () => {
|
action: () => {
|
||||||
const index = themeData.data.themes
|
const index = themeData.data.themes
|
||||||
.map(t => t.id)
|
.map((t) => t.id)
|
||||||
.indexOf(theme.id)
|
.indexOf(theme.id)
|
||||||
|
|
||||||
themeData.data.themes = themeData.data.themes.toSpliced(
|
themeData.data.themes = themeData.data.themes.toSpliced(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const ASSETS = [
|
|||||||
...files, // everything in `static`
|
...files, // everything in `static`
|
||||||
]
|
]
|
||||||
|
|
||||||
self.addEventListener('install', event => {
|
self.addEventListener('install', (event) => {
|
||||||
console.info('[i] Installing service worker')
|
console.info('[i] Installing service worker')
|
||||||
// Create a new cache and add all files to it
|
// Create a new cache and add all files to it
|
||||||
async function addFilesToCache() {
|
async function addFilesToCache() {
|
||||||
@@ -23,7 +23,7 @@ self.addEventListener('install', event => {
|
|||||||
event.waitUntil(addFilesToCache())
|
event.waitUntil(addFilesToCache())
|
||||||
})
|
})
|
||||||
|
|
||||||
self.addEventListener('activate', event => {
|
self.addEventListener('activate', (event) => {
|
||||||
console.info('[i] Activating service worker')
|
console.info('[i] Activating service worker')
|
||||||
// Remove previous cached data from disk
|
// Remove previous cached data from disk
|
||||||
async function deleteOldCaches() {
|
async function deleteOldCaches() {
|
||||||
@@ -35,7 +35,7 @@ self.addEventListener('activate', event => {
|
|||||||
event.waitUntil(deleteOldCaches())
|
event.waitUntil(deleteOldCaches())
|
||||||
})
|
})
|
||||||
|
|
||||||
self.addEventListener('fetch', e => {
|
self.addEventListener('fetch', (e) => {
|
||||||
const event = e as FetchEvent
|
const event = e as FetchEvent
|
||||||
// ignore POST requests etc
|
// ignore POST requests etc
|
||||||
if (event.request.method !== 'GET') return
|
if (event.request.method !== 'GET') return
|
||||||
|
|||||||
Reference in new issue
Block a user