Update - selects for playing

This commit is contained in:
Luke Berndt
2021-02-20 13:05:18 -05:00
parent fe90263b2c
commit a89f6c1b15

View File

@@ -63,6 +63,7 @@ class CallPlayer extends React.Component {
playTime: 0, playTime: 0,
sourceIndex: 0, sourceIndex: 0,
callScroll: false, callScroll: false,
callSelect: false,
urlOptions: false, urlOptions: false,
isPlaying: false, isPlaying: false,
sidebarOpened: false, sidebarOpened: false,
@@ -171,7 +172,7 @@ class CallPlayer extends React.Component {
} }
} }
updateUri(props) { updateUri(props, state) {
var search = "?" var search = "?"
switch (props.filterType) { switch (props.filterType) {
@@ -186,6 +187,9 @@ class CallPlayer extends React.Component {
break; break;
} }
if (state.callId) {
search = search + `call-id=${state.callId}`
}
if (props.filterDate) { if (props.filterDate) {
if (search.length !== 1) { if (search.length !== 1) {
search = search + '&'; search = search + '&';
@@ -341,7 +345,8 @@ class CallPlayer extends React.Component {
sourceIndex: 0, sourceIndex: 0,
urlOptions: true, urlOptions: true,
autoPlay: false, autoPlay: false,
callScroll: true callScroll: true,
callSelect: true
}); });
this.props.callActions.fetchCallInfo(_id); this.props.callActions.fetchCallInfo(_id);
this.props.callActions.setCallTime(date); this.props.callActions.setCallTime(date);
@@ -398,7 +403,7 @@ class CallPlayer extends React.Component {
return true return true
} }
componentWillUpdate(nextProps) { componentWillUpdate(nextProps, nextState) {
if (!this.props.groups && nextProps.groups) { if (!this.props.groups && nextProps.groups) {
if (!this.state.urlOptions && (nextProps.groups.length > 0)) { if (!this.state.urlOptions && (nextProps.groups.length > 0)) {
this.setState({ this.setState({
@@ -428,7 +433,7 @@ class CallPlayer extends React.Component {
break; break;
} }
this.updateUri(nextProps); this.updateUri(nextProps, nextState);
if (this.props.live) { if (this.props.live) {
this.startSocket(this.props.shortName, typeString, filterCode, nextProps.filterStarred); this.startSocket(this.props.shortName, typeString, filterCode, nextProps.filterStarred);
} }
@@ -441,6 +446,10 @@ class CallPlayer extends React.Component {
this.prevHeight = contextRef.clientHeight; this.prevHeight = contextRef.clientHeight;
this.autoScroll = true; this.autoScroll = true;
} }
/* // if you do this, you also need to update time in the URI to be the call time...
if (this.state.callId != nextState.callId) {
this.updateUri(nextProps, nextState);
}*/
if (this.state.callId && !this.state.callUrl) { if (this.state.callId && !this.state.callUrl) {
const call = this.props.callsById[this.state.callId]; const call = this.props.callsById[this.state.callId];
@@ -460,6 +469,8 @@ class CallPlayer extends React.Component {
// scroll to a call once the calls have loaded // scroll to a call once the calls have loaded
if (this.state.callScroll && (this.props.callsAllIds.length > prevProps.callsAllIds.length)) { if (this.state.callScroll && (this.props.callsAllIds.length > prevProps.callsAllIds.length)) {
const call = this.props.callsById[this.state.callId];
if (call) {
this.setState({ callScroll: false }); this.setState({ callScroll: false });
if (this.currentCallRef.current) { if (this.currentCallRef.current) {
this.currentCallRef.current.scrollIntoView({ this.currentCallRef.current.scrollIntoView({
@@ -472,6 +483,21 @@ class CallPlayer extends React.Component {
} }
} }
if (this.state.callSelect) {
const call = this.props.callsById[this.state.callId];
if (call) {
const audio = this.audioRef.current;
var callUrl = call.url;
this.setState({
callUrl: callUrl,
sourceIndex: 0,
isPlaying: true,
callSelect: false
}, () => { audio.playSource(callUrl); }); //scrollToComponent(this.currentCallRef.current);
}
}
}
//https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux //https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter //https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
render() { render() {