Skip to content

Commit

Permalink
Persist timeline range when loading log file
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 11, 2024
1 parent 1659609 commit 5a8ce75
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hub/SelectionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ export default class SelectionImpl implements Selection {
/** Returns the visible range for the timeline. */
getTimelineRange(): [number, number] {
this.applyTimelineScroll(0, 0, 0);
return this.timelineRange;
return [...this.timelineRange];
}

/** Returns whether the timeline is locked to max zoom. */
getTimelineIsMaxZoom(): boolean {
return this.timelineMaxZoom;
}

/** Set the visible range for the timeline. */
Expand Down
9 changes: 9 additions & 0 deletions src/hub/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,13 @@ window.getLoadingFields = () => {
/** Connects to a historical data source. */
function startHistorical(path: string, clear = true, merge = false) {
clear = clear || !merge;
let originalTimelineRange: null | [number, number] = null;
let originalTimelineIsMaxZoom: null | boolean = null;
if (clear) {
historicalSources.forEach((entry) => entry.source.stop());
historicalSources = [];
originalTimelineRange = window.selection.getTimelineRange();
originalTimelineIsMaxZoom = window.selection.getTimelineIsMaxZoom();
window.log = new Log();
window.sidebar.refresh();
window.tabs.refresh();
Expand Down Expand Up @@ -348,6 +352,11 @@ function startHistorical(path: string, clear = true, merge = false) {
setWindowTitle(logFriendlyName);
sourceEntry.progress = null;
updateLoading();
if (originalTimelineRange !== null && originalTimelineIsMaxZoom !== null) {
window.selection.setTimelineRange(originalTimelineRange, originalTimelineIsMaxZoom);
originalTimelineRange = null;
originalTimelineIsMaxZoom = null;
}
break;
case HistoricalDataSourceStatus.Error:
setWindowTitle(logFriendlyName, "Error");
Expand Down
4 changes: 4 additions & 0 deletions src/satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ class MockSelection implements Selection {
throw new Error("Method not implemented.");
}

getTimelineIsMaxZoom(): boolean {
throw new Error("Method not implemented.");
}

setTimelineRange(range: [number, number], lockMaxZoom: boolean) {
throw new Error("Method not implemented.");
}
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export default interface Selection {
/** Returns the visible range for the timeline. */
getTimelineRange(): [number, number];

/** Returns whether the timeline is locked to max zoom. */
getTimelineIsMaxZoom(): boolean;

/** Set the visible range for the timeline. */
setTimelineRange(range: [number, number], lockMaxZoom: boolean): void;

Expand Down

0 comments on commit 5a8ce75

Please sign in to comment.