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