diff options
author | Eric Bailey <git@esb.lol> | 2024-06-18 13:50:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 21:50:07 +0300 |
commit | 983d85384b9e736193e6c89107df5ced447a056a (patch) | |
tree | 8ecc5157012be5deda6ac44a86c6c3ad409c9a9f /src/view | |
parent | fb76265fcc0042bc8cd5a3f7563790f495d3ae8c (diff) | |
download | voidsky-983d85384b9e736193e6c89107df5ced447a056a.tar.zst |
Force callers of `getTimeAgo` to pass in the value for "now" (#4560)
* Remove icky hook for now * Force callers of getTimeAgo to pass in the 'now' value * Update usage in Newskie dialog
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/util/TimeElapsed.tsx | 6 | ||||
-rw-r--r-- | src/view/screens/Log.tsx | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/view/com/util/TimeElapsed.tsx b/src/view/com/util/TimeElapsed.tsx index d939b3163..a49585182 100644 --- a/src/view/com/util/TimeElapsed.tsx +++ b/src/view/com/util/TimeElapsed.tsx @@ -15,12 +15,14 @@ export function TimeElapsed({ const ago = useGetTimeAgo() const format = timeToString ?? ago const tick = useTickEveryMinute() - const [timeElapsed, setTimeAgo] = React.useState(() => format(timestamp)) + const [timeElapsed, setTimeAgo] = React.useState(() => + format(timestamp, tick), + ) const [prevTick, setPrevTick] = React.useState(tick) if (prevTick !== tick) { setPrevTick(tick) - setTimeAgo(format(timestamp)) + setTimeAgo(format(timestamp, tick)) } return children({timeElapsed}) diff --git a/src/view/screens/Log.tsx b/src/view/screens/Log.tsx index e10aa83ab..e6040b77e 100644 --- a/src/view/screens/Log.tsx +++ b/src/view/screens/Log.tsx @@ -7,6 +7,7 @@ import {useFocusEffect} from '@react-navigation/native' import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo' import {getEntries} from '#/logger/logDump' +import {useTickEveryMinute} from '#/state/shell' import {useSetMinimalShellMode} from '#/state/shell' import {usePalette} from 'lib/hooks/usePalette' import {CommonNavigatorParams, NativeStackScreenProps} from 'lib/routes/types' @@ -24,6 +25,7 @@ export function LogScreen({}: NativeStackScreenProps< const setMinimalShellMode = useSetMinimalShellMode() const [expanded, setExpanded] = React.useState<string[]>([]) const timeAgo = useGetTimeAgo() + const tick = useTickEveryMinute() useFocusEffect( React.useCallback(() => { @@ -72,7 +74,7 @@ export function LogScreen({}: NativeStackScreenProps< /> ) : undefined} <Text type="sm" style={[styles.ts, pal.textLight]}> - {timeAgo(entry.timestamp)} + {timeAgo(entry.timestamp, tick)} </Text> </TouchableOpacity> {expanded.includes(entry.id) ? ( |