From b07a37189bdc8bf22c083847c755f0e239e8c14a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 10 Aug 2022 01:04:59 +0200 Subject: [PATCH] remove query param offset pagination --- .../console/[project]/users/index.svelte | 19 ++----------------- .../console/[project]/users/teams.svelte | 15 ++------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/routes/console/[project]/users/index.svelte b/src/routes/console/[project]/users/index.svelte index b581e6ab3..61a8d0f07 100644 --- a/src/routes/console/[project]/users/index.svelte +++ b/src/routes/console/[project]/users/index.svelte @@ -20,12 +20,11 @@ import { Container } from '$lib/layout'; import { base } from '$app/paths'; import { usersList } from './store'; - import { onMount } from 'svelte'; import type { Models } from '@aw-labs/appwrite-console'; let showCreate = false; let search = ''; - let offset: number = null; + let offset = 0; const limit = 5; const project = $page.params.project; @@ -34,22 +33,8 @@ await goto(`${base}/console/${project}/users/user/${event.detail.$id}`); }; - $: usersList.load(search, limit, offset ?? 0); $: if (search) offset = 0; - $: { - //TODO: refactor this into something maintainable without the use of goto - if (offset !== null) { - $page.url.searchParams.set('offset', offset.toString()); - goto(`?${$page.url.searchParams.toString()}`, { replaceState: true, keepfocus: true }); - } - } - - onMount(() => { - const queryOffset = +$page.url.searchParams.get('offset') ?? 0; - if (offset && offset !== queryOffset) { - offset = queryOffset; - } - }); + $: usersList.load(search, limit, offset ?? 0); diff --git a/src/routes/console/[project]/users/teams.svelte b/src/routes/console/[project]/users/teams.svelte index 376f3578c..b65691801 100644 --- a/src/routes/console/[project]/users/teams.svelte +++ b/src/routes/console/[project]/users/teams.svelte @@ -19,7 +19,6 @@ import { Container } from '$lib/layout'; import { base } from '$app/paths'; import { teamsList } from './store'; - import { onMount } from 'svelte'; import type { Models } from '@aw-labs/appwrite-console'; let search = ''; @@ -32,19 +31,9 @@ const teamCreated = async (event: CustomEvent) => { await goto(`${base}/console/${project}/users/teams/${event.detail.$id}`); }; - $: teamsList.load(search, limit, offset); - $: if (search) offset = 0; - $: { - //TODO: refactor this into something maintainable without the use of goto - if (offset !== null) { - $page.url.searchParams.set('offset', offset.toString()); - goto(`?${$page.url.searchParams.toString()}`, { replaceState: true, keepfocus: true }); - } - } - onMount(() => { - offset = +$page.url.searchParams.get('offset') ?? 0; - }); + $: if (search) offset = 0; + $: teamsList.load(search, limit, offset);