refactor: 🏗️

This commit is contained in:
codytseng 2025-12-25 23:03:33 +08:00
parent d964c7b7b3
commit e25902b8b4
18 changed files with 619 additions and 426 deletions

16
src/hooks/useThread.tsx Normal file
View file

@ -0,0 +1,16 @@
import threadService from '@/services/thread.service'
import { useSyncExternalStore } from 'react'
export function useThread(stuffKey: string) {
return useSyncExternalStore(
(cb) => threadService.listenThread(stuffKey, cb),
() => threadService.getThread(stuffKey)
)
}
export function useAllDescendantThreads(stuffKey: string) {
return useSyncExternalStore(
(cb) => threadService.listenAllDescendantThreads(stuffKey, cb),
() => threadService.getAllDescendantThreads(stuffKey)
)
}