Added "followers only" filter
This commit is contained in:
parent
3448277220
commit
5eb2a25591
5 changed files with 34 additions and 10 deletions
|
@ -6,9 +6,11 @@ export async function load({ fetch, params, url }) {
|
|||
|
||||
var sort = search.get('sort') || 'rating';
|
||||
|
||||
var type = search.get('type') || 'all';
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/postBulk?page=${id}&sort=${sort}`);
|
||||
const res = await fetch(`/api/postBulk?page=${id}&sort=${sort}&type=${type}`);
|
||||
const postJson = await res.json();
|
||||
|
||||
return { postJson, id };
|
||||
|
|
|
@ -1,8 +1,22 @@
|
|||
<script>
|
||||
import PostList from '$lib/components/PostList.svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import {setLocation} from '$lib/util.js';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<PostList data={data} />
|
||||
<p>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'type',('all')) }}>All users</Button>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'type',('follow')) }}>Followers only</Button>
|
||||
</p>
|
||||
|
||||
<PostList data={data} />
|
||||
|
||||
<p>
|
||||
{#if data.id > 0}
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)-1)) }}>Previous page</Button>
|
||||
{/if}
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)+1)) }}>Next page</Button>
|
||||
</p>
|
|
@ -9,7 +9,7 @@ export async function load({ fetch, params, url }) {
|
|||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/postBulk?id=${id}&page=${page}&sort=${sort}`);
|
||||
const res = await fetch(`/api/postBulk?id=${id}&page=${page}&sort=${sort}&type=post`);
|
||||
const postJson = (await res.json());
|
||||
|
||||
return {postJson, id: page};
|
||||
|
|
|
@ -11,7 +11,7 @@ export async function load({ fetch, params, url }) {
|
|||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/postBulk?user=${user}&page=${id}&sort=${sort}`);
|
||||
const res = await fetch(`/api/postBulk?user=${user}&page=${id}&sort=${sort}&type=user`);
|
||||
const postJson = await res.json();
|
||||
|
||||
const resUser = await fetch(`/api/userGet?user=${user}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue