forked from BRETT/BRETT
Initial Commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { CommentAttachment } from '~~/shared/utils/attachments'
|
||||
|
||||
export interface LiveComment {
|
||||
id: number
|
||||
content: string
|
||||
createdAt: string
|
||||
userName: string
|
||||
userId: number
|
||||
userColor: string | null
|
||||
userAvatarUrl: string | null
|
||||
uploadId: string
|
||||
attachments?: CommentAttachment[]
|
||||
}
|
||||
|
||||
export function useLiveComments() {
|
||||
const liveComments = useState<LiveComment[]>('comments:live', () => [])
|
||||
|
||||
function pushLive(comment: LiveComment) {
|
||||
if (liveComments.value.some(c => c.id === comment.id)) return
|
||||
liveComments.value = [comment, ...liveComments.value].slice(0, 50)
|
||||
}
|
||||
|
||||
return { liveComments, pushLive }
|
||||
}
|
||||
Reference in New Issue
Block a user