diff --git a/package.json b/package.json index b5b0228d..66efa0bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "1.12.2", + "version": "1.13.0", "private": true, "scripts": { "dev": "vite dev", @@ -19,19 +19,20 @@ "@types/markdown-it-container": "^2.0.6", "@types/nprogress": "^0.2.0", "@vite-pwa/sveltekit": "^0.2.5", - "autoprefixer": "^10.4.14", + "autoprefixer": "^10.4.16", "jsdom": "^22.1.0", + "lemmy-js-client": "^0.18.1", "markdown-it-container": "^3.0.0", "markdown-it-sub": "^1.0.0", "markdown-it-sup": "^1.0.0", "nprogress": "^0.2.0", - "postcss": "^8.4.24", + "postcss": "^8.4.30", "rollup-plugin-visualizer": "^5.9.2", "svelte": "^4.2.0", "svelte-check": "^3.0.1", "svelte-hero-icons": "^5.0.0", "svelte-tiny-virtual-list": "^2.0.5", - "tailwindcss": "^3.3.2", + "tailwindcss": "^3.3.3", "tslib": "^2.4.1", "typescript": "^5.0.0", "vite": "^4.3.0", @@ -42,7 +43,6 @@ "dependencies": { "@dicebear/core": "^6.0.4", "@dicebear/initials": "^6.0.4", - "lemmy-js-client": "^0.18.0-rc.2", "markdown-it": "^13.0.1", "mono-svelte": "^0.3.7" }, diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 9d51d815..5e824d6e 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -135,7 +135,7 @@ export async function setUser(jwt: string, inst: string, username: string) { return { profile: id, - profiles: [...pd.profiles, newProfile], + profiles: [newProfile, ...pd.profiles], } }) @@ -146,7 +146,24 @@ async function userFromJwt( jwt: string, instance: string ): Promise<{ user: PersonData; site: GetSiteResponse } | undefined> { - const site = await getClient(instance).getSite({ auth: jwt }) + const sitePromise = getClient(instance).getSite({ + auth: jwt, + }) + + let timer = setTimeout( + () => + toast({ + content: `It's taking a while to fetch your user. Is your instance down?`, + type: 'warning', + }), + 5000 + ) + + const site = await sitePromise.then((r) => { + clearTimeout(timer) + return r + }) + const myUser = site.my_user if (!myUser) return undefined diff --git a/src/routes/admin/config/+page.svelte b/src/routes/admin/config/+page.svelte index 920d7e82..dc293a15 100644 --- a/src/routes/admin/config/+page.svelte +++ b/src/routes/admin/config/+page.svelte @@ -128,6 +128,16 @@ Federation enabled + + Federation debug mode + + + Captcha enabled + + {#if formData.captcha_enabled} + {console.log(formData.captcha_difficulty)} + + import { page } from '$app/stores' + import { XMark, Icon } from 'svelte-hero-icons' + + +
+
+ +
+

Error

+

+ That password reset token doesn't exist. +

+ {$page.error?.message} +
diff --git a/src/routes/password_change/[token]/+page.svelte b/src/routes/password_change/[token]/+page.svelte new file mode 100644 index 00000000..f1d1e835 --- /dev/null +++ b/src/routes/password_change/[token]/+page.svelte @@ -0,0 +1,83 @@ + + +
+

Reset Password

+

+ You've clicked an email with the password reset link in it. Now, choose your + new password. +

+
+ {#if !LINKED_INSTANCE_URL} + + + What instance did you reset your password for? + + + {/if} + + + + +
diff --git a/src/routes/password_change/[token]/+page.ts b/src/routes/password_change/[token]/+page.ts new file mode 100644 index 00000000..8f31c281 --- /dev/null +++ b/src/routes/password_change/[token]/+page.ts @@ -0,0 +1,3 @@ +export const load = ({ params }) => ({ + token: params.token, +}) diff --git a/src/routes/profile/(local_user)/+layout.ts b/src/routes/profile/(local_user)/+layout.ts deleted file mode 100644 index 52d6d377..00000000 --- a/src/routes/profile/(local_user)/+layout.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { profile } from '$lib/auth.js' -import { getClient } from '$lib/lemmy.js' -import { get } from 'svelte/store' - -export async function load() { - return (await getClient().getSite({ auth: get(profile)?.jwt })).my_user -} diff --git a/src/routes/profile/(local_user)/password/+page.svelte b/src/routes/profile/(local_user)/password/+page.svelte new file mode 100644 index 00000000..3e225c33 --- /dev/null +++ b/src/routes/profile/(local_user)/password/+page.svelte @@ -0,0 +1,64 @@ + + +

Change Password

+
+ + + + + diff --git a/src/routes/profile/(local_user)/settings/+page.svelte b/src/routes/profile/(local_user)/settings/+page.svelte index 767ec9da..c0055256 100644 --- a/src/routes/profile/(local_user)/settings/+page.svelte +++ b/src/routes/profile/(local_user)/settings/+page.svelte @@ -11,8 +11,8 @@ export let data let formData: Omit | undefined = { - ...data.local_user_view?.local_user, - ...data.local_user_view?.person, + ...data.my_user?.local_user_view?.local_user, + ...data.my_user?.local_user_view?.person, } let profileImage: FileList | undefined @@ -150,7 +150,7 @@

User settings

- {#if data.local_user_view?.local_user && formData} + {#if data.my_user?.local_user_view?.local_user && formData} { goto(e.detail) diff --git a/src/routes/profile/+layout.ts b/src/routes/profile/+layout.ts index 8eb71dc4..62a317db 100644 --- a/src/routes/profile/+layout.ts +++ b/src/routes/profile/+layout.ts @@ -5,43 +5,12 @@ import type { SortType } from 'lemmy-js-client' import { get } from 'svelte/store' export async function load({ params, url, fetch }) { - const page = Number(url.searchParams.get('page')) || 1 - const type: 'comments' | 'posts' | 'all' = - (url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all' - const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New' - - const user = await getClient(undefined, fetch).getPersonDetails({ - limit: 20, - page: page, - username: get(profile)!.user?.local_user_view.person.name, - sort: sort, - auth: get(profile)?.jwt, - }) - - const items = [...user.posts, ...user.comments] - - if (sort == 'TopAll') { - items.sort( - (a, b) => - b.counts.upvotes - - b.counts.downvotes - - (a.counts.upvotes - a.counts.downvotes) - ) - } else if (sort == 'New') { - items.sort( - (a, b) => - Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)) - ) - } + const my_user = (await getClient().getSite({ auth: get(profile)?.jwt })) + .my_user return { - type: type, - page: page, - sort: sort, - user: { - person_view: user.person_view, - moderates: user.moderates, - submissions: items, - }, + my_user: my_user, + community_blocks: my_user?.community_blocks, + person_blocks: my_user?.person_blocks, } } diff --git a/src/routes/profile/user/+page.ts b/src/routes/profile/user/+page.ts new file mode 100644 index 00000000..976e52cf --- /dev/null +++ b/src/routes/profile/user/+page.ts @@ -0,0 +1,49 @@ +import { profile } from '$lib/auth.js' +import { getClient } from '$lib/lemmy.js' +import { getItemPublished } from '$lib/lemmy/item.js' +import type { SortType } from 'lemmy-js-client' +import { get } from 'svelte/store' + +export async function load({ url, fetch, parent }) { + const page = Number(url.searchParams.get('page')) || 1 + const type: 'comments' | 'posts' | 'all' = + (url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all' + const sort: SortType = (url.searchParams.get('sort') as SortType) || 'New' + + const { my_user } = await parent() + + const user = await getClient(undefined, fetch).getPersonDetails({ + limit: 20, + page: page, + username: my_user?.local_user_view.person.name, + sort: sort, + auth: get(profile)?.jwt, + }) + + const items = [...user.posts, ...user.comments] + + if (sort == 'TopAll') { + items.sort( + (a, b) => + b.counts.upvotes - + b.counts.downvotes - + (a.counts.upvotes - a.counts.downvotes) + ) + } else if (sort == 'New') { + items.sort( + (a, b) => + Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)) + ) + } + + return { + type: type, + page: page, + sort: sort, + user: { + submissions: items, + moderates: user.moderates, + person_view: user.person_view, + }, + } +} diff --git a/src/routes/saved/+page.svelte b/src/routes/saved/+page.svelte index cfa1551a..44765456 100644 --- a/src/routes/saved/+page.svelte +++ b/src/routes/saved/+page.svelte @@ -18,7 +18,7 @@ Saved -

Saved

+

Saved

Search -

Search

+

Search