@@ -78,21 +88,18 @@
searchParam($page.url, 'page', p.detail.toString())}
+ on:cursor={(c) => {
+ searchParam($page.url, 'cursor', c.detail)
+ }}
>
-
- You've viewed
- {data.page * 20}
+
+
+
+ {$site?.site_view.counts.users_active_day}
- posts.
-
-
-
- {data.page * 20}
-
- posts
+ Active users
diff --git a/src/routes/+page.ts b/src/routes/+page.ts
index 7daa3ec6..bc6ac7e9 100644
--- a/src/routes/+page.ts
+++ b/src/routes/+page.ts
@@ -4,9 +4,12 @@ import type { ListingType, SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
import { error } from '@sveltejs/kit'
import { profile } from '$lib/auth.js'
+import { feature } from '$lib/version.js'
export async function load({ url, fetch }) {
- const page = Number(url.searchParams.get('page') || 1) || 1
+ const cursor = url.searchParams.get('cursor') as string | undefined
+ const prevCursor = url.searchParams.get('prevCursor') as string | undefined
+ const page = Number(url.searchParams.get('page')) || undefined
const sort: SortType =
(url.searchParams.get('sort') as SortType) ||
@@ -15,18 +18,25 @@ export async function load({ url, fetch }) {
(url.searchParams.get('type') as ListingType) ||
get(userSettings).defaultSort.feed
+ const posts = await getClient(undefined, fetch).getPosts({
+ limit: 20,
+ page: page,
+ sort: sort,
+ type_: listingType,
+ page_cursor: cursor,
+ })
+
try {
return {
sort: sort,
listingType: listingType,
- page: page,
- posts: await getClient(undefined, fetch).getPosts({
- limit: 20,
- page: page,
- sort: sort,
- type_: listingType,
- auth: get(profile)?.jwt,
- }),
+ page: page || 1,
+ posts: posts,
+ cursor: {
+ next: posts.next_page,
+ back: prevCursor,
+ current: cursor,
+ },
}
} catch (err) {
throw error(500, {
diff --git a/src/routes/admin/+layout.ts b/src/routes/admin/+layout.ts
index a607f9a4..4f057387 100644
--- a/src/routes/admin/+layout.ts
+++ b/src/routes/admin/+layout.ts
@@ -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
}
diff --git a/src/routes/admin/applications/+page.ts b/src/routes/admin/applications/+page.ts
index 95216789..f706d88f 100644
--- a/src/routes/admin/applications/+page.ts
+++ b/src/routes/admin/applications/+page.ts
@@ -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,
diff --git a/src/routes/admin/applications/Application.svelte b/src/routes/admin/applications/Application.svelte
index e521ce2c..f91f3db6 100644
--- a/src/routes/admin/applications/Application.svelte
+++ b/src/routes/admin/applications/Application.svelte
@@ -25,7 +25,6 @@
try {
await getClient().approveRegistrationApplication({
approve: approve,
- auth: $profile.jwt,
id: application.registration_application.id,
})
toast({
diff --git a/src/routes/admin/config/+page.svelte b/src/routes/admin/config/+page.svelte
index dc293a15..fd9a0fe7 100644
--- a/src/routes/admin/config/+page.svelte
+++ b/src/routes/admin/config/+page.svelte
@@ -24,7 +24,6 @@
try {
await getClient().editSite({
- auth: jwt,
...formData,
})
toast({
diff --git a/src/routes/admin/federation/+page.svelte b/src/routes/admin/federation/+page.svelte
index 084dbea1..fad81814 100644
--- a/src/routes/admin/federation/+page.svelte
+++ b/src/routes/admin/federation/+page.svelte
@@ -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,
})
diff --git a/src/routes/admin/federation/+page.ts b/src/routes/admin/federation/+page.ts
index 5b64aeac..3b32e283 100644
--- a/src/routes/admin/federation/+page.ts
+++ b/src/routes/admin/federation/+page.ts
@@ -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,
diff --git a/src/routes/admin/taglines/+page.svelte b/src/routes/admin/taglines/+page.svelte
index c71c11a9..28977b66 100644
--- a/src/routes/admin/taglines/+page.svelte
+++ b/src/routes/admin/taglines/+page.svelte
@@ -24,7 +24,6 @@
try {
await getClient().editSite({
- auth: $profile.jwt,
taglines: taglines,
})
toast({
diff --git a/src/routes/admin/team/+page.svelte b/src/routes/admin/team/+page.svelte
index e812994f..ce209bc1 100644
--- a/src/routes/admin/team/+page.svelte
+++ b/src/routes/admin/team/+page.svelte
@@ -28,7 +28,6 @@
const result = await trycatch(() =>
getClient().addAdmin({
added: false,
- auth: $profile!.jwt!,
person_id: id,
})
)
diff --git a/src/routes/c/[name]/+layout.ts b/src/routes/c/[name]/+layout.ts
index ad1e075c..e891aa21 100644
--- a/src/routes/c/[name]/+layout.ts
+++ b/src/routes/c/[name]/+layout.ts
@@ -5,7 +5,8 @@ import type { ListingType, SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
export async function load(req: any) {
- const page = Number(req.url.searchParams.get('page') || 1) || 1
+ const cursor: string | undefined = req.url.searchParams.get('cursor')
+ const page = Number(req.url.searchParams.get('page')) || undefined
const sort: SortType =
(req.url.searchParams.get('sort') as SortType) ||
@@ -13,17 +14,16 @@ export async function load(req: any) {
return {
sort: sort,
- page: page,
+ page: page || 1,
posts: getClient(undefined, req.fetch).getPosts({
limit: 40,
community_name: req.params.name,
page: page,
sort: sort,
- auth: get(profile)?.jwt,
+ page_cursor: cursor
}),
community: getClient(undefined, req.fetch).getCommunity({
name: req.params.name,
- auth: get(profile)?.jwt,
}),
}
}
diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte
index a84a0332..ef5e605b 100644
--- a/src/routes/c/[name]/+page.svelte
+++ b/src/routes/c/[name]/+page.svelte
@@ -11,6 +11,7 @@
import { Button, Modal, toast } from 'mono-svelte'
import { afterNavigate } from '$app/navigation'
import { browser } from '$app/environment'
+ import { ChartBar, Icon } from 'svelte-hero-icons'
export let data
@@ -89,20 +90,22 @@
searchParam($page.url, 'cursor', c.detail)}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
>
{#if data.posts.posts.length > 0}
-
- You've scrolled
- {data.page * 20}
+
+
+
+ {data.community.community_view.counts.users_active_day}
- posts.
-
-
-
- {data.page * 20}
+
+ Active user{data.community.community_view.counts.users_active_day >
+ 1
+ ? 's'
+ : ''}
- posts
{/if}
diff --git a/src/routes/c/[name]/settings/team/+page.svelte b/src/routes/c/[name]/settings/team/+page.svelte
index b47577fc..979276ac 100644
--- a/src/routes/c/[name]/settings/team/+page.svelte
+++ b/src/routes/c/[name]/settings/team/+page.svelte
@@ -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,
})
diff --git a/src/routes/comment/[instance]/[id]/+page.ts b/src/routes/comment/[instance]/[id]/+page.ts
index 1581aa15..d220aab4 100644
--- a/src/routes/comment/[instance]/[id]/+page.ts
+++ b/src/routes/comment/[instance]/[id]/+page.ts
@@ -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(
diff --git a/src/routes/communities/+page.ts b/src/routes/communities/+page.ts
index 42387580..b0d6f877 100644
--- a/src/routes/communities/+page.ts
+++ b/src/routes/communities/+page.ts
@@ -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,
diff --git a/src/routes/communities/Subscribe.svelte b/src/routes/communities/Subscribe.svelte
index e2189f1e..83faff51 100644
--- a/src/routes/communities/Subscribe.svelte
+++ b/src/routes/communities/Subscribe.svelte
@@ -19,7 +19,6 @@
try {
const res = await getClient().followCommunity({
- auth: $profile.jwt,
community_id: id,
follow: subscribed == 'NotSubscribed',
})
diff --git a/src/routes/create/post/+page.ts b/src/routes/create/post/+page.ts
index a8117f50..d8874497 100644
--- a/src/routes/create/post/+page.ts
+++ b/src/routes/create/post/+page.ts
@@ -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 }
+}
diff --git a/src/routes/inbox/+page.svelte b/src/routes/inbox/+page.svelte
index 808d304d..63414568 100644
--- a/src/routes/inbox/+page.svelte
+++ b/src/routes/inbox/+page.svelte
@@ -30,9 +30,7 @@
markingAsRead = true
- const response = await getClient().markAllAsRead({
- auth: $profile.jwt!,
- })
+ const response = await getClient().markAllAsRead()
$profile.user.unreads = 0
diff --git a/src/routes/inbox/+page.ts b/src/routes/inbox/+page.ts
index a40305cd..302d246f 100644
--- a/src/routes/inbox/+page.ts
+++ b/src/routes/inbox/+page.ts
@@ -23,7 +23,6 @@ export async function load({ url, fetch }) {
const params = {
limit: 20,
page: page,
- auth: auth.jwt,
unread_only: unreadOnly == 'true',
}
diff --git a/src/routes/inbox/InboxItem.svelte b/src/routes/inbox/InboxItem.svelte
index 8908fbfc..da123c13 100644
--- a/src/routes/inbox/InboxItem.svelte
+++ b/src/routes/inbox/InboxItem.svelte
@@ -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,
})
diff --git a/src/routes/instances/+page.ts b/src/routes/instances/+page.ts
index 2557dc88..e791157b 100644
--- a/src/routes/instances/+page.ts
+++ b/src/routes/instances/+page.ts
@@ -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
}
diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte
index e0363ea9..e16a6f62 100644
--- a/src/routes/login/+page.svelte
+++ b/src/routes/login/+page.svelte
@@ -1,7 +1,7 @@
@@ -92,6 +117,34 @@
/>
{/if}
+{#if purgingUser}
+
+ Purging User
+
+ Purging user
+ {data.person_view.person.name}
+
+
+
+ Are you sure you want to do this? (The button will enable in 3 seconds.)
+
+
+
+
+
+
+{/if}
+
@@ -130,7 +183,7 @@
- {#each data.items as item (item.counts.id)}
+ {#each data.items as item}
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')}
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')}
@@ -223,34 +276,48 @@
{/if}
-
+
+ {#if isAdmin($profile?.user)}
+
+ {/if}
+
+
- {#if isAdmin($profile?.user)}
-
- {/if}
{/if}
diff --git a/src/routes/u/[name]/+page.ts b/src/routes/u/[name]/+page.ts
index 2e3a9d3f..2376afbc 100644
--- a/src/routes/u/[name]/+page.ts
+++ b/src/routes/u/[name]/+page.ts
@@ -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]
diff --git a/tests/version.test.ts b/tests/version.test.ts
new file mode 100644
index 00000000..713cb4da
--- /dev/null
+++ b/tests/version.test.ts
@@ -0,0 +1,21 @@
+import { versionIsSupported } from '../src/lib/version.js'
+import { describe, expect, it } from 'vitest'
+
+describe('versionIsSupported()', () => {
+ it('checks minimum correctly', () => {
+ expect(versionIsSupported('0.1.0', '0.0.0')).toBeTruthy()
+ expect(versionIsSupported('0.0.0', '0.1.0')).toBeFalsy()
+ })
+ it('checks weird minimum versions correctly', () => {
+ expect(versionIsSupported('0.19.0-rc.2', '0.19.0')).toBeTruthy()
+ expect(versionIsSupported('0.19.0.rc.9', '0.19.1')).toBeFalsy()
+ })
+ it('checks major and patch versions correctly', () => {
+ expect(versionIsSupported('2.0.0', '1.0.0')).toBeTruthy()
+ expect(versionIsSupported('0.0.2', '0.0.1')).toBeTruthy()
+ })
+ it('handles other cases', () => {
+ expect(versionIsSupported('2.0.2', '1.0.5')).toBeTruthy()
+ expect(versionIsSupported('9.5.2', '7.6.3')).toBeTruthy()
+ })
+})
diff --git a/yarn.lock b/yarn.lock
index 987b4c04..07edabf7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2821,10 +2821,10 @@ kleur@^4.1.5:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780"
integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==
-lemmy-js-client@^0.18.1:
- version "0.18.1"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.18.1.tgz#28df266eded0ef4a72b05ee6eabebddadfd81a27"
- integrity sha512-maafUZ9ZJkXthRZmM0+limJmymF2kmN/8SiKufS3V4OVNM72s+wUFFiyhKmA370g23iZRW6SUagE7jNKnqNyYQ==
+lemmy-js-client@^0.19.0-rc.13:
+ version "0.19.0-rc.13"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.13.tgz#e0e15ba6fe3a08cb85130eea7eec4bd2773999f9"
+ integrity sha512-JP9oEh1+Wfttqx5O5EMAVIR/hFVS66iVKmEo8/Uxw8fJfyUeQo7BhKvG8LTYegBE39Womgyu3KxXb7Jy9DRI5A==
dependencies:
cross-fetch "^3.1.5"
form-data "^4.0.0"