1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00
fixed navigation to correct timeline period upon goto snapshot from timeline or calendar
This commit is contained in:
Ivan Velev 2021-09-21 06:42:30 -07:00
parent b694fa817f
commit 000c12f2d6
4 changed files with 54 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -93,7 +93,7 @@ export default {
}
// only go to snapshot if caller did not request to zoom only
if (newPeriod.snapshot && !onlyZoomToPeriod) {
this.gotoSnapshot(newPeriod.snapshot);
this.gotoSnapshot(newPeriod.snapshot, newPeriod);
} else {
// save current period (aka zoom)
// use sessionStorage (not localStorage), as we want this to be a very temporary memory for current page tab/window and no longer; NOTE: it serves when navigating from an "*" query to a specific capture and subsequent reloads
@ -102,14 +102,23 @@ export default {
}
// If
if (newPeriod.type > this.maxTimelineZoomLevel) {
this.currentPeriod = newPeriod.getDay();
this.currentPeriod = newPeriod.get(this.maxTimelineZoomLevel);
} else {
this.currentPeriod = newPeriod;
}
}
},
gotoSnapshot(snapshot) {
gotoSnapshot(snapshot, fromPeriod) {
this.currentSnapshot = snapshot;
// if the current period is not matching the current snapshot, updated it!
if (fromPeriod && !this.currentPeriod.contains(fromPeriod)) {
const fromPeriodAtMaxZoomLevel = fromPeriod.get(this.maxTimelineZoomLevel);
if (fromPeriodAtMaxZoomLevel !== this.currentPeriod) {
this.currentPeriod = fromPeriodAtMaxZoomLevel;
}
}
// COMMUNICATE TO ContentFrame
this.$emit("show-snapshot", snapshot);
this.showFullView = false;

View File

@ -31,6 +31,7 @@
:month="month"
:year="year"
:is-current="month === currentMonth"
:has-current-snapshot="month === currentMonth"
@goto-period="$emit('goto-period', $event)"
@show-day-timeline="setCurrentTimeline"
></CalendarMonth>
@ -52,7 +53,7 @@ import { PywbPeriod } from "../model.js";
export default {
components: {CalendarMonth, TimelineLinear, Tooltip},
props: ["period"],
props: ["period", "currentSnapshot"],
data: function() {
return {
firstZoomLevel: PywbPeriod.Type.day,

View File

@ -319,7 +319,7 @@ PywbPeriod.prototype.getParents = function(skipAllTime=false) {
};
PywbPeriod.prototype.contains = function(period) {
return !!period.getParents().find(this);
return !!period.getParents().find(p => p === this);
};
PywbPeriod.prototype.snapshot = null;