mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 06:12:23 +03:00
Pass along disconnect time to determine chat disable timer duration (#1310)
This commit is contained in:
parent
6fb383d04b
commit
5adf2cdecd
1 changed files with 18 additions and 14 deletions
|
@ -251,14 +251,6 @@ export default class App extends Component {
|
||||||
lastDisconnectTime,
|
lastDisconnectTime,
|
||||||
} = status;
|
} = status;
|
||||||
|
|
||||||
if (status.online && !curStreamOnline) {
|
|
||||||
// stream has just come online.
|
|
||||||
this.handleOnlineMode();
|
|
||||||
} else if (!status.online && curStreamOnline) {
|
|
||||||
// stream has just flipped offline.
|
|
||||||
this.handleOfflineMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
viewerCount,
|
viewerCount,
|
||||||
lastConnectTime,
|
lastConnectTime,
|
||||||
|
@ -266,6 +258,14 @@ export default class App extends Component {
|
||||||
streamTitle,
|
streamTitle,
|
||||||
lastDisconnectTime,
|
lastDisconnectTime,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (status.online && !curStreamOnline) {
|
||||||
|
// stream has just come online.
|
||||||
|
this.handleOnlineMode();
|
||||||
|
} else if (!status.online && curStreamOnline) {
|
||||||
|
// stream has just flipped offline.
|
||||||
|
this.handleOfflineMode(lastDisconnectTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// when videojs player is ready, start polling for stream
|
// when videojs player is ready, start polling for stream
|
||||||
|
@ -296,13 +296,17 @@ export default class App extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop status timer and disable chat after some time.
|
// stop status timer and disable chat after some time.
|
||||||
handleOfflineMode() {
|
handleOfflineMode(lastDisconnectTime) {
|
||||||
clearInterval(this.streamDurationTimer);
|
clearInterval(this.streamDurationTimer);
|
||||||
const remainingChatTime =
|
|
||||||
TIMER_DISABLE_CHAT_AFTER_OFFLINE -
|
if (lastDisconnectTime) {
|
||||||
(Date.now() - new Date(this.state.lastDisconnectTime));
|
const remainingChatTime =
|
||||||
const countdown = remainingChatTime < 0 ? 0 : remainingChatTime;
|
TIMER_DISABLE_CHAT_AFTER_OFFLINE -
|
||||||
this.disableChatInputTimer = setTimeout(this.disableChatInput, countdown);
|
(Date.now() - new Date(lastDisconnectTime));
|
||||||
|
const countdown = remainingChatTime < 0 ? 0 : remainingChatTime;
|
||||||
|
this.disableChatInputTimer = setTimeout(this.disableChatInput, countdown);
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
streamOnline: false,
|
streamOnline: false,
|
||||||
streamStatusMessage: MESSAGE_OFFLINE,
|
streamStatusMessage: MESSAGE_OFFLINE,
|
||||||
|
|
Loading…
Reference in a new issue