Skip to content

Commit

Permalink
Custom duration detection: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
pakaoraki committed Jul 2, 2024
1 parent 4847883 commit 529bf35
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions caffeine@patapon.info/preferences/timerPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,16 @@ class CaffeineTimerPage extends Adw.PreferencesPage {
}

_isCustomValueSet() {
const shortValue = this.shortTimerSelector.get_value();
const mediumValue = this.mediumTimerSelector.get_value();
const longValue = this.longTimerSelector.get_value();
const selectors = [this.shortTimerSelector, this.mediumTimerSelector, this.longTimerSelector];
const durationIndex = this.sliderTimer.get_value();
let isCustomed = false;
if (shortValue !== parseInt(TIMERS_DURATION[durationIndex][0]) * 60) {
isCustomed = true;
}
if (mediumValue !== parseInt(TIMERS_DURATION[durationIndex][1]) * 60) {
isCustomed = true;
}
if (longValue !== parseInt(TIMERS_DURATION[durationIndex][2]) * 60) {
isCustomed = true;
let isCustom = false;
for (const [i, selector] of selectors.entries()) {
if (selector.get_value() !== parseInt(TIMERS_DURATION[durationIndex][i]) * 60) {
isCustom = true;
break;
}
}
return isCustomed;
return isCustom;
}

_updateTimerDuration(value) {
Expand Down

0 comments on commit 529bf35

Please sign in to comment.