diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index b092e618b..befb4b076 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -37,7 +37,7 @@ showRight = scrollLeft < scrollWidth - offsetWidth - 10; }; - //TODO: implement thisdirectly into onScroll + //TODO: implement this directly into onScroll const throttle = (fn: () => void, delay: number) => { let timeout = false; return () => { diff --git a/src/routes/console/[project]/users/index.svelte b/src/routes/console/[project]/users/index.svelte index 9f1381ba2..6406309f2 100644 --- a/src/routes/console/[project]/users/index.svelte +++ b/src/routes/console/[project]/users/index.svelte @@ -20,19 +20,32 @@ import { toLocaleDate } from '$lib/helpers/date'; import { Container } from '$lib/layout'; import { base } from '$app/paths'; + import { usersList } from './store'; + import { onMount } from 'svelte'; - let search = ''; let showCreate = false; - let offset = 0; - const limit = 25; + let search = ''; + let offset: number = null; + const limit = 5; const project = $page.params.project; const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 30, 30).toString(); const userCreated = async (event: CustomEvent>>) => { await goto(`${base}/console/${project}/users/user/${event.detail.$id}`); }; - $: request = sdkForProject.users.list(search, limit, offset, undefined, undefined, 'DESC'); + $: usersList.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()}`); + } + } + + onMount(() => { + offset = +$page.url.searchParams.get('offset') ?? 0; + }); @@ -46,64 +59,60 @@