Skip to content

Commit

Permalink
Keep track of how long user has weather info open.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Mar 15, 2024
1 parent 2ba4214 commit c9dd2bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/AdvancedWeatherView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export default defineComponent({
'define-term': DefineTerm,
},
emits: ['update:modelValue','close'],
emits: ['update:modelValue','close', 'explainer-open'],
props: {
modelValue: {
Expand Down Expand Up @@ -1206,8 +1206,11 @@ export default defineComponent({
this.inBounds = inBounds;
});
this.getLatLonIndex(value.latitudeDeg, value.longitudeDeg);
},
explainerOpen(open: boolean) {
this.$emit('explainer-open', open);
}
},
Expand Down Expand Up @@ -1306,4 +1309,3 @@ export default defineComponent({
}
</style>
./utils
21 changes: 18 additions & 3 deletions src/SolarEclipse2024.vue
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@
@close="() => {
console.log('closing');
showAdvancedWeather = false;
}"
}"
@explainer-open="(open: boolean) => { weatherInfoOpen = open }"
:default-location="locationDeg"
/>
<div
Expand Down Expand Up @@ -1709,9 +1710,12 @@ export default defineComponent({
uuid,
infoTimeMs: 0,
weatherTimeMs: 0,
weatherInfoTimeMs: 0,
appStartTimestamp: Date.now(),
infoStartTimestamp: null as number | null,
weatherStartTimestamp: null as number | null,
weatherInfoStartTimestamp: null as number | null,
weatherInfoOpen: false,
responseOptOut: responseOptOut as boolean | null,
showSplashScreen: queryData.splash ?? true,
Expand Down Expand Up @@ -2833,10 +2837,12 @@ export default defineComponent({
this.cloudCoverSelectedLocations = [];
this.infoTimeMs = 0;
this.weatherTimeMs = 0;
this.weatherInfoTimeMs = 0;
const now = Date.now();
this.appStartTimestamp = now;
this.infoStartTimestamp = this.showInfoSheet ? now : null;
this.weatherStartTimestamp = this.showAdvancedWeather ? now : null;
this.weatherInfoStartTimestamp = this.weatherInfoOpen ? now : null;
},
sendUpdateData() {
Expand All @@ -2846,6 +2852,7 @@ export default defineComponent({
const now = Date.now();
const infoTime = (this.showInfoSheet && this.infoStartTimestamp !== null) ? now - this.infoStartTimestamp : this.infoTimeMs;
const weatherTime = (this.showAdvancedWeather && this.weatherStartTimestamp !== null) ? now - this.weatherStartTimestamp : this.weatherTimeMs;
const weatherInfoTime = (this.weatherInfoOpen && this.weatherInfoStartTimestamp !== null) ? now - this.weatherInfoStartTimestamp : this.weatherInfoTimeMs;
fetch(`${API_BASE_URL}/solar-eclipse-2024/data/${this.uuid}`, {
method: "PATCH",
headers: {
Expand All @@ -2861,8 +2868,7 @@ export default defineComponent({
// eslint-disable-next-line @typescript-eslint/naming-convention
delta_info_time_ms: infoTime, delta_app_time_ms: Date.now() - this.appStartTimestamp,
// eslint-disable-next-line @typescript-eslint/naming-convention
delta_advanced_weather_time_ms: weatherTime,
delta_advanced_weather_time_ms: weatherTime, delta_weather_info_time_ms: weatherInfoTime,
}),
keepalive: true,
}).then(() => {
Expand Down Expand Up @@ -3595,6 +3601,15 @@ export default defineComponent({
this.weatherStartTimestamp = null;
}
},
weatherInfoOpen(open: boolean) {
if (open) {
this.weatherInfoStartTimestamp = Date.now();
} else if (this.weatherInfoStartTimestamp !== null) {
this.weatherInfoTimeMs += (Date.now() - this.weatherInfoStartTimestamp);
this.weatherInfoStartTimestamp = null;
}
},
introSlide(val: number) {
this.inIntro = val < 4;
Expand Down

0 comments on commit c9dd2bc

Please sign in to comment.