Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.4 KB
Raw Blame
import { memo } from 'react'
import { Text } from 'react-native'
import {
  NATIVE_CHAT_MESSAGE_FULL_TIME_FORMAT,
  NATIVE_CHAT_MESSAGE_TIME_FORMAT
} from '../../../../../src/shared/native-chat/transcript/native-chat-message-time'
import { colors, typography } from '../../../theme/mobile-theme'
import { themedStyleSheet } from '../../../theme/themed-styles'
import { useMobileColorScheme } from '../../../theme/use-mobile-color-scheme'
import { scaledType } from './mobile-native-chat-message-styles'

let formatters: { time: Intl.DateTimeFormat; full: Intl.DateTimeFormat } | null = null

export const MobileNativeChatMessageTime = memo(function MobileNativeChatMessageTime({
  timestamp,
  fontScale
}: {
  timestamp: number | null | undefined
  fontScale: number
}): React.JSX.Element | null {
  useMobileColorScheme()
  const date = timestamp == null ? null : new Date(timestamp)
  if (!date || Number.isNaN(date.getTime())) {
    return null
  }
  formatters ??= {
    time: new Intl.DateTimeFormat(undefined, NATIVE_CHAT_MESSAGE_TIME_FORMAT),
    full: new Intl.DateTimeFormat(undefined, NATIVE_CHAT_MESSAGE_FULL_TIME_FORMAT)
  }
  return (
    <Text
      style={[styles.time, scaledType(typography.metaSize, fontScale, 5)]}
      accessibilityLabel={formatters.full.format(date)}
    >
      {formatters.time.format(date)}
    </Text>
  )
})

const styles = themedStyleSheet(() => ({
  time: {
    color: colors.textMuted,
    fontVariant: ['tabular-nums']
  }
}))