Skip to content

Commit

Permalink
Merge pull request #739 from nextcloud/AllwaysShowTracksWithoutTimest…
Browse files Browse the repository at this point in the history
…amps

Allways show tracks without timestamps
Review see #738
  • Loading branch information
tacruc committed Jun 7, 2022
2 parents c8c3cd6 + 4933abb commit 1ab9175
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/map/TrackLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
end: {
type: Number,
required: false,
default: moment.unix(),
default: moment().unix(),
},
},
Expand Down Expand Up @@ -113,7 +113,7 @@ export default {
},
lines() {
const trkSegments = []
if (this.track.metadata?.begin >= this.end || this.track.metadata?.end <= this.start) {
if (this.track.metadata?.begin >= this.end || (this.track.metadata?.end >= 0 && this.track.metadata?.end <= this.start)) {
return trkSegments
} else if (this.track.metadata?.begin >= this.start && this.track.metadata?.end <= this.end) {
this.track.data.tracks.forEach((trk) => {
Expand All @@ -129,8 +129,8 @@ export default {
this.track.data.tracks.forEach((trk) => {
trk.segments.forEach((segment) => {
const lastNullIndex = binSearch(segment.points, (p) => !p.timestamp)
const firstShownIndex = binSearch(segment.points, (p) => (p.timestamp || 0) < this.start) + 1
const lastShownIndex = binSearch(segment.points, (p) => (p.timestamp || 0) < this.end)
const firstShownIndex = binSearch(segment.points, (p) => (p.timestamp || -1) < this.start) + 1
const lastShownIndex = binSearch(segment.points, (p) => (p.timestamp || -1) < this.end)
const points = [
...segment.points.slice(0, lastNullIndex + 1),
...segment.points.slice(firstShownIndex, lastShownIndex + 1),
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/TracksLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
end: {
type: Number,
required: false,
default: moment.unix(),
default: moment().unix(),
},
},
Expand Down
9 changes: 7 additions & 2 deletions src/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Content app-name="maps">
<MapsNavigation
@toggle-trackme="onToggleTrackme"
@toggle-slider="sliderEnabled = $event; sliderStart=0; sliderEnd=moment.unix()">
@toggle-slider="onToggleSlider">
<template #items>
<AppNavigationFavoritesItem
:enabled="favoritesEnabled"
Expand Down Expand Up @@ -333,7 +333,7 @@ export default {
displayedTracks() {
return this.sliderEnabled
? this.tracks.filter((t) => {
return !(t.metadata?.begin >= this.sliderEnd || t.metadata?.end <= this.sliderStart)
return !(t.metadata?.begin >= this.sliderEnd || (t.metadata?.end >= 0 && t.metadata?.end <= this.sliderStart))
})
: this.tracks
},
Expand Down Expand Up @@ -617,6 +617,11 @@ export default {
this.stopTrackLoop()
}
},
onToggleSlider(enabled) {
this.sliderEnabled = enabled
this.sliderStart = 0
this.sliderEnd = moment().unix()
},
sendPositionLoop() {
// start a loop which get and send my position
if (navigator.geolocation && window.isSecureContext) {
Expand Down

0 comments on commit 1ab9175

Please sign in to comment.