Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only query single route if segmentRange specified #544

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"node": ">=16"
},
"dependencies": {
"@commaai/api": "github:commaai/comma-api#3.1.2",
"@commaai/api": "github:commaai/comma-api#3.1.3",
"@commaai/my-comma-auth": "^1.4.1",
"@mapbox/mapbox-sdk": "^0.15.3",
"@material-ui/core": "^1.5.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ export function checkRoutesData() {
const { dongleId } = state;
const fetchRange = state.filter;

routesRequest = {
req: Drives.getRoutesSegments(dongleId, fetchRange.start, fetchRange.end, state.limit),
dongleId,
};
if (state.segmentRange) {
routesRequest = {
req: Drives.getRoutesSegments(dongleId, undefined, undefined, undefined, `${dongleId}|${state.segmentRange.log_id}`),
dongleId,
};
} else {
routesRequest = {
req: Drives.getRoutesSegments(dongleId, fetchRange.start, fetchRange.end, state.limit),
dongleId,
};
}

routesRequestPromise = routesRequest.req.then((routesData) => {
state = getState();
Expand Down Expand Up @@ -148,8 +155,6 @@ export function urlForState(dongleId, log_id, start, end, prime) {
}

function updateTimeline(state, dispatch, log_id, start, end, allowPathChange) {
dispatch(checkRoutesData());
Copy link
Contributor Author

@sshane sshane Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in #419, I'm not sure why. It re-queries the API twice on loading any route (from URL only). With this change, this ends up breaking something in ACTION_ROUTES_METADATA as it is also called twice; the second time segmentRange's start and end values are properly set, but that function only works if they're both NaN on first load (??). On master, querying the API the first time here is fine because the limit param just happens to be set to 0 so currentRoute isn't set yet, which would change segmentRange's start and end lol

In summary: I'm amazed connect works as well as it does


if (!state.loop || !state.loop.startTime || !state.loop.duration || state.loop.startTime < start
|| state.loop.startTime + state.loop.duration > end || state.loop.duration < end - start) {
dispatch(resetPlayback());
Expand Down