Bugfix live status state (#1689)
* fix bug and add some documentation * Prevent is_live fetching when playing stream and going back to livestream page Co-authored-by: Rafael <rafael.saes@odysee.com>
This commit is contained in:
parent
e6a563443e
commit
bd9a6ac2bb
2 changed files with 8 additions and 2 deletions
|
@ -107,7 +107,7 @@ export default function LivestreamPage(props: Props) {
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useFetchLiveStatus(livestreamChannelId, doFetchChannelLiveStatus);
|
||||
useFetchLiveStatus(isStreamPlaying ? undefined : livestreamChannelId, doFetchChannelLiveStatus);
|
||||
|
||||
React.useEffect(() => {
|
||||
setActiveStreamUri(!isCurrentClaimLive && isChannelBroadcasting ? activeLivestreamForChannel.claimUri : false);
|
||||
|
|
|
@ -15,12 +15,18 @@ const defaultState: LivestreamState = {
|
|||
socketConnectionById: {},
|
||||
};
|
||||
|
||||
/**
|
||||
* Update state.viewersById with the latest data
|
||||
* @param {object} activeLivestreams - streams with fetched data
|
||||
* @param {object} originalState - streams with only their view counts
|
||||
* @returns {*} - updated viewersById object if active streams passed, otherwise return old data
|
||||
*/
|
||||
function updateViewersById(activeLivestreams, originalState) {
|
||||
if (activeLivestreams) {
|
||||
const viewersById = Object.assign({}, originalState);
|
||||
Object.values(activeLivestreams).forEach((data) => {
|
||||
// $FlowFixMe: mixed
|
||||
if (data.claimId && data.viewCount) {
|
||||
if (data && data.claimId && data.viewCount) {
|
||||
// $FlowFixMe: mixed
|
||||
viewersById[data.claimId] = data.viewCount;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue