mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-15 02:07:50 -05:00
websockets working!
This commit is contained in:
@@ -12,8 +12,6 @@ import {
|
|||||||
|
|
||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
function CallInfo(props) {
|
function CallInfo(props) {
|
||||||
|
|
||||||
|
|
||||||
let srcList = "";
|
let srcList = "";
|
||||||
let callLength = "-";
|
let callLength = "-";
|
||||||
let callFreq = "-";
|
let callFreq = "-";
|
||||||
@@ -39,8 +37,6 @@ function CallInfo(props) {
|
|||||||
callTweet = "https://twitter.com/intent/tweet?url="+encodeURIComponent(document.location.origin+props.link)+"&via="+encodeURIComponent("OpenMHz");
|
callTweet = "https://twitter.com/intent/tweet?url="+encodeURIComponent(document.location.origin+props.link)+"&via="+encodeURIComponent("OpenMHz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Segment padded attached>
|
<Segment padded attached>
|
||||||
@@ -86,7 +82,6 @@ function CallInfo(props) {
|
|||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CallInfo;
|
export default CallInfo;
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ function CallPlayer(props) {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const positionRef = useRef();
|
const positionRef = useRef();
|
||||||
|
const isPlayingRef = useRef(); // we need to do this to make the current value of isPlaying available in the socket message callback
|
||||||
|
isPlayingRef.current = isPlaying;
|
||||||
|
|
||||||
const filterType = useSelector((state) => state.callPlayer.filterType);
|
const filterType = useSelector((state) => state.callPlayer.filterType);
|
||||||
const filterGroupId = useSelector((state) => state.callPlayer.filterGroupId);
|
const filterGroupId = useSelector((state) => state.callPlayer.filterGroupId);
|
||||||
@@ -91,7 +93,9 @@ function CallPlayer(props) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handlePlayPause = (playing) => setIsPlaying(playing);
|
const handlePlayPause = (playing) => {
|
||||||
|
setIsPlaying(playing);
|
||||||
|
}
|
||||||
|
|
||||||
const handlePusherClick = () => {
|
const handlePusherClick = () => {
|
||||||
if (sidebarOpened) setSidebarOpened(false);
|
if (sidebarOpened) setSidebarOpened(false);
|
||||||
@@ -155,19 +159,12 @@ function CallPlayer(props) {
|
|||||||
const ref = positionRef;
|
const ref = positionRef;
|
||||||
setPrevScrollHeight(positionRef.clientHeight);
|
setPrevScrollHeight(positionRef.clientHeight);
|
||||||
setAddCallScroll(true);
|
setAddCallScroll(true);
|
||||||
dispatch(addCall(message))
|
|
||||||
/*const refs = this.refs.current;
|
if (!isPlayingRef.current) {
|
||||||
callActions.addCall(message);
|
setCurrentCall(message);
|
||||||
const newCall = callsById[callsAllIds[0]];
|
}
|
||||||
if (!isPlaying && autoPlay) {
|
|
||||||
this.playCall({ call: newCall });
|
dispatch(addCall(message));
|
||||||
if (this.currentCallRef.current) {
|
|
||||||
this.currentCallRef.current.scrollIntoView({
|
|
||||||
behavior: "smooth",
|
|
||||||
block: "center",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
console.log("Got: " + message);
|
console.log("Got: " + message);
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@@ -177,31 +174,18 @@ function CallPlayer(props) {
|
|||||||
|
|
||||||
const startSocket = () => {
|
const startSocket = () => {
|
||||||
const filter = getFilterDescription();
|
const filter = getFilterDescription();
|
||||||
|
|
||||||
socket.emit("start", {
|
socket.emit("start", {
|
||||||
filterCode: filter.Code,
|
filterCode: filter.code,
|
||||||
filterType: filter.Type,
|
filterType: filter.type,
|
||||||
filterName: "OpenMHz",
|
filterName: "OpenMHz",
|
||||||
filterStarred: filter.Starred,
|
filterStarred: filter.starred,
|
||||||
shortName: shortName
|
shortName: shortName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const stopSocket = () => {
|
const stopSocket = () => {
|
||||||
socket.emit("stop");
|
socket.emit("stop");
|
||||||
}
|
}
|
||||||
const handleLiveToggle = () => {
|
|
||||||
if (!live) {
|
|
||||||
dispatch(setDateFilter(false));
|
|
||||||
dispatch(setLive(true));
|
|
||||||
setCurrentCall(false);
|
|
||||||
|
|
||||||
dispatch(getCalls({}));
|
|
||||||
|
|
||||||
this.startSocket();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updateUri = () => {
|
const updateUri = () => {
|
||||||
var search = "?"
|
var search = "?"
|
||||||
@@ -241,6 +225,16 @@ function CallPlayer(props) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleLiveToggle = () => {
|
||||||
|
if (!live) {
|
||||||
|
dispatch(setDateFilter(false));
|
||||||
|
dispatch(setLive(true));
|
||||||
|
setCurrentCall(false);
|
||||||
|
dispatch(getCalls({}));
|
||||||
|
|
||||||
|
this.startSocket();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleCalendarClose = (didUpdate) => {
|
const handleCalendarClose = (didUpdate) => {
|
||||||
setCalendarVisible(!calendarVisible);
|
setCalendarVisible(!calendarVisible);
|
||||||
@@ -386,7 +380,7 @@ function CallPlayer(props) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on("new message", handleSocketMessage);
|
socket.on("new message", handleSocketMessage );
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off('connect');
|
socket.off('connect');
|
||||||
@@ -416,6 +410,7 @@ function CallPlayer(props) {
|
|||||||
}, [groupsData])
|
}, [groupsData])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var archiveLabel = "";
|
var archiveLabel = "";
|
||||||
if (filterDate) {
|
if (filterDate) {
|
||||||
const filterDateObj = new Date(filterDate);
|
const filterDateObj = new Date(filterDate);
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ export const callsSlice = createSlice({
|
|||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
|
|
||||||
addCall: (call) => {
|
addCall: (state, action) => {
|
||||||
state.data = callsAdapter.addOne(state.data, call)
|
state.data = callsAdapter.addOne(state.data, action.payload)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extraReducers: {
|
extraReducers: {
|
||||||
@@ -269,5 +269,5 @@ export const callsSlice = createSlice({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
export const { addCall } = callsSlice.actions
|
||||||
export const callsReducer = callsSlice.reducer;
|
export const callsReducer = callsSlice.reducer;
|
||||||
|
|||||||
Reference in New Issue
Block a user