Skip to content

Commit

Permalink
Use method for timeToShow to deal with reactivity issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Apr 8, 2024
1 parent c181f45 commit f181eb0
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions src/EclipseTimer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="eclipse-timer-container" class="info-overlay-container">
<h1> Eclipse Timer</h1>
<h1>Eclipse Timer</h1>
<div v-if="showTimer" class="eclipse-countdown">
<div v-if="!noEclipse" class="ec-timer">{{ timeToShow }}</div>
<div v-if="!noEclipse">
Expand Down Expand Up @@ -160,11 +160,7 @@ export default defineComponent({
this.updateTimeData();
setInterval(() => {
try {
this.updateTimeData();
} catch (e) {
console.error(e);
}
this.updateTimeData();
}, 1000);
},
Expand All @@ -185,6 +181,7 @@ export default defineComponent({
timeToEndTotality: '',
timeToStartTotality: '',
timeText: '',
timeToShow: '',
};
},
Expand Down Expand Up @@ -258,24 +255,7 @@ export default defineComponent({
return spaceHMS(this.prediction.duration);
},
timeToShow(): string {
console.log('timeToShow');
// before totality or before max
if (this.type === 'Total' && this.beforeTotality()) {
return this.timeToStartTotality;
} else if (this.inTotality()) {
return this.timeToEndTotality;
} else if (!this.isTotal && this.beforeMax()) {
return this.timeToEclipse;
} else if ((this.afterMax() && this.beforeEndPartial()) || (this.afterTotality() && !this.afterEndPartial())) {
return this.timeToEndPartial;
} else {
return 'The Eclipse has passed';
}
},
},
Expand Down Expand Up @@ -408,7 +388,6 @@ export default defineComponent({
},
getTimeText(): string {
console.log('getTimeText');
if (this.type === '') return '';
if (this.type === 'Total' && this.beforeTotality()) {
return 'until totality';
Expand All @@ -422,6 +401,21 @@ export default defineComponent({
return '';
}
},
getTimeToShow(): string {
// before totality or before max
if (this.type === 'Total' && this.beforeTotality()) {
return this.timeToStartTotality;
} else if (this.inTotality()) {
return this.timeToEndTotality;
} else if (!this.isTotal && this.beforeMax()) {
return this.timeToEclipse;
} else if ((this.afterMax() && this.beforeEndPartial()) || (this.afterTotality() && !this.afterEndPartial())) {
return this.timeToEndPartial;
} else {
return 'The Eclipse has passed';
}
},
updateTime() {
this.getTimeToEclipse();
Expand All @@ -435,6 +429,7 @@ export default defineComponent({
this.updateTimeConditions();
this.updateTime();
this.timeText = this.getTimeText();
this.timeToShow = this.getTimeToShow();
}
}
},
Expand Down

0 comments on commit f181eb0

Please sign in to comment.