1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-24 06:59:52 +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 // only go to snapshot if caller did not request to zoom only
if (newPeriod.snapshot && !onlyZoomToPeriod) { if (newPeriod.snapshot && !onlyZoomToPeriod) {
this.gotoSnapshot(newPeriod.snapshot); this.gotoSnapshot(newPeriod.snapshot, newPeriod);
} else { } else {
// save current period (aka zoom) // 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 // 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
if (newPeriod.type > this.maxTimelineZoomLevel) { if (newPeriod.type > this.maxTimelineZoomLevel) {
this.currentPeriod = newPeriod.getDay(); this.currentPeriod = newPeriod.get(this.maxTimelineZoomLevel);
} else { } else {
this.currentPeriod = newPeriod; this.currentPeriod = newPeriod;
} }
} }
}, },
gotoSnapshot(snapshot) { gotoSnapshot(snapshot, fromPeriod) {
this.currentSnapshot = snapshot; 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 // COMMUNICATE TO ContentFrame
this.$emit("show-snapshot", snapshot); this.$emit("show-snapshot", snapshot);
this.showFullView = false; this.showFullView = false;

View File

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

View File

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