diff options
Diffstat (limited to 'src/routes/(app)')
| -rw-r--r-- | src/routes/(app)/contacts/+server.ts | 12 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.server.ts | 5 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.svelte | 16 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/routes/(app)/contacts/+server.ts b/src/routes/(app)/contacts/+server.ts new file mode 100644 index 00000000..e448bda2 --- /dev/null +++ b/src/routes/(app)/contacts/+server.ts @@ -0,0 +1,12 @@ +import { auth, get } from "$lib/utils"; +import { json } from "@sveltejs/kit"; + +export async function GET({ cookies }) { + try { + const contacts = await get("/contacts", auth(cookies)); + return json(contacts); + } catch (e) { + console.log(e); + return json({}); + } +} diff --git a/src/routes/(app)/send/[...text]/+page.server.ts b/src/routes/(app)/send/[...text]/+page.server.ts index b0baa2d5..3bd8dff3 100644 --- a/src/routes/(app)/send/[...text]/+page.server.ts +++ b/src/routes/(app)/send/[...text]/+page.server.ts @@ -1,12 +1,13 @@ +import parse from "$lib/parse"; import { auth, fd, get } from "$lib/utils"; import { fail } from "@sveltejs/kit"; -import parse from "$lib/parse"; +const limit = 1; export async function load({ cookies, params, url }) { const { text } = params; await parse(text, url.host); - const contacts = await get("/contacts", auth(cookies)); + const contacts = await get(`/contacts/${limit}`, auth(cookies)); return { contacts }; } diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index 2ce9d538..ebc705b5 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -8,12 +8,18 @@ import Avatar from "$comp/Avatar.svelte"; import Icon from "$comp/Icon.svelte"; import Spinner from "$comp/Spinner.svelte"; - import { back, fail, focus } from "$lib/utils"; + import { back, get, fail, focus } from "$lib/utils"; let { data = $bindable(), form } = $props(); data.subject = data.user; - let { contacts } = data; + let { contacts } = $state(data); + + let loaded = $state(); + let loadMore = async () => { + loaded = true; + contacts = await get("/contacts"); + }; let el = $state(), text = $state(), @@ -109,4 +115,10 @@ </div> </div> {/if} + + {#if !loaded} + <button onclick={loadMore} type="button" class="btn" + >{$t("user.loadMore")}</button + > + {/if} </div> |
