Live video on the AT Protocol

bugfix: add offline setting and fix timestamp parsing

+16 -2
+16 -2
js/app/components/livestream/livestream.tsx
··· 64 const [outerHeight, setOuterHeight] = useState(0); 65 const [innerHeight, setInnerHeight] = useState(0); 66 const [isChatVisible, setIsChatVisible] = useState(true); 67 const [currentUserDID, setCurrentUserDID] = useState<string | null>(null); 68 const { fullscreen, setFullscreen } = useFullscreen(); 69 70 const streamerDID = player.livestream?.author?.did; 71 const streamerProfile = streamerDID ? profiles[streamerDID] : undefined; 72 const streamerHandle = streamerProfile?.handle; 73 - const startTime = player.livestream?.record?.createdAt || Date(); 74 75 // this would all be really easy if i had library that would give me the 76 // safe area view height and width but i don't. so let's measure ··· 104 dispatch(getProfile(streamerDID)); 105 } 106 }, [streamerDID, streamerProfile, dispatch]); 107 108 let slideKeyboard = 0; 109 if (isIOS && keyboardHeight > 0) { ··· 264 )} 265 </View> 266 <View flexDirection="row" alignItems="center" gap="$2"> 267 - <Timer start={startTime} /> 268 <Viewers viewers={player.viewers ?? 0} /> 269 <Button 270 backgroundColor="transparent"
··· 64 const [outerHeight, setOuterHeight] = useState(0); 65 const [innerHeight, setInnerHeight] = useState(0); 66 const [isChatVisible, setIsChatVisible] = useState(true); 67 + const [offline, setOffline] = useState(true); 68 const [currentUserDID, setCurrentUserDID] = useState<string | null>(null); 69 const { fullscreen, setFullscreen } = useFullscreen(); 70 71 const streamerDID = player.livestream?.author?.did; 72 const streamerProfile = streamerDID ? profiles[streamerDID] : undefined; 73 const streamerHandle = streamerProfile?.handle; 74 + const startTime = player.livestream?.record?.createdAt 75 + ? new Date(player.livestream?.record?.createdAt) : undefined; 76 77 // this would all be really easy if i had library that would give me the 78 // safe area view height and width but i don't. so let's measure ··· 106 dispatch(getProfile(streamerDID)); 107 } 108 }, [streamerDID, streamerProfile, dispatch]); 109 + 110 + useEffect(() => { 111 + // 10 second cut off for segements 112 + const cuttOffDate = new Date(Date.now() - 10 * 1000); 113 + // 15 second cut off if segment start time not found 114 + const startTime = player.segment?.startTime 115 + ? new Date(player.segment?.startTime) : new Date(Date.now() - 15 * 1000); 116 + 117 + if (startTime > cuttOffDate) { 118 + setOffline(false); 119 + } 120 + }, [player.segment]); 121 122 let slideKeyboard = 0; 123 if (isIOS && keyboardHeight > 0) { ··· 278 )} 279 </View> 280 <View flexDirection="row" alignItems="center" gap="$2"> 281 + {(startTime instanceof Date) && !offline && <Timer start={startTime} />} 282 <Viewers viewers={player.viewers ?? 0} /> 283 <Button 284 backgroundColor="transparent"