mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 09:17:30 -05:00
infiinite scroll is here!
This commit is contained in:
@@ -2,6 +2,7 @@ MEDIA=/Users/luke/Testing/media
|
|||||||
DATA=/Users/luke/Testing/data
|
DATA=/Users/luke/Testing/data
|
||||||
MAILJET_KEY="4d2a0f6deb20a7890afee2daf595c22d"
|
MAILJET_KEY="4d2a0f6deb20a7890afee2daf595c22d"
|
||||||
MAILJET_SECRET="fb74f682d68bf6b05ab626c0ac93a6da"
|
MAILJET_SECRET="fb74f682d68bf6b05ab626c0ac93a6da"
|
||||||
|
GOOGLE_ANALYTICS="UA-45563211-1"
|
||||||
STAGE=test
|
STAGE=test
|
||||||
TAG=1.7
|
TAG=1.7
|
||||||
DOMAIN_NAME="openmhz.test"
|
DOMAIN_NAME="openmhz.test"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"react-datepicker": "4.8.0",
|
"react-datepicker": "4.8.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-ga": "^3.3.1",
|
"react-ga": "^3.3.1",
|
||||||
|
"react-intersection-observer": "^9.4.1",
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"react-router-dom": "6.6.1",
|
"react-router-dom": "6.6.1",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import CalendarModal from "./CalendarModalContainer";
|
|||||||
import CallInfo from "./CallInfo";
|
import CallInfo from "./CallInfo";
|
||||||
import ListCalls from "./ListCalls";
|
import ListCalls from "./ListCalls";
|
||||||
import { useSelector, useDispatch } from 'react-redux'
|
import { useSelector, useDispatch } from 'react-redux'
|
||||||
import { setLive, setShortName } from "../features/callPlayer/callPlayerSlice";
|
import { setLive, setShortName, setFilter } from "../features/callPlayer/callPlayerSlice";
|
||||||
import { getCalls, getOlderCalls} from "../features/calls/callsSlice";
|
import { getCalls, getOlderCalls, getNewerCalls} from "../features/calls/callsSlice";
|
||||||
import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice'
|
import { useGetGroupsQuery, useGetTalkgroupsQuery } from '../features/api/apiSlice'
|
||||||
import { selectAllCalls, useGetCallsQuery, callsAdapter } from "../features/calls/callsSlice";
|
import { useInView } from 'react-intersection-observer';
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
Label,
|
Label,
|
||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
Icon,
|
Icon,
|
||||||
Sidebar,
|
Sidebar,
|
||||||
Visibility,
|
|
||||||
Button
|
Button
|
||||||
} from "semantic-ui-react";
|
} from "semantic-ui-react";
|
||||||
import "./CallPlayer.css";
|
import "./CallPlayer.css";
|
||||||
@@ -37,14 +36,21 @@ import queryString from '../query-string';
|
|||||||
function CallPlayer (props) {
|
function CallPlayer (props) {
|
||||||
|
|
||||||
const { shortName } = useParams();
|
const { shortName } = useParams();
|
||||||
|
const { ref: loadOlderRef, inView: loadOlderInView, entry: loadOlderEntry } = useInView({
|
||||||
|
/* Optional options */
|
||||||
|
threshold: 0.5
|
||||||
|
});
|
||||||
|
const { ref: loadNewerRef, inView: loadNewerInView, entry: loadNewerEntry } = useInView({
|
||||||
|
/* Optional options */
|
||||||
|
threshold: 0.5
|
||||||
|
});
|
||||||
const { data:groupsData, isSuccess:isGroupsSuccess } = useGetGroupsQuery(shortName);
|
const { data:groupsData, isSuccess:isGroupsSuccess } = useGetGroupsQuery(shortName);
|
||||||
//const { data:callsData, isSuccess:isCallsSuccess } = useGetCallsQuery({shortName});
|
//const { data:callsData, isSuccess:isCallsSuccess } = useGetCallsQuery({shortName});
|
||||||
const {loading, data: callsData} = useSelector((state) => state.calls);
|
const {loading: callsLoading, data: callsData} = useSelector((state) => state.calls);
|
||||||
|
|
||||||
//console.log(callsData);
|
//console.log(callsData);
|
||||||
const { data:talkgroupsData, isSuccess:isTalkgroupsSuccess } = useGetTalkgroupsQuery(shortName);
|
const { data:talkgroupsData, isSuccess:isTalkgroupsSuccess } = useGetTalkgroupsQuery(shortName);
|
||||||
//const allCalls = callsData?callsData.ids.map( id => callsData.entities[id] ):[]
|
//const allCalls = callsData?callsData.ids.map( id => callsData.entities[id] ):[]
|
||||||
const [requestMessage, setRequestMessage] = useState("");
|
|
||||||
const [callUrl, setCallUrl] = useState("");
|
const [callUrl, setCallUrl] = useState("");
|
||||||
const [autoPlay, setAutoPlay] = useState(true);
|
const [autoPlay, setAutoPlay] = useState(true);
|
||||||
const [callId, setCallId] = useState(false);
|
const [callId, setCallId] = useState(false);
|
||||||
@@ -67,7 +73,6 @@ function CallPlayer (props) {
|
|||||||
const filterStarred = useSelector((state) => state.callPlayer.filterStarred);
|
const filterStarred = useSelector((state) => state.callPlayer.filterStarred);
|
||||||
const filterDate = useSelector((state) => state.callPlayer.filterDate);
|
const filterDate = useSelector((state) => state.callPlayer.filterDate);
|
||||||
const live = useSelector((state) => state.callPlayer.live);
|
const live = useSelector((state) => state.callPlayer.live);
|
||||||
|
|
||||||
const uri = queryString.parse(useLocation().search);
|
const uri = queryString.parse(useLocation().search);
|
||||||
|
|
||||||
const switchAutoPlay = () => setAutoPlay(!autoPlay);
|
const switchAutoPlay = () => setAutoPlay(!autoPlay);
|
||||||
@@ -107,10 +112,11 @@ function CallPlayer (props) {
|
|||||||
callActions.fetchNewerCalls(newestCallTime.getTime());
|
callActions.fetchNewerCalls(newestCallTime.getTime());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const loadOlderCalls = (getOlderCalls) => {
|
const loadOlderCalls = (getOlderCalls) => {
|
||||||
|
|
||||||
console.log("Loading Older Calls");
|
console.log("Loading Older Calls");
|
||||||
dispatch(getOlderCalls());
|
dispatch(getOlderCalls({}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +238,6 @@ const getFilter = () => {
|
|||||||
|
|
||||||
const handleGroupClose = (didUpdate) => {
|
const handleGroupClose = (didUpdate) => {
|
||||||
setGroupVisible(!groupVisible);
|
setGroupVisible(!groupVisible);
|
||||||
//callActions.fetchCalls();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleFilterClose = (didUpdate) => {
|
const handleFilterClose = (didUpdate) => {
|
||||||
@@ -241,7 +246,6 @@ const getFilter = () => {
|
|||||||
if (didUpdate) {
|
if (didUpdate) {
|
||||||
setCallUrl("");
|
setCallUrl("");
|
||||||
setCallId(false);
|
setCallId(false);
|
||||||
//callActions.fetchCalls();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -299,7 +303,7 @@ const getFilter = () => {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
const setStateFromUri = () => {
|
const setStateFromUri = async () => {
|
||||||
var filter = {
|
var filter = {
|
||||||
filterDate: false,
|
filterDate: false,
|
||||||
filterType: 0, // this is "all"
|
filterType: 0, // this is "all"
|
||||||
@@ -367,9 +371,23 @@ const getFilter = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//callActions.setFilter(filter);
|
await dispatch(setFilter(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (loadNewerInView && callsData && (callsData.ids.length > 0)) {
|
||||||
|
dispatch(getNewerCalls({}));
|
||||||
|
}
|
||||||
|
}, [loadNewerInView]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (loadOlderInView && callsData && (callsData.ids.length > 0)) {
|
||||||
|
dispatch(getOlderCalls({}));
|
||||||
|
}
|
||||||
|
}, [loadOlderInView]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// When a time/date is provided in the URL, it will be added to the filter
|
// When a time/date is provided in the URL, it will be added to the filter
|
||||||
// When fetchCalls is called it will selected calls that are older
|
// When fetchCalls is called it will selected calls that are older
|
||||||
@@ -382,6 +400,7 @@ const getFilter = () => {
|
|||||||
if (filter.live) {
|
if (filter.live) {
|
||||||
this.startSocket(shortName, filterType, filterCode, filter.filterStarred);
|
this.startSocket(shortName, filterType, filterCode, filter.filterStarred);
|
||||||
}*/
|
}*/
|
||||||
|
setStateFromUri();
|
||||||
console.log("Setting short name to: " + shortName)
|
console.log("Setting short name to: " + shortName)
|
||||||
dispatch(setShortName(shortName));
|
dispatch(setShortName(shortName));
|
||||||
|
|
||||||
@@ -391,7 +410,8 @@ const getFilter = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getCalls({shortName}));
|
dispatch(getCalls({}));
|
||||||
|
//dispatch(getOlderCalls());
|
||||||
}, [shortName,filterGroupId,filterTalkgroups,filterType,filterStarred])
|
}, [shortName,filterGroupId,filterTalkgroups,filterType,filterStarred])
|
||||||
|
|
||||||
|
|
||||||
@@ -598,13 +618,11 @@ const getFilter = () => {
|
|||||||
onClick={handlePusherClick}
|
onClick={handlePusherClick}
|
||||||
style={{ minHeight: '100vh' }}
|
style={{ minHeight: '100vh' }}
|
||||||
>
|
>
|
||||||
<Visibility onTopVisible={loadNewerCalls} onBottomVisible={loadOlderCalls} once={false}>
|
<div ref={loadNewerRef} />
|
||||||
<ListCalls callsData={callsData} currentCallRef={false} activeCallId={callId} talkgroups={talkgroupsData} playCall={playCall} />
|
<ListCalls callsData={callsData} currentCallRef={false} activeCallId={callId} talkgroups={talkgroupsData} playCall={playCall} />
|
||||||
<Button onClick={()=> dispatch(getOlderCalls())}>Load More!</Button>
|
<div ref={loadOlderRef} style={{height: 50}}/>
|
||||||
<div>
|
|
||||||
<Button>padding</Button>
|
|
||||||
</div>
|
|
||||||
</Visibility>
|
|
||||||
</Sidebar.Pusher>
|
</Sidebar.Pusher>
|
||||||
</Sidebar.Pushable>
|
</Sidebar.Pushable>
|
||||||
<Rail position='right' className="desktop-only" dimmed={sidebarOpened ? "true" : "false"} >
|
<Rail position='right' className="desktop-only" dimmed={sidebarOpened ? "true" : "false"} >
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ const now = new Date();
|
|||||||
|
|
||||||
export const callsAdapter = createEntityAdapter({
|
export const callsAdapter = createEntityAdapter({
|
||||||
selectId: (call) => call._id,
|
selectId: (call) => call._id,
|
||||||
sortComparer: (a, b) => a.time.localeCompare(b.time),
|
sortComparer: (a, b) => b.time.localeCompare(a.time),
|
||||||
})
|
})
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@@ -129,7 +129,7 @@ export const getCalls = createAsyncThunk(
|
|||||||
'calls/getCalls',
|
'calls/getCalls',
|
||||||
async({},{getState, requestId}) => {
|
async({},{getState, requestId}) => {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const {loading,oldestCallTime, newestCallTime} = getState().call;
|
const {loading,oldestCallTime, newestCallTime} = getState().calls;
|
||||||
const url = buildCallUrl(getState);
|
const url = buildCallUrl(getState);
|
||||||
const res = await fetch(url).then(
|
const res = await fetch(url).then(
|
||||||
(data) => data.json()
|
(data) => data.json()
|
||||||
@@ -140,7 +140,7 @@ export const getCalls = createAsyncThunk(
|
|||||||
export const getOlderCalls = createAsyncThunk(
|
export const getOlderCalls = createAsyncThunk(
|
||||||
'calls/getOlderCalls',
|
'calls/getOlderCalls',
|
||||||
async({},{getState, requestId} ) => {
|
async({},{getState, requestId} ) => {
|
||||||
const {loading,oldestCallTime, newestCallTime} = getState().call;
|
const {loading,oldestCallTime, newestCallTime} = getState().calls;
|
||||||
const url = buildCallUrl(getState,"older",oldestCallTime.getTime());
|
const url = buildCallUrl(getState,"older",oldestCallTime.getTime());
|
||||||
const res = await fetch(url).then(
|
const res = await fetch(url).then(
|
||||||
(data) => data.json()
|
(data) => data.json()
|
||||||
@@ -151,7 +151,7 @@ export const getCalls = createAsyncThunk(
|
|||||||
export const getNewerCalls = createAsyncThunk(
|
export const getNewerCalls = createAsyncThunk(
|
||||||
'calls/getNewerCalls',
|
'calls/getNewerCalls',
|
||||||
async({},{getState, requestId} ) => {
|
async({},{getState, requestId} ) => {
|
||||||
const {loading,oldestCallTime, newestCallTime} = getState().call;
|
const {loading,oldestCallTime, newestCallTime} = getState().calls;
|
||||||
const url = buildCallUrl(getState,"newer",newestCallTime.getTime());
|
const url = buildCallUrl(getState,"newer",newestCallTime.getTime());
|
||||||
const res = await fetch(url).then(
|
const res = await fetch(url).then(
|
||||||
(data) => data.json()
|
(data) => data.json()
|
||||||
|
|||||||
@@ -8431,6 +8431,11 @@ react-ga@^3.3.1:
|
|||||||
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
|
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
|
||||||
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==
|
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==
|
||||||
|
|
||||||
|
react-intersection-observer@^9.4.1:
|
||||||
|
version "9.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-intersection-observer/-/react-intersection-observer-9.4.1.tgz#4ccb21e16acd0b9cf5b28d275af7055bef878f6b"
|
||||||
|
integrity sha512-IXpIsPe6BleFOEHKzKh5UjwRUaz/JYS0lT/HPsupWEQou2hDqjhLMStc5zyE3eQVT4Fk3FufM8Fw33qW1uyeiw==
|
||||||
|
|
||||||
react-is@^16.13.1, react-is@^16.6.3, react-is@^16.7.0:
|
react-is@^16.13.1, react-is@^16.6.3, react-is@^16.7.0:
|
||||||
version "16.13.1"
|
version "16.13.1"
|
||||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||||
|
|||||||
Reference in New Issue
Block a user