fix: post load fails
This commit is contained in:
7 files changed
+108
-107
No files matched your search
Vendored
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"i18n-ally.localesPaths": [
|
"i18n-ally.localesPaths": [
|
||||||
"src/lib/i18n",
|
"src/lib/app/i18n"
|
||||||
"src/routes/inbox/messages"
|
|
||||||
],
|
],
|
||||||
"i18n-ally.keystyle": "nested"
|
"i18n-ally.keystyle": "nested"
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { Post } from "$lib/api/types"
|
||||||
|
import VirtualList from "$lib/app/render/VirtualList.svelte"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import type { CommentNodeI } from "./comments.svelte"
|
||||||
|
import CommentTree from "./CommentTree.svelte"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
nodes: CommentNodeI[]
|
nodes: CommentNodeI[]
|
||||||
post: Post
|
post: Post
|
||||||
@@ -43,7 +49,7 @@
|
|||||||
>
|
>
|
||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
||||||
<Comments
|
<CommentTree
|
||||||
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
||||||
{post}
|
{post}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
import type { Comment, CommentView } from "$lib/api/types"
|
||||||
|
import { t } from "$lib/app/i18n"
|
||||||
|
import { SvelteMap } from "svelte/reactivity"
|
||||||
|
|
||||||
export interface CommentNodeI {
|
export interface CommentNodeI {
|
||||||
comment_view: CommentView
|
comment_view: CommentView
|
||||||
children: Array<CommentNodeI>
|
children: Array<CommentNodeI>
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export interface FeedTypes {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
export const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
||||||
|
|
||||||
export function feed<Type extends keyof FeedTypes>(
|
export function feed<Type extends keyof FeedTypes>(
|
||||||
id: Type,
|
id: Type,
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import { client } from '$lib/api/client.svelte'
|
|||||||
import { profile } from '$lib/app/auth.svelte'
|
import { profile } from '$lib/app/auth.svelte'
|
||||||
import { settings } from '$lib/app/settings.svelte'
|
import { settings } from '$lib/app/settings.svelte'
|
||||||
import { ReactiveState } from '$lib/app/util.svelte'
|
import { ReactiveState } from '$lib/app/util.svelte'
|
||||||
import { feed } from '$lib/feature/feeds/feed.svelte'
|
import CommunityCard from '$lib/feature/community/CommunityCard.svelte'
|
||||||
|
import { Feed, feed, feeds, type FeedTypes } from '$lib/feature/feeds/feed.svelte'
|
||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
function buildContext(thread?: string) {
|
function buildContext(thread?: string) {
|
||||||
@@ -28,23 +29,10 @@ function buildContext(thread?: string) {
|
|||||||
async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
|
async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
|
||||||
// this never actually loads anything
|
// this never actually loads anything
|
||||||
if (id == '/') {
|
if (id == '/') {
|
||||||
const resolved = feed(id, async (p) => ({
|
return (feeds.get(id) as Feed<FeedTypes['/'][0], FeedTypes['/'][1]>)?.peek()
|
||||||
posts: (await client().getPosts(p)).posts,
|
?.posts.find((i) => i.post.id.toString() == postId)
|
||||||
client: {},
|
|
||||||
params: p,
|
|
||||||
})).peek()
|
|
||||||
|
|
||||||
return resolved
|
|
||||||
? resolved?.posts?.find((i) => i.post.id.toString() == postId)
|
|
||||||
: undefined
|
|
||||||
} else {
|
} else {
|
||||||
return feed(id, async (p) => ({
|
return (feeds.get(id) as Feed<FeedTypes['/c/[name]'][0], FeedTypes['/c/[name]'][1]>)?.peek()
|
||||||
...(await client().getPosts(p)),
|
|
||||||
client: {},
|
|
||||||
params: p,
|
|
||||||
community: await client().getCommunity({}),
|
|
||||||
}))
|
|
||||||
.peek()
|
|
||||||
?.posts.find((i) => i.post.id.toString() == postId)
|
?.posts.find((i) => i.post.id.toString() == postId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,31 @@
|
|||||||
<title>{$t('settings.title')}</title>
|
<title>{$t('settings.title')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
<Tabs
|
||||||
|
routes={[
|
||||||
|
{
|
||||||
|
href: '/settings/app',
|
||||||
|
name: $t('settings.app.title'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/settings/lemmy',
|
||||||
|
name: $t('settings.lemmy.title'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/settings/embeds',
|
||||||
|
name: $t('settings.embeds.title'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/settings/moderation',
|
||||||
|
name: $t('settings.moderation.title'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/settings/other',
|
||||||
|
name: $t('settings.other.title'),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<Header pageHeader class="text-3xl font-bold flex justify-between">
|
<Header pageHeader class="text-3xl font-bold flex justify-between">
|
||||||
{$t('settings.title')}
|
{$t('settings.title')}
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
@@ -92,30 +117,4 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<Tabs
|
|
||||||
routes={[
|
|
||||||
{
|
|
||||||
href: '/settings/app',
|
|
||||||
name: $t('settings.app.title'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '/settings/lemmy',
|
|
||||||
name: $t('settings.lemmy.title'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '/settings/embeds',
|
|
||||||
name: $t('settings.embeds.title'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '/settings/moderation',
|
|
||||||
name: $t('settings.moderation.title'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '/settings/other',
|
|
||||||
name: $t('settings.other.title'),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
style="subpage"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -44,14 +44,73 @@
|
|||||||
toast({ content: err as string, type: 'error' })
|
toast({ content: err as string, type: 'error' })
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
title={$t('routes.theme.import')}
|
title={$t('settings.import')}
|
||||||
action={$t('routes.theme.import')}
|
action={$t('settings.import')}
|
||||||
>
|
>
|
||||||
<TextArea bind:value={importText} style="font-family: monospace;" />
|
<TextArea bind:value={importText} style="font-family: monospace;" />
|
||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Header pageHeader>{$t('routes.theme.title')}</Header>
|
<Header pageHeader>{$t('routes.theme.title')}
|
||||||
|
|
||||||
|
{#snippet extended()}
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
onclick={() => {
|
||||||
|
importing = !importing
|
||||||
|
}}
|
||||||
|
rounding="pill"
|
||||||
|
disabled={themeData.current.id <= 0}
|
||||||
|
>
|
||||||
|
<Icon src={ArrowUpTray} size="16" mini />
|
||||||
|
{$t('settings.import')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onclick={() => {
|
||||||
|
navigator.clipboard.writeText(JSON.stringify(themeData.current.colors))
|
||||||
|
toast({ content: 'Copied theme to clipboard.' })
|
||||||
|
}}
|
||||||
|
rounding="pill"
|
||||||
|
>
|
||||||
|
<Icon src={ArrowDownTray} size="16" mini />
|
||||||
|
{$t('settings.export')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={themeData.current.id <= 0}
|
||||||
|
onclick={() => {
|
||||||
|
modal({
|
||||||
|
actions: [
|
||||||
|
action({
|
||||||
|
content: $t('common.cancel'),
|
||||||
|
close: true,
|
||||||
|
}),
|
||||||
|
action({
|
||||||
|
action: () => {
|
||||||
|
themeData.current.colors = {
|
||||||
|
other: {},
|
||||||
|
primary: {},
|
||||||
|
zinc: {},
|
||||||
|
slate: {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content: $t('settings.reset'),
|
||||||
|
close: true,
|
||||||
|
type: 'danger',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
title: $t('routes.theme.resetWarning.title'),
|
||||||
|
body: $t('routes.theme.resetWarning.description'),
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
rounding="pill"
|
||||||
|
>
|
||||||
|
<Icon src={ArrowPath} size="16" mini />
|
||||||
|
{$t('settings.reset')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</Header>
|
||||||
<div class="flex flex-col gap-4 h-full">
|
<div class="flex flex-col gap-4 h-full">
|
||||||
<h3
|
<h3
|
||||||
class="relative -mb-7 z-10 left-6 font-medium text-sm bg-slate-25 dark:bg-zinc-925 w-max px-1"
|
class="relative -mb-7 z-10 left-6 font-medium text-sm bg-slate-25 dark:bg-zinc-925 w-max px-1"
|
||||||
@@ -59,7 +118,7 @@
|
|||||||
{$t('routes.theme.preset.presets')}
|
{$t('routes.theme.preset.presets')}
|
||||||
</h3>
|
</h3>
|
||||||
<Material
|
<Material
|
||||||
color="transparent"
|
color="uniform"
|
||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
class="overflow-auto max-h-96 relative @container"
|
class="overflow-auto max-h-96 relative @container"
|
||||||
>
|
>
|
||||||
@@ -96,60 +155,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Material>
|
</Material>
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<Button
|
|
||||||
onclick={() => {
|
|
||||||
importing = !importing
|
|
||||||
}}
|
|
||||||
size="lg"
|
|
||||||
disabled={themeData.current.id <= 0}
|
|
||||||
>
|
|
||||||
<Icon src={ArrowUpTray} size="16" mini />
|
|
||||||
{$t('settings.import')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onclick={() => {
|
|
||||||
navigator.clipboard.writeText(JSON.stringify(themeData.current.colors))
|
|
||||||
toast({ content: 'Copied theme to clipboard.' })
|
|
||||||
}}
|
|
||||||
size="lg"
|
|
||||||
>
|
|
||||||
<Icon src={ArrowDownTray} size="16" mini />
|
|
||||||
{$t('settings.export')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
disabled={themeData.current.id <= 0}
|
|
||||||
onclick={() => {
|
|
||||||
modal({
|
|
||||||
actions: [
|
|
||||||
action({
|
|
||||||
content: $t('common.cancel'),
|
|
||||||
close: true,
|
|
||||||
}),
|
|
||||||
action({
|
|
||||||
action: () => {
|
|
||||||
themeData.current.colors = {
|
|
||||||
other: {},
|
|
||||||
primary: {},
|
|
||||||
zinc: {},
|
|
||||||
slate: {},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content: $t('settings.reset'),
|
|
||||||
close: true,
|
|
||||||
type: 'danger',
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
title: $t('routes.theme.resetWarning.title'),
|
|
||||||
body: $t('routes.theme.resetWarning.description'),
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
size="lg"
|
|
||||||
>
|
|
||||||
<Icon src={ArrowPath} size="16" mini />
|
|
||||||
{$t('settings.reset')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
{#if themeData.current.id <= 0}
|
{#if themeData.current.id <= 0}
|
||||||
<Note>
|
<Note>
|
||||||
{$t('routes.theme.preset.description')}
|
{$t('routes.theme.preset.description')}
|
||||||
@@ -161,7 +166,7 @@
|
|||||||
class:pointer-events-none={themeData.current.id <= 0}
|
class:pointer-events-none={themeData.current.id <= 0}
|
||||||
>
|
>
|
||||||
<Material
|
<Material
|
||||||
color="transparent"
|
color="uniform"
|
||||||
class="items-center gap-x-4 color-grid gap-y-2"
|
class="items-center gap-x-4 color-grid gap-y-2"
|
||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
>
|
>
|
||||||
@@ -205,7 +210,7 @@
|
|||||||
{#each Object.entries(defaultColors) as [category, value] (category)}
|
{#each Object.entries(defaultColors) as [category, value] (category)}
|
||||||
<Material
|
<Material
|
||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
color="transparent"
|
color="uniform"
|
||||||
class="flex flex-col gap-2"
|
class="flex flex-col gap-2"
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
|
|||||||
Reference in new issue
Block a user