Fix live activity timer
This commit is contained in:
@@ -2014,6 +2014,7 @@ const ActivityChainSummary: FC<{
|
||||
});
|
||||
const initialStartedAtMs =
|
||||
metadataRunStartedAtMs ?? contentRunStartedAtMs ?? messageCreatedAtMs;
|
||||
const liveStartedAtRef = useRef<number | null>(initialStartedAtMs);
|
||||
const [elapsedMs, setElapsedMs] = useState<number | null>(() => {
|
||||
if (storedElapsedMs !== null) return storedElapsedMs;
|
||||
if (initialStartedAtMs !== null) {
|
||||
@@ -2041,11 +2042,14 @@ const ActivityChainSummary: FC<{
|
||||
setElapsedMs(storedElapsedMs);
|
||||
return;
|
||||
}
|
||||
const startedAt =
|
||||
metadataRunStartedAtMs ??
|
||||
contentRunStartedAtMs ??
|
||||
messageCreatedAtMs ??
|
||||
(storedElapsedMs === null ? null : Date.now() - storedElapsedMs);
|
||||
const explicitStartedAt =
|
||||
metadataRunStartedAtMs ?? contentRunStartedAtMs ?? messageCreatedAtMs;
|
||||
if (explicitStartedAt !== null) {
|
||||
liveStartedAtRef.current = explicitStartedAt;
|
||||
} else if (liveStartedAtRef.current === null && storedElapsedMs !== null) {
|
||||
liveStartedAtRef.current = Date.now() - storedElapsedMs;
|
||||
}
|
||||
const startedAt = liveStartedAtRef.current;
|
||||
if (startedAt === null) {
|
||||
setElapsedMs(storedElapsedMs);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user