Added "followers only" filter

This commit is contained in:
tdgmdev 2023-03-07 18:53:56 -05:00
parent 3448277220
commit 5eb2a25591
5 changed files with 34 additions and 10 deletions

View file

@ -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 };

View file

@ -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>

View file

@ -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};

View file

@ -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}`);