@@ -4,44 +4,12 @@ import { twMerge } from 'tailwind-merge'
44import Badge from '@/components/Badge'
55import { badgeCVA } from '@/components/design'
66import MultiSegment from '@/components/MultiSegment'
7+ import { allLeafValues , timeAgo } from '@/components/misc'
78import type { CommentTableRow } from '@/entrypoints/background'
89import type { FilterState } from '@/entrypoints/popup/popup'
910import { EnhancerRegistry } from '@/lib/registries'
1011import { generateMockDrafts } from './replicaData'
1112
12- // Helper function for relative time
13- function timeAgo ( date : Date | number ) : string {
14- const timestamp = typeof date === 'number' ? date : date . getTime ( )
15- const seconds = Math . floor ( ( Date . now ( ) - timestamp ) / 1000 )
16- const intervals = [
17- { label : 'y' , secs : 31536000 } ,
18- { label : 'mo' , secs : 2592000 } ,
19- { label : 'w' , secs : 604800 } ,
20- { label : 'd' , secs : 86400 } ,
21- { label : 'h' , secs : 3600 } ,
22- { label : 'm' , secs : 60 } ,
23- { label : 's' , secs : 1 } ,
24- ]
25- for ( const i of intervals ) {
26- const v = Math . floor ( seconds / i . secs )
27- if ( v >= 1 ) return `${ v } ${ i . label } `
28- }
29- return 'just now'
30- }
31-
32- /** Returns all leaf values of an arbitrary object as strings. */
33- function * allLeafValues ( obj : any , visited = new Set ( ) ) : Generator < string > {
34- if ( visited . has ( obj ) || obj == null ) return
35- if ( typeof obj === 'string' ) yield obj
36- else if ( typeof obj === 'number' ) yield String ( obj )
37- else if ( typeof obj === 'object' ) {
38- visited . add ( obj )
39- for ( const key in obj ) {
40- yield * allLeafValues ( obj [ key ] , visited )
41- }
42- }
43- }
44-
4513export const ClaudePrototype = ( ) => {
4614 const [ drafts ] = useState ( generateMockDrafts ( ) )
4715 const [ selectedIds , setSelectedIds ] = useState ( new Set ( ) )
0 commit comments