enzostvs HF staff commited on
Commit
5dfd24d
β€’
1 Parent(s): 0dfbd23

invalidate load function

Browse files
Files changed (2) hide show
  1. src/routes/+page.svelte +2 -2
  2. src/routes/+page.ts +6 -4
src/routes/+page.svelte CHANGED
@@ -32,7 +32,7 @@
32
  const handleChangeFilter = async (filter: string) => {
33
  form = { ...form, filter, page: (0).toString()};
34
  $page.url.searchParams.set('filter', filter);
35
- goto(`?${$page.url.searchParams.toString()}`);
36
  }
37
  let timeout: any;
38
  const handleChangeSearch = async (search: string) => {
@@ -41,7 +41,7 @@
41
  timeout = setTimeout(() => {
42
  if (search === "") $page.url.searchParams.delete('search');
43
  else $page.url.searchParams.set('search', search);
44
- goto(`?${$page.url.searchParams.toString()}`);
45
  }, 500);
46
  }
47
 
 
32
  const handleChangeFilter = async (filter: string) => {
33
  form = { ...form, filter, page: (0).toString()};
34
  $page.url.searchParams.set('filter', filter);
35
+ goto(`?${$page.url.searchParams.toString()}`, { replaceState: true, invalidateAll: true });
36
  }
37
  let timeout: any;
38
  const handleChangeSearch = async (search: string) => {
 
41
  timeout = setTimeout(() => {
42
  if (search === "") $page.url.searchParams.delete('search');
43
  else $page.url.searchParams.set('search', search);
44
+ goto(`?${$page.url.searchParams.toString()}`, { replaceState: true, invalidateAll: true });
45
  }, 500);
46
  }
47
 
src/routes/+page.ts CHANGED
@@ -1,10 +1,11 @@
1
  import { modelStore } from "$lib/stores/use-model";
2
 
 
3
  export async function load({ fetch, url }) {
4
  const model_param = url.searchParams.get("model")
5
- const search_param = url.searchParams.get("search") ?? ""
6
- const filter_param = url.searchParams.get("filter") ?? "hotest"
7
-
8
  if (model_param) {
9
  const model_request = await fetch(`/api/models/${model_param?.replace("/", "@")}?full=true`, {
10
  method: "GET",
@@ -19,8 +20,9 @@ export async function load({ fetch, url }) {
19
  });
20
  }
21
 
 
22
  const data = {
23
- filter: filter_param,
24
  page: "0",
25
  search: search_param ?? ""
26
  }
 
1
  import { modelStore } from "$lib/stores/use-model";
2
 
3
+ /** @type {import('./$types').PageServerLoad} */
4
  export async function load({ fetch, url }) {
5
  const model_param = url.searchParams.get("model")
6
+ const search_param = url.searchParams.get("search") ?? undefined
7
+ const filter_param = url.searchParams.get("filter") ?? undefined
8
+
9
  if (model_param) {
10
  const model_request = await fetch(`/api/models/${model_param?.replace("/", "@")}?full=true`, {
11
  method: "GET",
 
20
  });
21
  }
22
 
23
+
24
  const data = {
25
+ filter: filter_param ?? "hotest",
26
  page: "0",
27
  search: search_param ?? ""
28
  }