feat: add default comment sorts, close #93

This commit is contained in:
Xyphyn committed 2023-08-10 17:01:25 -07:00
1 parent c5afc07b41
commit f9becd1bd0
7 files changed
+27 -13

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "0.6.2",
"version": "0.6.3",
"private": true,
"scripts": {
"dev": "vite dev",
+4 -2
View File
@@ -1,4 +1,4 @@
import type { SortType } from 'lemmy-js-client'
import type { CommentSortType, SortType } from 'lemmy-js-client'
import { writable } from 'svelte/store'
interface Settings {
@@ -16,6 +16,7 @@ interface Settings {
defaultSort: {
sort: SortType
feed: 'All' | 'Subscribed' | 'Local'
comments: CommentSortType
}
hidePosts: {
deleted: boolean
@@ -40,13 +41,14 @@ const defaultSettings: Settings = {
revertColors: false,
showInstances: {
user: false,
community: false,
community: true,
comments: false,
},
showCompactPosts: false,
defaultSort: {
sort: 'Active',
feed: 'Local',
comments: 'Hot',
},
hidePosts: {
deleted: true,
+1 -1
View File
@@ -89,7 +89,7 @@
}
</script>
<Card elevation={0} class="flex flex-col rounded-md p-4 max-w-full gap-2">
<Card elevation={0} class="flex flex-col rounded-md p-5 max-w-full gap-2">
{#if !isPrivateMessage(item)}
<PostMeta
published={new Date(item.post.published)}
@@ -36,7 +36,7 @@
})
let commentsPage = 1
let commentSort: CommentSortType = 'Hot'
let commentSort: CommentSortType = data.commentSort
let loading = false
let moreComments = true
@@ -46,7 +46,6 @@
data.streamed.comments = getClient().getComments({
auth: $profile?.jwt,
max_depth: 3,
page: commentsPage,
limit: 25,
type_: 'All',
@@ -1,5 +1,6 @@
import { profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import { error } from '@sveltejs/kit'
import { get } from 'svelte/store'
@@ -26,9 +27,12 @@ export async function load({ params, url, fetch }) {
max_depth = 10
}
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
return {
singleThread: parentId != undefined,
post: post,
commentSort: sort,
streamed: {
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
post_id: Number(params.id),
@@ -37,7 +41,7 @@ export async function load({ params, url, fetch }) {
page: 1,
max_depth: max_depth,
saved_only: false,
sort: 'Hot',
sort: sort,
auth: get(profile)?.jwt,
parent_id: parentId,
}),
+14 -5
View File
@@ -8,6 +8,7 @@
import Button from '$lib/components/input/Button.svelte'
import { getInboxNotifications } from '$lib/auth.js'
import Checkbox from '$lib/components/input/Checkbox.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
let data = {
loading: false,
@@ -20,22 +21,29 @@
<div class="flex flex-col">
<h1 class="text-3xl font-bold">Settings</h1>
<h2 class="uppercase font-bold opacity-80 text-sm mt-4">General</h2>
<SectionTitle class="mt-4">General</SectionTitle>
<Setting>
<span slot="title">Default sort</span>
<span slot="description">The default sort to use for feeds.</span>
<div class="flex flex-wrap flex-row gap-4 w-full">
<div class="w-full">
<div class="max-w-full">
<span class="block my-1 font-bold">Feed</span>
<MultiSelect
options={['Subscribed', 'Local', 'All']}
bind:selected={$userSettings.defaultSort.feed}
/>
</div>
<div class="w-full">
<div class="max-w-full">
<span class="block my-1 font-bold">Sort</span>
<Sort bind:selected={$userSettings.defaultSort.sort} navigate={false} />
</div>
<div class="max-w-full">
<span class="block my-1 font-bold">Comments</span>
<MultiSelect
options={['Hot', 'Top', 'New']}
bind:selected={$userSettings.defaultSort.comments}
/>
</div>
</div>
</Setting>
<Setting>
@@ -59,7 +67,8 @@
Show a user's display name instead of their account username.
</span>
</Setting>
<h2 class="uppercase font-bold opacity-80 text-sm mt-4">UI</h2>
<SectionTitle class="mt-4">UI</SectionTitle>
<Setting>
<Checkbox bind:checked={$userSettings.markReadPosts} slot="title">
Mark read posts
@@ -82,7 +91,7 @@
bind:selected={$userSettings.showCompactPosts}
/>
</Setting>
<h2 class="uppercase font-bold opacity-80 text-sm mt-4">Instances</h2>
<SectionTitle class="mt-4">Instances</SectionTitle>
<Setting>
<span slot="title">Show instances</span>
<span slot="description">Show items' instances.</span>
+1 -1
View File
@@ -2,7 +2,7 @@
import Card from '$lib/components/ui/Card.svelte'
</script>
<Card class="flex flex-col gap-3 p-6 text-sm my-2">
<Card class="flex flex-col gap-3 p-5 text-sm my-2">
<h1 class="font-bold"><slot name="title" /></h1>
{#if $$slots.description}
<p class="text-slate-700 dark:text-zinc-300">