|
|
@ -8,11 +8,6 @@ import UsernameForm from './components/chat/username.js'; |
|
|
|
import VideoPoster from './components/video-poster.js'; |
|
|
|
import VideoPoster from './components/video-poster.js'; |
|
|
|
import Chat from './components/chat/chat.js'; |
|
|
|
import Chat from './components/chat/chat.js'; |
|
|
|
import Websocket from './utils/websocket.js'; |
|
|
|
import Websocket from './utils/websocket.js'; |
|
|
|
import { |
|
|
|
|
|
|
|
parseSecondsToDurationString, |
|
|
|
|
|
|
|
hasTouchScreen, |
|
|
|
|
|
|
|
getOrientation, |
|
|
|
|
|
|
|
} from './utils/helpers.js'; |
|
|
|
|
|
|
|
import ExternalActionModal, { |
|
|
|
import ExternalActionModal, { |
|
|
|
ExternalActionButton, |
|
|
|
ExternalActionButton, |
|
|
|
} from './components/external-action-modal.js'; |
|
|
|
} from './components/external-action-modal.js'; |
|
|
@ -24,6 +19,10 @@ import { |
|
|
|
debounce, |
|
|
|
debounce, |
|
|
|
generateUsername, |
|
|
|
generateUsername, |
|
|
|
getLocalStorage, |
|
|
|
getLocalStorage, |
|
|
|
|
|
|
|
getOrientation, |
|
|
|
|
|
|
|
hasTouchScreen, |
|
|
|
|
|
|
|
makeLastOnlineString, |
|
|
|
|
|
|
|
parseSecondsToDurationString, |
|
|
|
pluralize, |
|
|
|
pluralize, |
|
|
|
setLocalStorage, |
|
|
|
setLocalStorage, |
|
|
|
} from './utils/helpers.js'; |
|
|
|
} from './utils/helpers.js'; |
|
|
@ -72,6 +71,7 @@ export default class App extends Component { |
|
|
|
// status
|
|
|
|
// status
|
|
|
|
streamStatusMessage: MESSAGE_OFFLINE, |
|
|
|
streamStatusMessage: MESSAGE_OFFLINE, |
|
|
|
viewerCount: '', |
|
|
|
viewerCount: '', |
|
|
|
|
|
|
|
lastDisconnectTime: null, |
|
|
|
|
|
|
|
|
|
|
|
// dom
|
|
|
|
// dom
|
|
|
|
windowWidth: window.innerWidth, |
|
|
|
windowWidth: window.innerWidth, |
|
|
@ -208,9 +208,7 @@ export default class App extends Component { |
|
|
|
if (!status) { |
|
|
|
if (!status) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const { viewerCount, online, lastConnectTime, streamTitle } = status; |
|
|
|
const { viewerCount, online, lastConnectTime, streamTitle, lastDisconnectTime } = status; |
|
|
|
|
|
|
|
|
|
|
|
this.lastDisconnectTime = status.lastDisconnectTime; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status.online && !curStreamOnline) { |
|
|
|
if (status.online && !curStreamOnline) { |
|
|
|
// stream has just come online.
|
|
|
|
// stream has just come online.
|
|
|
@ -225,6 +223,7 @@ export default class App extends Component { |
|
|
|
lastConnectTime, |
|
|
|
lastConnectTime, |
|
|
|
streamOnline: online, |
|
|
|
streamOnline: online, |
|
|
|
streamTitle, |
|
|
|
streamTitle, |
|
|
|
|
|
|
|
lastDisconnectTime, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -260,7 +259,7 @@ export default class App extends Component { |
|
|
|
clearInterval(this.streamDurationTimer); |
|
|
|
clearInterval(this.streamDurationTimer); |
|
|
|
const remainingChatTime = |
|
|
|
const remainingChatTime = |
|
|
|
TIMER_DISABLE_CHAT_AFTER_OFFLINE - |
|
|
|
TIMER_DISABLE_CHAT_AFTER_OFFLINE - |
|
|
|
(Date.now() - new Date(this.lastDisconnectTime)); |
|
|
|
(Date.now() - new Date(this.state.lastDisconnectTime)); |
|
|
|
const countdown = remainingChatTime < 0 ? 0 : remainingChatTime; |
|
|
|
const countdown = remainingChatTime < 0 ? 0 : remainingChatTime; |
|
|
|
this.disableChatTimer = setTimeout(this.disableChatInput, countdown); |
|
|
|
this.disableChatTimer = setTimeout(this.disableChatInput, countdown); |
|
|
|
this.setState({ |
|
|
|
this.setState({ |
|
|
@ -501,6 +500,7 @@ export default class App extends Component { |
|
|
|
windowHeight, |
|
|
|
windowHeight, |
|
|
|
windowWidth, |
|
|
|
windowWidth, |
|
|
|
externalAction, |
|
|
|
externalAction, |
|
|
|
|
|
|
|
lastDisconnectTime, |
|
|
|
} = state; |
|
|
|
} = state; |
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
const { |
|
|
@ -520,10 +520,13 @@ export default class App extends Component { |
|
|
|
|
|
|
|
|
|
|
|
const tagList = tags !== null && tags.length > 0 && tags.join(' #'); |
|
|
|
const tagList = tags !== null && tags.length > 0 && tags.join(' #'); |
|
|
|
|
|
|
|
|
|
|
|
const viewerCountMessage = |
|
|
|
let viewerCountMessage = ''; |
|
|
|
streamOnline && viewerCount > 0 |
|
|
|
if (streamOnline && viewerCount > 0) { |
|
|
|
? html`${viewerCount} ${pluralize('viewer', viewerCount)}` |
|
|
|
viewerCountMessage = html`${viewerCount} ${pluralize('viewer', viewerCount)}`; |
|
|
|
: null; |
|
|
|
} else if (lastDisconnectTime) { |
|
|
|
|
|
|
|
viewerCountMessage = makeLastOnlineString(lastDisconnectTime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mainClass = playerActive ? 'online' : ''; |
|
|
|
const mainClass = playerActive ? 'online' : ''; |
|
|
|
const isPortrait = |
|
|
|
const isPortrait = |
|
|
@ -647,10 +650,10 @@ export default class App extends Component { |
|
|
|
<section |
|
|
|
<section |
|
|
|
id="stream-info" |
|
|
|
id="stream-info" |
|
|
|
aria-label="Stream status" |
|
|
|
aria-label="Stream status" |
|
|
|
class="flex text-center flex-row justify-between font-mono py-2 px-8 bg-gray-900 text-indigo-200 shadow-md border-b border-gray-100 border-solid" |
|
|
|
class="flex text-center flex-row justify-between font-mono py-2 px-4 bg-gray-900 text-indigo-200 shadow-md border-b border-gray-100 border-solid" |
|
|
|
> |
|
|
|
> |
|
|
|
<span>${streamStatusMessage}</span> |
|
|
|
<span class="text-xs">${streamStatusMessage}</span> |
|
|
|
<span id="stream-viewer-count">${viewerCountMessage}</span> |
|
|
|
<span id="stream-viewer-count" class="text-xs text-right">${viewerCountMessage}</span> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</main> |
|
|
|
</main> |
|
|
|
|
|
|
|
|
|
|
|