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