1
1
'use client'
2
2
3
3
import { useQuery } from '@tanstack/react-query'
4
- import { memo , useCallback , useEffect } from 'react'
4
+ import { memo , useEffect } from 'react'
5
5
import clsx from 'clsx'
6
6
import { m } from 'framer-motion'
7
- import Link from 'next/link'
8
7
import { useRouter , useSearchParams } from 'next/navigation'
9
8
import type { TimelineData } from '@mx-space/api-client'
10
- import type { SyntheticEvent } from 'react'
11
9
12
10
import { TimelineType } from '@mx-space/api-client'
13
11
@@ -17,13 +15,10 @@ import { NormalContainer } from '~/components/layout/container/Normal'
17
15
import { Divider } from '~/components/ui/divider'
18
16
import { TimelineList } from '~/components/ui/list/TimelineList'
19
17
import { BottomToUpSoftScaleTransitionView } from '~/components/ui/transition/BottomToUpSoftScaleTransitionView'
20
- import { NotePreview } from '~/components/widgets/peek/NotePreview'
21
- import { PeekModal } from '~/components/widgets/peek/PeekModal'
22
- import { PostPreview } from '~/components/widgets/peek/PostPreview'
18
+ import { PeekLink } from '~/components/widgets/peek/PeekLink'
23
19
import { TimelinProgress } from '~/components/widgets/timeline/TimelineProgress'
24
20
import { apiClient } from '~/lib/request'
25
21
import { springScrollToElement } from '~/lib/scroller'
26
- import { useModalStack } from '~/providers/root/modal-stack-provider'
27
22
28
23
enum ArticleType {
29
24
Post ,
@@ -221,48 +216,7 @@ const Item = memo<{
221
216
} > ( ( { item } ) => {
222
217
const router = useRouter ( )
223
218
const isMobile = useIsMobile ( )
224
- const { present } = useModalStack ( )
225
-
226
- const handlePeek = useCallback (
227
- ( e : SyntheticEvent ) => {
228
- if ( isMobile ) return
229
- if ( item . type === ArticleType . Note ) {
230
- {
231
- e . preventDefault ( )
232
- present ( {
233
- clickOutsideToDismiss : true ,
234
- title : 'Preview' ,
235
- modalClassName : 'flex justify-center' ,
236
- modalContainerClassName : 'flex justify-center' ,
237
- CustomModalComponent : ( ) => (
238
- < PeekModal to = { item . href } >
239
- < NotePreview noteId = { parseInt ( item . href . split ( '/' ) . pop ( ) ! ) } />
240
- </ PeekModal >
241
- ) ,
242
- content : ( ) => null ,
243
- } )
244
- }
245
- } else if ( item . type === ArticleType . Post ) {
246
- e . preventDefault ( )
247
- const splitpath = item . href . split ( '/' )
248
- const slug = splitpath . pop ( ) !
249
- const category = splitpath . pop ( ) !
250
- present ( {
251
- clickOutsideToDismiss : true ,
252
- title : 'Preview' ,
253
- modalClassName : 'flex justify-center' ,
254
- modalContainerClassName : 'flex justify-center' ,
255
- CustomModalComponent : ( ) => (
256
- < PeekModal to = { item . href } >
257
- < PostPreview category = { category } slug = { slug } />
258
- </ PeekModal >
259
- ) ,
260
- content : ( ) => null ,
261
- } )
262
- }
263
- } ,
264
- [ isMobile ] ,
265
- )
219
+
266
220
return (
267
221
< li
268
222
key = { item . id }
@@ -276,14 +230,13 @@ const Item = memo<{
276
230
day : '2-digit' ,
277
231
} ) . format ( item . date ) }
278
232
</ span >
279
- < Link
233
+ < PeekLink
280
234
prefetch = { false }
281
235
href = { item . href }
282
236
className = "min-w-0 truncate leading-6"
283
- onClick = { handlePeek }
284
237
>
285
238
< span className = "min-w-0 truncate" > { item . title } </ span >
286
- </ Link >
239
+ </ PeekLink >
287
240
{ item . important && (
288
241
< SolidBookmark
289
242
className = "ml-2 cursor-pointer text-red-500"
0 commit comments