Skip to content

Commit

Permalink
Use seconds instead of ms in url.
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7B5 committed Jun 15, 2024
1 parent 5b11bd0 commit 0e7d503
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/__puppeteer__/drive.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { configureViewport, goto } from './utils';

const DEMO_DEVICE_URL = '/1d3dc3e03047b0c7';
const DEMO_ROUTE_URL = '/1d3dc3e03047b0c7/000000dd--455f14369d';
const ZOOMED_DEMO_URL = '/1d3dc3e03047b0c7/000000dd--455f14369d/147082/290214';
const ZOOMED_DEMO_URL = '/1d3dc3e03047b0c7/000000dd--455f14369d/109/423';

jest.setTimeout(60000);

Expand Down
8 changes: 6 additions & 2 deletions src/actions/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ export const onHistoryMiddleware = ({ dispatch, getState }) => (next) => async (
}

const pathZoom = getZoom(action.payload.location.pathname);
if ((pathZoom !== state.zoom) && pathZoom) {
const pathSegmentRange = getSegmentRange(action.payload.location.pathname);

if ((pathZoom !== state.zoom) && pathZoom && !pathSegmentRange) {
const [start, end] = [pathZoom.start, pathZoom.end];

console.log('Fetching routes data for log ID conversion', pathDongleId, start, end);
Drives.getRoutesSegments(pathDongleId, start, end).then((routesData) => {
if (routesData && routesData.length > 0) {
const log_id = routesData[0].fullname.split('|')[1];
Expand All @@ -34,7 +38,7 @@ export const onHistoryMiddleware = ({ dispatch, getState }) => (next) => async (
});
}

const pathSegmentRange = getSegmentRange(action.payload.location.pathname);

if (pathSegmentRange !== state.segmentRange) {
dispatch(pushTimelineRange(pathSegmentRange?.log_id, pathSegmentRange?.start, pathSegmentRange?.end, false));
}
Expand Down
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function updateTimeline(state, dispatch, log_id, start, end, allowPathChange) {
}

if (allowPathChange) {
const desiredPath = urlForState(state.dongleId, log_id, start, end, false);
const desiredPath = urlForState(state.dongleId, log_id, Math.floor(start/1000), Math.floor(end/1000), false);
// const desiredPath = urlForState(state.dongleId, log_id, Math.floor(start), Math.floor(end), false);
if (window.location.pathname !== desiredPath) {
dispatch(push(desiredPath));
}
Expand Down
5 changes: 2 additions & 3 deletions src/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function getDongleID(pathname) {
export function getZoom(pathname) {
let parts = pathname.split('/');
parts = parts.filter((m) => m.length);

if (parts.length >= 3 && parts[0] !== 'auth') {
return {
start: Number(parts[1]),
Expand All @@ -32,8 +31,8 @@ export function getSegmentRange(pathname) {
if (parts.length >= 2 && logIdRegex.test(parts[1])) {
return {
log_id: parts[1],
start: Number(parts[2]),
end: Number(parts[3]),
start: Number(parts[2]) * 1000,
end: Number(parts[3]) * 1000,
};
}
return null;
Expand Down

0 comments on commit 0e7d503

Please sign in to comment.