Skip to content

Commit

Permalink
Fix issue with live show elapsed time not parsing UTC correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim020 committed May 22, 2023
1 parent 7197124 commit 1739406
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions client/src/views/show/ShowLiveView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default {
currentFirstPage: 1,
currentLastPage: 1,
pageBatchSize: 3,
startTime: null,
};
},
async mounted() {
Expand All @@ -97,6 +98,7 @@ export default {
this.computeContentSize();
this.computeScriptBoundaries();
this.startTime = this.createDateAsUTC(new Date(this.CURRENT_SHOW_SESSION.start_date_time.replace(' ', 'T')));
this.elapsedTimer = setInterval(this.updateElapsedTime, 1000);
this.scrollTimer = setInterval(this.computeScriptBoundaries, 25);
window.addEventListener('resize', debounce(this.computeContentSize, 100));
Expand All @@ -111,10 +113,20 @@ export default {
},
methods: {
msToTimer,
createDateAsUTC(date) {
return new Date(Date.UTC(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
));
},
updateElapsedTime() {
const now = new Date().getTime();
const startTime = Date.parse(this.CURRENT_SHOW_SESSION.start_date_time);
this.elapsedTime = now - startTime;
if (this.startTime != null) {
this.elapsedTime = Date.now() - this.startTime;
}
},
computeScriptBoundaries() {
const scriptContainer = $('#script-container');
Expand Down

0 comments on commit 1739406

Please sign in to comment.