feat: add v0.19.0 support
This commit is contained in:
1 parent
b3b8a10e44
commit
119ab53946
62 files changed
+188
-157
No files matched your search
@@ -25,7 +25,6 @@ export async function load({ url, fetch }) {
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: listingType,
|
||||
auth: get(profile)?.jwt,
|
||||
}),
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -8,9 +8,7 @@ export async function load({ fetch }) {
|
||||
let site = get(siteStore)
|
||||
|
||||
if (!site) {
|
||||
const res = await getClient(undefined, fetch).getSite({
|
||||
auth: jwt,
|
||||
})
|
||||
const res = await getClient(undefined, fetch).getSite()
|
||||
|
||||
site = res
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ export async function load({ data, fetch, url }) {
|
||||
const unreadOnly = (url.searchParams.get('unreadOnly') || 'true') == 'true'
|
||||
|
||||
const res = await getClient(undefined, fetch).listRegistrationApplications({
|
||||
auth: jwt,
|
||||
page: page,
|
||||
limit: 40,
|
||||
unread_only: unreadOnly,
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
try {
|
||||
await getClient().approveRegistrationApplication({
|
||||
approve: approve,
|
||||
auth: $profile.jwt,
|
||||
id: application.registration_application.id,
|
||||
})
|
||||
toast({
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
try {
|
||||
await getClient().editSite({
|
||||
auth: jwt,
|
||||
...formData,
|
||||
})
|
||||
toast({
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
if (!blocked) allowedInstances.push(instance)
|
||||
|
||||
await getClient().editSite({
|
||||
auth: $profile.jwt,
|
||||
blocked_instances: blockedInstances,
|
||||
allowed_instances: allowedInstances,
|
||||
})
|
||||
@@ -102,7 +101,6 @@
|
||||
)
|
||||
|
||||
return await getClient().editSite({
|
||||
auth: $profile.jwt,
|
||||
allowed_instances: allowedInstances,
|
||||
blocked_instances: blockedInstances,
|
||||
})
|
||||
|
||||
@@ -3,9 +3,7 @@ import { getClient } from '$lib/lemmy.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ fetch, parent }) {
|
||||
const instances = await getClient(undefined, fetch).getFederatedInstances({
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
const instances = await getClient(undefined, fetch).getFederatedInstances()
|
||||
|
||||
return {
|
||||
federated_instances: instances,
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
try {
|
||||
await getClient().editSite({
|
||||
auth: $profile.jwt,
|
||||
taglines: taglines,
|
||||
})
|
||||
toast({
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
const result = await trycatch(() =>
|
||||
getClient().addAdmin({
|
||||
added: false,
|
||||
auth: $profile!.jwt!,
|
||||
person_id: id,
|
||||
})
|
||||
)
|
||||
|
||||
@@ -19,11 +19,9 @@ export async function load(req: any) {
|
||||
community_name: req.params.name,
|
||||
page: page,
|
||||
sort: sort,
|
||||
auth: get(profile)?.jwt,
|
||||
}),
|
||||
community: getClient(undefined, req.fetch).getCommunity({
|
||||
name: req.params.name,
|
||||
auth: get(profile)?.jwt,
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,11 @@
|
||||
|
||||
try {
|
||||
const res = await getClient().resolveObject({
|
||||
auth: $profile.jwt,
|
||||
q: formData.newModerator,
|
||||
})
|
||||
|
||||
if (res.person) {
|
||||
const addModRes = await getClient().addModToCommunity({
|
||||
auth: $profile.jwt,
|
||||
added: true,
|
||||
person_id: res.person.person.id,
|
||||
community_id: data.community.community_view.community.id,
|
||||
@@ -66,7 +64,6 @@
|
||||
try {
|
||||
const res = await getClient().addModToCommunity({
|
||||
added: false,
|
||||
auth: $profile.jwt,
|
||||
community_id: data.community.community_view.community.id,
|
||||
person_id: id,
|
||||
})
|
||||
|
||||
@@ -6,7 +6,6 @@ import { get } from 'svelte/store'
|
||||
export async function load({ params, fetch }) {
|
||||
const comment = await getClient(undefined, fetch).getComment({
|
||||
id: Number(params.id),
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
throw redirect(
|
||||
|
||||
@@ -21,7 +21,6 @@ export async function load({ url, fetch }) {
|
||||
type_: 'Communities',
|
||||
listing_type: type,
|
||||
q: query,
|
||||
auth: get(profile)?.jwt,
|
||||
})),
|
||||
type: type,
|
||||
sort: sort,
|
||||
@@ -35,7 +34,6 @@ export async function load({ url, fetch }) {
|
||||
page: page,
|
||||
sort: sort,
|
||||
type_: type,
|
||||
auth: get(profile)?.jwt,
|
||||
})),
|
||||
type: type,
|
||||
sort: sort,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
try {
|
||||
const res = await getClient().followCommunity({
|
||||
auth: $profile.jwt,
|
||||
community_id: id,
|
||||
follow: subscribed == 'NotSubscribed',
|
||||
})
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const load = ({ url }) => ({
|
||||
crosspost: Boolean(url.searchParams.get('crosspost')) ?? false,
|
||||
})
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
|
||||
export const load = ({ url }) => {
|
||||
return { crosspost: Boolean(url.searchParams.get('crosspost')) ?? false }
|
||||
}
|
||||
@@ -30,9 +30,7 @@
|
||||
|
||||
markingAsRead = true
|
||||
|
||||
const response = await getClient().markAllAsRead({
|
||||
auth: $profile.jwt!,
|
||||
})
|
||||
const response = await getClient().markAllAsRead()
|
||||
|
||||
$profile.user.unreads = 0
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ export async function load({ url, fetch }) {
|
||||
const params = {
|
||||
limit: 20,
|
||||
page: page,
|
||||
auth: auth.jwt,
|
||||
unread_only: unreadOnly == 'true',
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
try {
|
||||
await getClient().createPrivateMessage({
|
||||
auth: $profile.jwt,
|
||||
content: reply,
|
||||
recipient_id: message.creator.id,
|
||||
})
|
||||
@@ -68,13 +67,11 @@
|
||||
|
||||
if (item.type == 'person_mention') {
|
||||
await getClient().markPersonMentionAsRead({
|
||||
auth: $profile?.jwt,
|
||||
person_mention_id: item.id,
|
||||
read: isRead,
|
||||
})
|
||||
} else if (item.type == 'comment_reply') {
|
||||
await getClient().markCommentReplyAsRead({
|
||||
auth: $profile?.jwt,
|
||||
comment_reply_id: item.id,
|
||||
read: isRead,
|
||||
})
|
||||
|
||||
@@ -3,9 +3,6 @@ import { getClient } from '$lib/lemmy.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ fetch }) {
|
||||
return (
|
||||
await getClient(undefined, fetch).getFederatedInstances({
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
).federated_instances
|
||||
return (await getClient(undefined, fetch).getFederatedInstances())
|
||||
.federated_instances
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { setUser } from '$lib/auth.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Note, toast } from 'mono-svelte'
|
||||
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { getClient, validateInstance } from '$lib/lemmy.js'
|
||||
import { Button, TextInput } from 'mono-svelte'
|
||||
@@ -11,6 +11,8 @@
|
||||
Identification,
|
||||
QuestionMarkCircle,
|
||||
} from 'svelte-hero-icons'
|
||||
import { DOMAIN_REGEX_FORMS } from '$lib/util.js'
|
||||
import { MINIMUM_VERSION } from '$lib/version.js'
|
||||
|
||||
let data = {
|
||||
instance: DEFAULT_INSTANCE_URL,
|
||||
@@ -36,10 +38,12 @@
|
||||
})
|
||||
|
||||
if (response?.jwt) {
|
||||
await setUser(response.jwt, data.instance, data.username)
|
||||
const result = await setUser(response.jwt, data.instance, data.username)
|
||||
|
||||
toast({ content: 'Successfully logged in.', type: 'success' })
|
||||
goto('/')
|
||||
if (result) {
|
||||
toast({ content: 'Successfully logged in.', type: 'success' })
|
||||
goto('/')
|
||||
}
|
||||
} else {
|
||||
throw new Error('Invalid credentials')
|
||||
}
|
||||
@@ -62,6 +66,13 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<h1 class="font-bold text-3xl">Log In</h1>
|
||||
<p>Enter the fediverse</p>
|
||||
<Note>
|
||||
This version of Photon supports instances running
|
||||
<span style="font-family: monospace;">
|
||||
v{MINIMUM_VERSION}
|
||||
</span>
|
||||
or higher.
|
||||
</Note>
|
||||
</div>
|
||||
<div class="flex flex-row w-full items-center gap-2">
|
||||
<TextInput
|
||||
@@ -81,7 +92,7 @@
|
||||
bind:value={data.instance}
|
||||
class="flex-1"
|
||||
required
|
||||
pattern={'(?!-)[A-Za-z0-9-]+([-.]{1}[a-z0-9]+)*.[A-Za-z]{2,6}'}
|
||||
pattern={DOMAIN_REGEX_FORMS}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,6 @@ export async function load({ url, fetch }) {
|
||||
const client = getClient(undefined, fetch)
|
||||
|
||||
const params = {
|
||||
auth: jwt,
|
||||
limit: 20,
|
||||
page: page,
|
||||
unresolved_only: type == 'unread',
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
switch (item.type) {
|
||||
case 'comment': {
|
||||
const res = await getClient().resolveCommentReport({
|
||||
auth: $profile.jwt,
|
||||
report_id: item.id,
|
||||
resolved: !item.resolved,
|
||||
})
|
||||
@@ -44,7 +43,6 @@
|
||||
}
|
||||
case 'post': {
|
||||
const res = await getClient().resolvePostReport({
|
||||
auth: $profile.jwt,
|
||||
report_id: item.id,
|
||||
resolved: !item.resolved,
|
||||
})
|
||||
@@ -61,7 +59,6 @@
|
||||
}
|
||||
case 'message': {
|
||||
const res = await getClient().resolvePrivateMessageReport({
|
||||
auth: $profile.jwt,
|
||||
report_id: item.id,
|
||||
resolved: !item.resolved,
|
||||
})
|
||||
@@ -79,9 +76,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
const reports = await getClient().getReportCount({
|
||||
auth: $profile?.jwt,
|
||||
})
|
||||
const reports = await getClient().getReportCount({})
|
||||
|
||||
$profile.user.reports =
|
||||
reports.comment_reports +
|
||||
|
||||
@@ -207,7 +207,6 @@ export async function load({ url }) {
|
||||
(url.searchParams.get('type') as ModlogActionType) || 'All'
|
||||
|
||||
const results = await getClient().getModlog({
|
||||
auth: get(profile)?.jwt,
|
||||
community_id: community,
|
||||
limit: 40,
|
||||
type_: type,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { instance } from '$lib/instance.js'
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
import { error, redirect } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
@@ -6,7 +7,7 @@ export function load({ params, url }) {
|
||||
if (Number(params.instance)) {
|
||||
const split = url.pathname.split('/')
|
||||
|
||||
split.splice(2, 0, `${get(instance)?.toLowerCase()}`)
|
||||
split.splice(2, 0, `${getInstance()?.toLowerCase()}`)
|
||||
|
||||
const newUrl = new URL(url)
|
||||
newUrl.pathname = split.join('/')
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
$profile?.jwt
|
||||
) {
|
||||
getClient().markPostAsRead({
|
||||
auth: $profile.jwt,
|
||||
read: $userSettings.markPostsAsRead,
|
||||
post_id: post.post_view.post.id,
|
||||
})
|
||||
@@ -73,7 +72,6 @@
|
||||
|
||||
try {
|
||||
const res = await getClient().resolveObject({
|
||||
auth: jwt,
|
||||
q: post.post_view.post.ap_id,
|
||||
})
|
||||
|
||||
@@ -98,7 +96,6 @@
|
||||
commentsPage = 1
|
||||
|
||||
data.streamed.comments = getClient().getComments({
|
||||
auth: $profile?.jwt,
|
||||
page: 1,
|
||||
limit: 25,
|
||||
type_: 'All',
|
||||
|
||||
@@ -8,7 +8,6 @@ import { get } from 'svelte/store'
|
||||
export async function load({ params, url, fetch }) {
|
||||
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
|
||||
id: Number(params.id),
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
let max_depth = post.post_view.counts.comments > 100 ? 1 : 3
|
||||
@@ -38,7 +37,6 @@ export async function load({ params, url, fetch }) {
|
||||
max_depth: max_depth,
|
||||
saved_only: false,
|
||||
sort: sort,
|
||||
auth: get(profile)?.jwt,
|
||||
parent_id: parentId,
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
data.person_blocks = data.person_blocks
|
||||
|
||||
await getClient().blockPerson({
|
||||
auth: $profile.jwt,
|
||||
block: false,
|
||||
person_id: item.target.id,
|
||||
})
|
||||
@@ -50,7 +49,6 @@
|
||||
data.community_blocks = data.community_blocks
|
||||
|
||||
await getClient().blockCommunity({
|
||||
auth: $profile.jwt,
|
||||
block: false,
|
||||
community_id: item.community.id,
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
newPasswordVerify = ''
|
||||
let loading = false
|
||||
|
||||
// @ts-ignore
|
||||
$: totpLink = data.my_user?.local_user_view?.local_user?.totp_2fa_url
|
||||
|
||||
async function changePassword() {
|
||||
@@ -22,7 +23,6 @@
|
||||
if (!$profile?.jwt) return
|
||||
loading = true
|
||||
const res = await getClient().changePassword({
|
||||
auth: $profile?.jwt,
|
||||
new_password: newPassword,
|
||||
new_password_verify: newPasswordVerify,
|
||||
old_password: oldPassword,
|
||||
@@ -56,8 +56,8 @@
|
||||
await getClient().saveUserSettings({
|
||||
...data.my_user?.local_user_view.local_user,
|
||||
...data.my_user?.local_user_view.person,
|
||||
// @ts-ignore
|
||||
generate_totp_2fa: enabled,
|
||||
auth: $profile?.jwt,
|
||||
})
|
||||
goto($page.url, { invalidateAll: true })
|
||||
toast({
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
: undefined
|
||||
|
||||
const res = await getClient().saveUserSettings({
|
||||
auth: $profile.jwt,
|
||||
...formData,
|
||||
avatar: pfp,
|
||||
})
|
||||
@@ -104,9 +103,10 @@
|
||||
try {
|
||||
const { jwt } = $profile
|
||||
|
||||
// TODO - add option to delete content
|
||||
await getClient().deleteAccount({
|
||||
auth: jwt,
|
||||
password: deletion.password,
|
||||
delete_content: false,
|
||||
})
|
||||
|
||||
profileData.update((pd) => {
|
||||
|
||||
@@ -5,8 +5,7 @@ import type { SortType } from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ params, url, fetch }) {
|
||||
const my_user = (await getClient().getSite({ auth: get(profile)?.jwt }))
|
||||
.my_user
|
||||
const my_user = (await getClient().getSite()).my_user
|
||||
|
||||
return {
|
||||
my_user: my_user,
|
||||
|
||||
@@ -17,7 +17,6 @@ export async function load({ url, fetch, parent }) {
|
||||
page: page,
|
||||
username: my_user?.local_user_view.person.name,
|
||||
sort: sort,
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
const items = [...user.posts, ...user.comments]
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { CommentSortType, CommentView, ListingType, PostView, SortType } from 'lemmy-js-client'
|
||||
import type {
|
||||
CommentSortType,
|
||||
CommentView,
|
||||
ListingType,
|
||||
PostView,
|
||||
SortType,
|
||||
} from 'lemmy-js-client'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
function getSavedItemPublished(item: PostView | CommentView) {
|
||||
@@ -18,12 +24,11 @@ export async function load({ url, fetch }) {
|
||||
const client = getClient(undefined, fetch)
|
||||
|
||||
const params = {
|
||||
auth: get(profile)!.jwt!,
|
||||
saved_only: true,
|
||||
limit: 20,
|
||||
page: page,
|
||||
sort: 'New' as SortType & CommentSortType,
|
||||
type_: 'All' as ListingType
|
||||
type_: 'All' as ListingType,
|
||||
}
|
||||
|
||||
const [posts, comments] = await Promise.all([
|
||||
|
||||
@@ -22,7 +22,6 @@ export async function load({ url, fetch }) {
|
||||
if (query) {
|
||||
const results = await getClient(undefined, fetch).search({
|
||||
q: query,
|
||||
auth: get(profile)?.jwt,
|
||||
community_id: community ?? undefined,
|
||||
limit: 20,
|
||||
page: page,
|
||||
@@ -52,7 +51,6 @@ export async function load({ url, fetch }) {
|
||||
streamed: {
|
||||
object: get(profile)?.jwt
|
||||
? getClient(undefined, fetch).resolveObject({
|
||||
auth: get(profile)!.jwt!,
|
||||
q: query,
|
||||
})
|
||||
: undefined,
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
const blocked = isBlocked($profile.user, block)
|
||||
|
||||
await getClient().blockPerson({
|
||||
auth: $profile.jwt,
|
||||
block: !blocked,
|
||||
person_id: block,
|
||||
})
|
||||
@@ -130,7 +129,7 @@
|
||||
<div
|
||||
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
|
||||
>
|
||||
{#each data.items as item (item.counts.id)}
|
||||
{#each data.items as item}
|
||||
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')}
|
||||
<CommentItem comment={item} />
|
||||
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')}
|
||||
|
||||
@@ -15,7 +15,6 @@ export async function load({ params, url, fetch }) {
|
||||
page: page,
|
||||
username: params.name,
|
||||
sort: sort,
|
||||
auth: get(profile)?.jwt,
|
||||
})
|
||||
|
||||
const items = [...user.posts, ...user.comments]
|
||||
|
||||
Reference in new issue
Block a user