feat: add contextual actions to command palette

This commit is contained in:
Xylight committed 2024-10-18 14:06:30 -07:00
1 parent 3738413184
commit d7d8981cc6
6 files changed
+176 -69

No files matched your search

+24 -11
View File
@@ -6,6 +6,8 @@ import { error } from '@sveltejs/kit'
import { browser } from '$app/environment'
import { instance } from '$lib/instance'
import { postFeed, postFeeds, shouldReload } from '$lib/lemmy/postfeed.js'
import { t } from '$lib/translations.js'
import { ChevronDoubleUp } from 'svelte-hero-icons'
export async function load({ url, fetch }) {
const cursor = url.searchParams.get('cursor') as string | undefined
@@ -18,16 +20,27 @@ export async function load({ url, fetch }) {
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
return await postFeed({
id: 'main',
request: {
page_cursor: cursor,
sort: sort,
type_: listingType,
limit: 20,
show_hidden: settings.posts.showHidden,
return {
...(await postFeed({
id: 'main',
request: {
page_cursor: cursor,
sort: sort,
type_: listingType,
limit: 20,
show_hidden: settings.posts.showHidden,
},
url: url,
fetch: fetch,
})),
contextual: {
actions: [
{
name: t.get('routes.post.scrollToTop'),
handle: () => window?.scrollTo({ top: 0, behavior: 'instant' }),
icon: ChevronDoubleUp,
},
],
},
url: url,
fetch: fetch,
})
}
}