Add an animation to the register/cancel button
Hopefully this will stop people mashing the button and DoS'ing shittyserver
This commit is contained in:
parent
2ae1cbae84
commit
5f373571af
5 changed files with 41 additions and 4 deletions
|
@ -95,6 +95,7 @@
|
|||
"strict-event-emitter-types": "^2.0.0",
|
||||
"style-loader": "1.0.0",
|
||||
"terser-webpack-plugin": "1.4.1",
|
||||
"three-dots": "^0.2.0",
|
||||
"ts-pnp": "1.1.4",
|
||||
"typescript": "3.7.2",
|
||||
"url-loader": "2.1.0",
|
||||
|
|
|
@ -110,6 +110,7 @@ export class WebRTCStreamer extends Streamer {
|
|||
const data = JSON.parse(evt.data);
|
||||
switch (data.kind) {
|
||||
case "HELLO":
|
||||
this.onStateChange("CONNECTING");
|
||||
console.log("WS HELLO, our client ID is " + data.connectionId);
|
||||
this.dispatch(BroadcastState.setWsID(data.connectionId));
|
||||
if (this.state !== "HELLO") {
|
||||
|
@ -258,6 +259,11 @@ export class WebRTCStreamer extends Streamer {
|
|||
return "NOT_CONNECTED";
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
"Relevant values: ",
|
||||
this.pc?.iceConnectionState,
|
||||
this.ws?.readyState
|
||||
);
|
||||
switch (this.pc.iceConnectionState) {
|
||||
case "connected":
|
||||
case "completed":
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useRef, useEffect } from "react";
|
||||
import React, { useRef, useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import Clock from "react-live-clock";
|
||||
|
||||
|
@ -40,6 +40,17 @@ export function NavBar() {
|
|||
const broadcastState = useSelector((state: RootState) => state.broadcast);
|
||||
const settings = useSelector((state: RootState) => state.settings);
|
||||
const redirect_url = encodeURIComponent(window.location.toString());
|
||||
|
||||
const [connectButtonAnimating, setConnectButtonAnimating] = useState(false);
|
||||
|
||||
const prevRegistrationStage = useRef(broadcastState.stage);
|
||||
useEffect(() => {
|
||||
if (broadcastState.stage !== prevRegistrationStage.current) {
|
||||
setConnectButtonAnimating(false);
|
||||
}
|
||||
prevRegistrationStage.current = broadcastState.stage;
|
||||
}, [broadcastState.stage]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="navbar-nav navbar-left">
|
||||
|
@ -77,8 +88,9 @@ export function NavBar() {
|
|||
</div>
|
||||
</li>
|
||||
<li
|
||||
className="btn btn-outline-light rounded-0 pt-2 pb-1 nav-item nav-link"
|
||||
className="btn btn-outline-light rounded-0 pt-2 pb-1 nav-item nav-link connect"
|
||||
onClick={() => {
|
||||
setConnectButtonAnimating(true);
|
||||
switch (broadcastState.stage) {
|
||||
case "NOT_REGISTERED":
|
||||
dispatch(BroadcastState.goOnAir());
|
||||
|
@ -89,8 +101,14 @@ export function NavBar() {
|
|||
}
|
||||
}}
|
||||
>
|
||||
{connectButtonAnimating ? (
|
||||
<span className="dot-pulse" />
|
||||
) : (
|
||||
<>
|
||||
{broadcastState.stage === "NOT_REGISTERED" && "Register for show"}
|
||||
{broadcastState.stage === "REGISTERED" && "Cancel registration"}
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
{settings.enableRecording && (
|
||||
<li className="nav-item nav-link">
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* Stuff to get the nav to collapse at 991px (when the menu collapses)
|
||||
* Taken from http://stackoverflow.com/a/36289507/995325 */
|
||||
|
||||
$dot-color: #fff;
|
||||
@import "~three-dots/sass/three-dots";
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.navbar-header {
|
||||
float: none;
|
||||
|
@ -251,3 +254,7 @@
|
|||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.nav-link.connect {
|
||||
min-width: 80px;
|
||||
}
|
||||
|
|
|
@ -10427,6 +10427,11 @@ text-table@0.2.0, text-table@^0.2.0:
|
|||
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
|
||||
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
|
||||
|
||||
three-dots@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/three-dots/-/three-dots-0.2.0.tgz#a854461cfdcaae829587a72d7693b0a774da05cb"
|
||||
integrity sha512-UIbDvl8F1qjoBigeEjcl2h101Frx+CaWCJSr7xabRh6BjFUkkJU1GW2jzmt0IQP7yVAOKW9q5bMj7Tafz0pP1g==
|
||||
|
||||
throat@^4.0.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
|
||||
|
|
Loading…
Reference in a new issue