Skip to content

Commit c6e8d69

Browse files
committed
fix: category slug reactive closes #294
Signed-off-by: Innei <[email protected]>
1 parent c009425 commit c6e8d69

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/components/layout/header/internal/Activity.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const ActivityIcon = memo(() => {
109109
}
110110
setActivityProcessInfo({
111111
name: data.processInfo?.name || data.processName,
112+
iconUrl: data.processInfo?.iconUrl,
112113
iconBase64: data.processInfo?.iconBase64,
113114
description: data.processInfo?.description,
114115
})
@@ -203,7 +204,11 @@ const TriggerComponent = memo<{
203204
const isBuiltIn = !!appIcon[processName]
204205

205206
const src =
206-
!isBuiltIn && icon ? icon : `${CND_DOMAIN}/apps/${appIcon[processName]}.png`
207+
!isBuiltIn && icon
208+
? icon
209+
: isBuiltIn
210+
? `${CND_DOMAIN}/apps/${appIcon[processName]}.png`
211+
: ''
207212

208213
const className = clsx('pointer-events-none select-none', {
209214
'rounded-md': !isBuiltIn,
@@ -214,7 +219,7 @@ const TriggerComponent = memo<{
214219
<Image
215220
width={32}
216221
height={32}
217-
src={error ? ErrorFallback : src}
222+
src={error ? ErrorFallback : src || ErrorFallback}
218223
alt={processName}
219224
priority
220225
fetchPriority="low"

src/components/modules/dashboard/home/Shiju.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const ShiJu = () => {
2121
if (!origin) return null
2222
return (
2323
<FloatPopover triggerElement={<span>{data?.shiju}</span>}>
24-
<div className="text-center">
24+
<div className="max-w-[800px] text-center">
2525
<h3 className="sticky top-0 py-2 text-2xl font-medium">
2626
{origin.title}
2727
</h3>

src/components/modules/dashboard/post-editing/SlugInput.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useQuery } from '@tanstack/react-query'
2-
import { useEffect, useRef } from 'react'
2+
import { useEffect, useMemo, useRef } from 'react'
3+
import type { CategoryModel } from '@mx-space/api-client'
34

45
import { adminQueries } from '~/queries/definition'
56

@@ -22,14 +23,24 @@ export const SlugInput = () => {
2223
setCategoryId(category.id)
2324
}
2425
}, [category, categoryId, setCategoryId])
26+
const categoryIdMap: Record<string, CategoryModel> = useMemo(() => {
27+
if (!categories) return {}
28+
return categories.data.reduce(
29+
(acc, category) => ({
30+
...acc,
31+
[category.id]: category,
32+
}),
33+
{},
34+
)
35+
}, [categories])
2536

2637
const isLoading = !category
2738
return (
2839
<>
29-
{isLoading ? (
30-
<div className="h-2 w-[120px] animate-pulse bg-white " />
40+
{isLoading || !categoryId ? (
41+
<div className="h-2 w-[120px] animate-pulse bg-white" />
3142
) : (
32-
<label className="text-base-content">{`${webUrl}/posts/${category?.slug}/`}</label>
43+
<label className="text-base-content">{`${webUrl}/posts/${categoryIdMap?.[categoryId]?.slug}/`}</label>
3344
)}
3445

3546
<div className="relative ml-1 inline-flex min-w-[2rem] items-center overflow-hidden rounded-md bg-white py-1 dark:bg-zinc-900 [&_*]:leading-4">

0 commit comments

Comments
 (0)