Skip to content

Commit

Permalink
Add ETA text fixes and update healthkit lookback to 1000 days by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Nov 7, 2024
1 parent e95894c commit 78ea49b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
33 changes: 24 additions & 9 deletions src/app/pages/questions/components/finish/finish.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,24 @@ export class FinishComponent implements OnChanges {
) {}

ngOnChanges() {
if (this.isShown) this.usage.setPage(this.constructor.name)
if (this.progressCount == 1) this.showDoneButton = true
if (this.isShown) {
this.usage.setPage(this.constructor.name)
}

this.showDoneButton = this.progressCount >= 1

this.displayNextTaskReminder =
this.taskType == AssessmentType.SCHEDULED && !this.isLastTask

this.innerText = this.getFinishButtonText(this.progressCount)
this.shadowStyle = this.getProgressBarStyle(this.progressCount)
this.progressDisplay = Math.ceil(this.progressCount) * 100

// Ensure progress is within a valid range for displaying ETA
this.progressDisplay = Math.min(
Math.max(Math.ceil(this.progressCount * 100), 1),
99
)

this.etaText = this.getEtaText(this.progressDisplay)
}

Expand All @@ -73,10 +84,14 @@ export class FinishComponent implements OnChanges {
}

getEtaText(progress) {
const duration = getMinutes({ milliseconds: Date.now() - this.startTime })
return (
'About ' + (duration * (100 - progress)) / progress + ' minutes remaining'
)
if (progress <= 0) {
return 'Calculating time remaining...'
}

const elapsedTime = (Date.now() - this.startTime) / 1000 // Convert milliseconds to seconds
const remainingTime = (elapsedTime * (100 - progress)) / progress

return 'About ' + remainingTime.toFixed(0) + ' seconds remaining'
}

getProgressBarStyle(progress) {
Expand All @@ -87,7 +102,7 @@ export class FinishComponent implements OnChanges {

getFinishButtonText(progress) {
return progress < 1
? this.localization.translateKey(LocKeys.SETTINGS_WAIT_ALERT) + '...'
: this.localization.translateKey(LocKeys.BTN_DONE)
? this.localization.translateKey(LocKeys.SETTINGS_WAIT_ALERT) + '...'
: this.localization.translateKey(LocKeys.BTN_DONE)
}
}
2 changes: 1 addition & 1 deletion src/assets/data/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ export const DefaultHealthkitPermissions = [
]

// *Default lookback interval to pull Healthkit data from
export const DefaultHealthkitLookbackInterval = 100
export const DefaultHealthkitLookbackInterval = 1000

0 comments on commit 78ea49b

Please sign in to comment.