diff --git a/src/lang/en_GB.json b/src/lang/en_GB.json index 5ff5657..cf52f3e 100644 --- a/src/lang/en_GB.json +++ b/src/lang/en_GB.json @@ -60,6 +60,7 @@ "post": { "loading": "loading post...", + "pinned": "📌 Pinned post", "by": "Post by %1", "time": "%1 ago", "boosted": "%1 boosted this post.", diff --git a/src/lib/api.js b/src/lib/api.js index c9b97ba..d5cfbb8 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -448,3 +448,51 @@ export async function lookupUser(host, token, handle) { return data; } + +/** + * GET /api/v1/accounts/{user_id}/statuses + * @param {string} host - The domain of the target server. + * @param {string} token - The application token. + * @param {string} user_id - The ID of the user to fetch. + * @param {string} max_id - If provided, only shows notifications before this ID. + * @param {boolean} replies - If replies should be fetched. + * @param {boolean} boosts - If boosts should be fetched. + * @param {boolean} only_media - If only media should be fetched. + */ +export async function getUserPosts(host, token, user_id, max_id, show_replies, show_boosts, only_media) { + let url = new URL(`https://${host}/api/v1/accounts/${user_id}/statuses`); + let query = []; + if (!show_replies) + query.push('exclude_replies=true'); + if (!show_boosts) + query.push('exclude_boosts=true'); + if (only_media) + query.push('only_media=true'); + if (max_id) + query.push(`max_id=${max_id}`); + url.search = query.join('&'); + + const data = await fetch(url, { + method: 'GET', + headers: { "Authorization": token ? `Bearer ${token}` : null } + }).then(res => res.json()); + + return data; +} + +/** + * GET /api/v1/accounts/{user_id}/statuses?pinned=true + * @param {string} host - The domain of the target server. + * @param {string} token - The application token. + * @param {string} user_id - The ID of the user to fetch. + */ +export async function getUserPinnedPosts(host, token, user_id) { + let url = `https://${host}/api/v1/accounts/${user_id}/statuses?pinned=true`; + + const data = await fetch(url, { + method: 'GET', + headers: { "Authorization": token ? `Bearer ${token}` : null } + }).then(res => res.json()); + + return data; +} diff --git a/src/lib/app.css b/src/lib/app.css index 0959dd5..fccff4a 100644 --- a/src/lib/app.css +++ b/src/lib/app.css @@ -81,6 +81,10 @@ img.emoji { margin: -.2em 0; } +hr { + border-color: color-mix(in srgb, transparent, var(--accent) 50%); +} + .throb { animation: .25s throb alternate infinite ease-in; } diff --git a/src/lib/ui/Navigation.svelte b/src/lib/ui/Navigation.svelte index e15979e..d67f391 100644 --- a/src/lib/ui/Navigation.svelte +++ b/src/lib/ui/Navigation.svelte @@ -4,12 +4,10 @@ import { server } from '$lib/client/server.js'; import { app } from '$lib/client/app.js'; import { playSound } from '$lib/sound.js'; - import { getTimeline } from '$lib/timeline.js'; - import { getNotifications } from '$lib/notifications.js'; import { goto } from '$app/navigation'; import { page } from '$app/stores'; import { createEventDispatcher } from 'svelte'; - import { notifications, unread_notif_count } from '$lib/notifications.js'; + import { unread_notif_count } from '$lib/notifications.js'; import Lang from '$lib/lang'; import Logo from '$lib/../img/campfire-logo.svg'; @@ -81,7 +79,7 @@ {lang.string('navigation.timeline')} + +
+ {#if profile_pinned_posts} + {#each $profile_pinned_posts as post} + + {/each} +


+ {/if} +
+
+ {#each $profile_posts as post} + + {/each} +
{:catch error}

{error}

{/await}