From 4ceb65cc025efd761a675b283a586cd9436009e3 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 18 Jul 2023 20:48:09 -0400 Subject: [PATCH] fixed some errors --- backend/controllers/calls.js | 12 +++--------- frontend/src/Call/Calls.js | 2 ++ frontend/src/features/callPlayer/callPlayerSlice.js | 5 +++++ frontend/src/features/calls/callsSlice.js | 12 +++++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/backend/controllers/calls.js b/backend/controllers/calls.js index e6177f1..e8559b7 100644 --- a/backend/controllers/calls.js +++ b/backend/controllers/calls.js @@ -24,7 +24,6 @@ const build_call_list = (items) => { }; calls.push(call); } - console.log("Finished Items is: " + items.length + " long and Calls is: " + calls.length) return calls; } @@ -46,25 +45,19 @@ async function get_calls(query, numResults, middleDate, res) { const sort = { length: -1 }; try { - console.log(query.filter); const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults); const refined_items = build_call_list(items); - //calls.concat(refined_items); calls.push(...refined_items); - console.log(calls); // if we are loading a list of calls around a specific Call ID, we want to load call before and after that call, so we call it twice. if (middleDate) { query.filter.time = { $gt: middleDate }; - console.log("doing a second query"); - console.log(query.filter); + const items = await Call.find(query.filter, fields).sort(query.sort_order).limit(numResults); const refined_items = build_call_list(items); calls.push(...refined_items); - console.log(calls); - //calls.concat(refined_items); } res.json({ calls: calls, @@ -80,9 +73,10 @@ async function get_calls(query, numResults, middleDate, res) { async function build_filter(filter_type, code, start_time, direction, shortName, numResults, starred, res) { var filter = {}; var query = {}; + var start = new Date(start_time); if (start_time) { - var start = new Date(start_time); + if (direction == 'newer') { filter.time = { $gt: start diff --git a/frontend/src/Call/Calls.js b/frontend/src/Call/Calls.js index e641b54..fb03323 100644 --- a/frontend/src/Call/Calls.js +++ b/frontend/src/Call/Calls.js @@ -265,6 +265,7 @@ function Calls(props) { filterTalkgroups: [], filterGroupId: false, filterStarred: false, + filterCallId: false, shortName: shortName }; @@ -288,6 +289,7 @@ function Calls(props) { if (uri.hasOwnProperty('call-id')) { const _id = uri['call-id']; setInitialCallId(_id); + filter.filterCallId = false; setAutoPlay(false); setLive(false); if (!urlOptions) setUrlOptions(true); diff --git a/frontend/src/features/callPlayer/callPlayerSlice.js b/frontend/src/features/callPlayer/callPlayerSlice.js index 245a38f..3f1d17c 100644 --- a/frontend/src/features/callPlayer/callPlayerSlice.js +++ b/frontend/src/features/callPlayer/callPlayerSlice.js @@ -12,6 +12,7 @@ const initialState = { filterGroupId: false, filterDate: false, filterStarred: false, + filterCallId: false, currentCallId: false, playlist: [], live: false, @@ -36,6 +37,9 @@ export const callPlayerSlice = createSlice({ setCurrentCallId: (state, action) => { state.currentCallId = action.payload; }, + setFilterCallId: (state, action) => { + state.filterCallId = action.payload; + }, setCallTime: (state, action) => { state.newestCallTime = action.payload; state.oldestCallTime = action.payload; @@ -70,6 +74,7 @@ export const callPlayerSlice = createSlice({ state.filterTalkgroups = !action.payload.filterTalkgroups ? [] : action.payload.filterTalkgroups; state.filterGroupId = !action.payload.filterGroupId ? false : action.payload.filterGroupId; state.filterDate = !action.payload.filterDate ? 0 : action.payload.filterDate; + state.filterCallId = !action.payload.filterCallId ? false : action.payload.filterCallId; state.shortName = !action.payload.shortName ? state.shortName : action.payload.shortName; }, setLive: (state,action) => { diff --git a/frontend/src/features/calls/callsSlice.js b/frontend/src/features/calls/callsSlice.js index a77db02..e1563ba 100644 --- a/frontend/src/features/calls/callsSlice.js +++ b/frontend/src/features/calls/callsSlice.js @@ -78,17 +78,19 @@ const initialState = { var params = {}; var url = ""; - const {shortName,filterType,filterGroupId, filterTalkgroups, filterStarred, filterDate} = getState().callPlayer; + const {shortName,filterType,filterGroupId, filterTalkgroups, filterStarred, filterDate, filterCallId} = getState().callPlayer; if ((typeof direction === 'string') && (typeof date === 'number')) { url = url + '/' + direction; params["time"] = date; - } else { - if (filterDate){ - url = url + '/date' + } else if (filterCallId) { + url = url + '/date' + params["time"] = filterDate; + } else if (filterDate){ + url = url + '/' params["time"] = filterDate; } - } + if (filterStarred) { params["filter-starred"] = true; }