1- import {
2- AndroidSolidIcon ,
3- AppleSolidIcon ,
4- ChromeSolidIcon ,
5- WavingHand02SolidIcon ,
6- WindowsOldSolidIcon ,
7- } from '@assets/icons/icons'
1+ import { WavingHand02SolidIcon } from '@assets/icons/icons'
82import { Gap12 } from '@components/Gap'
93import RoundedIcon from '@components/RoundedIcon'
104import { SettGroup , SettOption , SettText , SettWrapper } from '@components/Settings'
115import { useMutation , useQuery } from '@tanstack/react-query'
126import { client } from '@utils/client'
137import { Colors } from '@utils/colors'
148import { F , Medium } from '@utils/fonts'
15- import type { NavProp , NU , StackNav } from '@utils/types'
9+ import { getRelativeTime } from '@utils/timeFormat'
10+ import type { NavProp , StackNav } from '@utils/types'
1611import React , { useEffect , useMemo } from 'react'
1712import { ActivityIndicator , Alert , ToastAndroid } from 'react-native'
1813import type { Device } from './types'
19- import { getDate , getDeviceIcon } from './utils'
20- import { getRelativeTime } from '@utils/timeFormat'
14+ import { getDeviceIcon } from './utils'
2115
2216export default function Devices ( { navigation } : NavProp ) {
2317 const { data, isPending } = useQuery ( {
@@ -50,12 +44,10 @@ export default function Devices({ navigation }: NavProp) {
5044 return (
5145 < SettWrapper title = 'Devices' navigation = { navigation } >
5246 < Gap12 >
53- < SettText className = 'mt-3' >
54- You can manage your devices here. You can remove unwanted devices from the list.
55- </ SettText >
47+ < SettText className = 'mt-3' > You can remove unwanted devices from the list.</ SettText >
5648 < SettGroup title = 'This Device' >
5749 { isPending && < ActivityIndicator size = 'large' color = { Colors . accent } className = 'mb-10 mt-5' /> }
58- { data && data . data && < Device navigation = { navigation } device = { data . data . currentDevice } /> }
50+ { data && data . data && < Device navigation = { navigation } device = { data . data . currentDevice } isSelf = { true } /> }
5951 </ SettGroup >
6052 { data && data . data && data . data . devices . length > 0 && (
6153 < SettGroup >
@@ -72,7 +64,7 @@ export default function Devices({ navigation }: NavProp) {
7264 { data && data . data && data . data . devices . length > 0 && (
7365 < SettGroup title = 'Other Devices' >
7466 { data . data . devices . map ( ( device , i ) => (
75- < Device key = { i } navigation = { navigation } device = { device } arrow />
67+ < Device key = { i } navigation = { navigation } device = { device } isSelf />
7668 ) ) }
7769 </ SettGroup >
7870 ) }
@@ -84,21 +76,33 @@ export default function Devices({ navigation }: NavProp) {
8476 )
8577}
8678
87- function Device ( { navigation, device, arrow } : { navigation : StackNav ; device : Device ; arrow ? : boolean } ) {
79+ function Device ( { navigation, device, isSelf } : { navigation : StackNav ; device : Device ; isSelf : boolean } ) {
8880 const Icon = useMemo ( ( ) => getDeviceIcon ( device ?. os , device ?. name ) , [ device ?. os , device ?. name ] )
8981 const { id, time, os, name } = device || { }
90- // const relativeTime = useMemo(() => getRelativeTime(time), [time])
82+
83+ const relativeTime = useMemo ( ( ) => getRelativeTime ( time ) , [ time ] )
9184 return (
9285 < SettOption
93- onPress = { ( ) => arrow && navigation . navigate ( 'Device' , { device } ) }
86+ onPress = { ( ) =>
87+ navigation . navigate ( 'Device' , {
88+ device : {
89+ id : id || 'Unknown' ,
90+ time : time || 0 ,
91+ os,
92+ name,
93+ isSelf,
94+ } ,
95+ } )
96+ }
9497 title = { name || 'Unknown' }
9598 numberOfLines = { 1 }
9699 key = { id }
97100 Icon = { Icon }
98- arrow = { arrow }
101+ arrow
99102 >
100103 < Medium className = 'text-zinc-600 dark:text-zinc-400' style = { F . F10_5 } numberOfLines = { 1 } >
101- { os || 'Unknown' } • { getDate ( time ) }
104+ { /* {os || 'Unknown'} • {getDate(time)} */ }
105+ { os || 'Unknown' } • { relativeTime }
102106 </ Medium >
103107 </ SettOption >
104108 )
0 commit comments