diff --git a/frontend/src/Call/CallPlayer.js b/frontend/src/Call/CallPlayer.js
index e3cfb77..6781c33 100644
--- a/frontend/src/Call/CallPlayer.js
+++ b/frontend/src/Call/CallPlayer.js
@@ -6,6 +6,7 @@ import CallInfo from "./components/CallInfo";
import ListCalls from "./components/ListCalls";
import { useSelector, useDispatch } from 'react-redux'
import { useGetTalkgroupsQuery } from '../features/api/apiSlice'
+import { playedCall } from "../features/calls/callsSlice";
import { useInView } from 'react-intersection-observer';
import {
Container,
@@ -72,6 +73,7 @@ function CallPlayer(props) {
const playCall = (data) => {
setCurrentCall(data.call);
+ dispatch(playedCall(data.call._id));
setIsPlaying(true);
}
@@ -83,6 +85,7 @@ function CallPlayer(props) {
const nextCall = callsData.entities[nextCallId];
setCurrentCall(nextCall);
+ dispatch(playedCall(nextCall._id));
setIsPlaying(true);
} else {
setIsPlaying(false);
@@ -93,7 +96,7 @@ function CallPlayer(props) {
}
useEffect(() => {
- if (loadNewerInView && callsData && (callsData.ids.length > 0)) {
+ if (!live && loadNewerInView && callsData && (callsData.ids.length > 0)) {
handleNewer();
}
}, [loadNewerInView]);
@@ -115,7 +118,9 @@ function CallPlayer(props) {
if (selectCallId && callsData && !isPlaying && autoPlay) {
const call = callsData.entities[selectCallId];
if (call) {
+ setIsPlaying(true);
setCurrentCall(call);
+ dispatch(playedCall(call._id));
}
}
}, [selectCallId, callsData])
diff --git a/frontend/src/Call/Calls.js b/frontend/src/Call/Calls.js
index e57b5c0..5ef334a 100644
--- a/frontend/src/Call/Calls.js
+++ b/frontend/src/Call/Calls.js
@@ -7,8 +7,8 @@ import CallPlayer from "./CallPlayer";
import { useSelector, useDispatch } from 'react-redux'
import { setLive, setFilter, setDateFilter } from "../features/callPlayer/callPlayerSlice";
import { getCalls, addCall, getOlderCalls, getNewerCalls } from "../features/calls/callsSlice";
-import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice'
-
+import { useGetGroupsQuery, useGetSystemsQuery, } from '../features/api/apiSlice'
+import { selectSystem } from "../features/systems/systemsSlice";
import {
Container,
Label,
@@ -30,9 +30,10 @@ const socket = io(process.env.REACT_APP_BACKEND_SERVER);
function Calls(props) {
const { shortName } = useParams();
-
+ const { data: allSystems, isSuccess } = useGetSystemsQuery();
const { data: groupsData, isSuccess: isGroupsSuccess } = useGetGroupsQuery(shortName);
const { loading: callsLoading, data: callsData } = useSelector((state) => state.calls);
+
const [autoPlay, setAutoPlay] = useState(true);
const [currentCall, setCurrentCall] = useState(false);
const [urlOptions, setUrlOptions] = useState(false);
@@ -61,12 +62,15 @@ function Calls(props) {
const pathname = useLocation().pathname;
let currentCallId = false;
-
+ let system = false;
if (currentCall) {
currentCallId = currentCall._id;
}
+ if (allSystems) {
+ system = allSystems.systems.find( (system) => system.shortName === shortName)
+ }
const handlePusherClick = () => {
if (sidebarOpened) setSidebarOpened(false);
@@ -210,8 +214,10 @@ useLayoutEffect(() => {
if (pageYOffset.current) {
const scrollAmount = parseInt(positionRef.current.clientHeight) - parseInt(pageYOffset.current.position);
if (pageYOffset.current.direction == "top") {
- window.scrollBy({left: 0, top: scrollAmount, behavior: "auto"});
+ window.scrollBy({left: 0, top: scrollAmount, behavior: "auto"});
+ pageYOffset.current = {direction: "bottom", position: positionRef.current.clientHeight}; // reset PageY to be the current height incase callsData changes for other reasons
} else {
+ pageYOffset.current = {direction: "bottom", position: positionRef.current.clientHeight};
//window.scrollBy(0, -1 * scrollAmount);
}
}
@@ -381,7 +387,7 @@ useLayoutEffect(() => {
- {/*system && system.name*/}
+ {system && system.name}
diff --git a/frontend/src/Call/components/CallItem.js b/frontend/src/Call/components/CallItem.js
index 93ef21a..8669eed 100644
--- a/frontend/src/Call/components/CallItem.js
+++ b/frontend/src/Call/components/CallItem.js
@@ -89,11 +89,21 @@ const CallItem = (props) => {
} else {
talkgroup = talkgroups.talkgroups[call.talkgroupNum].description;
}
+
+ let playStatus = (<>>)
+ if (activeCall) {
+ playStatus = ()
+
+ } else if (!call.played) {
+ playStatus = ()
+ }
+
return (
props.onClick({ call: call }, e)} {...rowSelected} onDragStart={onDragStart} data-callid={call._id}>
- {call.len}
- {talkgroup}
- {time.toLocaleTimeString()}
+ {playStatus}
+ {call.len}
+ {talkgroup}
+ {time.toLocaleTimeString()}
setStarVisible(true)} onMouseLeave={() => setStarVisible(false)} onClick={handleStarClicked}>{starButton}
);
diff --git a/frontend/src/Call/components/ListCalls.js b/frontend/src/Call/components/ListCalls.js
index b0e8bd0..20d5845 100644
--- a/frontend/src/Call/components/ListCalls.js
+++ b/frontend/src/Call/components/ListCalls.js
@@ -33,6 +33,7 @@ const ListCalls = (props) => {
+
Len
Talkgroup
Time
diff --git a/frontend/src/Call/components/MediaPlayer.js b/frontend/src/Call/components/MediaPlayer.js
index 46524c2..86df7fe 100644
--- a/frontend/src/Call/components/MediaPlayer.js
+++ b/frontend/src/Call/components/MediaPlayer.js
@@ -18,9 +18,20 @@ const MediaPlayer = (props) => {
const [isPlaying, setIsPlaying] = useState(false);
const parentHandlePlayPause = props.onPlayPause
- const handlePause = () => { setIsPlaying(false); parentHandlePlayPause(false); }
- const handlePlay = () => { setIsPlaying(true); parentHandlePlayPause(true); }
- const playPause = () => { const audio = audioRef.current.audioEl.current; if (isPlaying) { audio.pause(); } else { audio.play(); } }
+ const handlePause = () => { setIsPlaying(false); }
+ const handlePlay = () => { setIsPlaying(true); }
+ const playPause = () => {
+ const audio = audioRef.current.audioEl.current;
+ if (isPlaying) {
+ setIsPlaying(false);
+ parentHandlePlayPause(false);
+ audio.pause();
+ } else {
+ setIsPlaying(true);
+ parentHandlePlayPause(true);
+ audio.play();
+ }
+ }
const call = props.call;
diff --git a/frontend/src/Common/NavBar.js b/frontend/src/Common/NavBar.js
index 511f7f9..3c1a65c 100644
--- a/frontend/src/Common/NavBar.js
+++ b/frontend/src/Common/NavBar.js
@@ -16,7 +16,7 @@ import {
return (
diff --git a/frontend/src/System/ListSystems.js b/frontend/src/System/ListSystems.js
index 8b23176..3728e7b 100644
--- a/frontend/src/System/ListSystems.js
+++ b/frontend/src/System/ListSystems.js
@@ -52,33 +52,30 @@ const ListSystems = (props) => {
-
-
-
-
- {stateList}
-
-
- International
-
-
-
- {systemsByState}
- {international}
-
-
-
-
-
-
- {stateList}
-
-
-
-
-
+
+
+ {stateList}
+
+
+ International
+
+
+
+ {systemsByState}
+ {international}
+
+
+
+
+
+ {stateList}
+
+
+
+
+
);
diff --git a/frontend/src/features/calls/callsSlice.js b/frontend/src/features/calls/callsSlice.js
index 4ef81ea..8fa14c4 100644
--- a/frontend/src/features/calls/callsSlice.js
+++ b/frontend/src/features/calls/callsSlice.js
@@ -65,8 +65,7 @@ const initialState = {
loading: false,
data: callsAdapter.getInitialState(),
oldestCallTime: now,
- newestCallTime: now,
- adjustCallScroll: false
+ newestCallTime: now
}
function buildUrlParams(a) {
@@ -201,9 +200,12 @@ export const callsSlice = createSlice({
initialState,
reducers: {
addCall: (state, action) => {
- state.data = callsAdapter.addOne(state.data, action.payload)
- state.adjustCallScroll = true;
+ const call = {...action.payload, played: false}
+ state.data = callsAdapter.addOne(state.data, call)
},
+ playedCall: (state,action) => {
+ state.data = callsAdapter.updateOne(state.data,{id: action.payload, changes: {played: true}});
+ }
},
extraReducers: {
[getCalls.pending]: (state) => {
@@ -214,7 +216,8 @@ export const callsSlice = createSlice({
},
[getCalls.fulfilled]: (state, {payload}) => {
state.loading = false;
- state.data = callsAdapter.setAll(state.data, payload.calls)
+ const calls = payload.calls.map( (call) => ({...call, played: false}));
+ state.data = callsAdapter.setAll(state.data, calls)
if (state.data && (state.data.ids.length > 0)) {
const first = state.data.ids[0]
const firstTime = state.data.entities[first].time;
@@ -232,7 +235,8 @@ export const callsSlice = createSlice({
},
[getOlderCalls.fulfilled]: (state, {payload}) => {
state.loading = false;
- state.data = callsAdapter.addMany(state.data, payload.calls)
+ const calls = payload.calls.map( (call) => ({...call, played: false}));
+ state.data = callsAdapter.addMany(state.data, calls)
if (state.data && (state.data.ids.length > 0)) {
const first = state.data.ids[0]
const firstTime = state.data.entities[first].time;
@@ -250,7 +254,8 @@ export const callsSlice = createSlice({
},
[getNewerCalls.fulfilled]: (state, {payload}) => {
state.loading = false;
- state.data = callsAdapter.addMany(state.data, payload.calls)
+ const calls = payload.calls.map( (call) => ({...call, played: false}));
+ state.data = callsAdapter.addMany(state.data, calls)
if (state.data && (state.data.ids.length > 0)) {
const first = state.data.ids[0]
const firstTime = state.data.entities[first].time;
@@ -268,5 +273,5 @@ export const callsSlice = createSlice({
}
}
})
-export const { addCall } = callsSlice.actions
+export const { addCall, playedCall } = callsSlice.actions
export const callsReducer = callsSlice.reducer;
diff --git a/frontend/src/features/systems/systemsSlice.js b/frontend/src/features/systems/systemsSlice.js
index 60f571b..13943d1 100644
--- a/frontend/src/features/systems/systemsSlice.js
+++ b/frontend/src/features/systems/systemsSlice.js
@@ -23,4 +23,10 @@ export const selectActiveSystems = createSelector(
selectAllSystems,
(state) => null,
(systems) => systems.filter(system => system.active === true)
+)
+
+export const selectSystem = createSelector(
+ selectAllSystems,
+ (state) => null,
+ (systems, shortName) => systems.find(system => system.shortName === shortName)
)
\ No newline at end of file