Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32441 from mcav/clock-defaults-enable
Browse files Browse the repository at this point in the history
Bug 1214546 - The ‘Start‘ button is grey with new defaults. r=gandalf
  • Loading branch information
mcav committed Oct 16, 2015
2 parents 45a6976 + 31f9578 commit bbe5eae
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions apps/clock/js/panels/timer/main.js
Expand Up @@ -123,7 +123,10 @@ Timer.Panel = function(element) {
picker.nodes.minutes.addEventListener('transitionend', enableButton);
picker.nodes.hours.addEventListener('transitionend', enableButton);

this.restoreDefaults();
this.restoreDefaults().then(() => {
enableButton(); // Update the enabled state to match the new defaults.
});

this.nodes.vibrate.addEventListener(
'change', (e) => this.saveCurrentSettingsAsDefaults());
this.nodes.sound.addEventListener(
Expand All @@ -149,17 +152,20 @@ Timer.Panel = function(element) {
Timer.Panel.prototype = Object.create(Panel.prototype);

Timer.Panel.prototype.restoreDefaults = function() {
asyncStorage.getItem('timer-defaults', (values) => {
values = values || {};
if (values.sound != null) {
this.soundButton.value = values.sound;
}
if (values.time != null) {
this.picker.value = values.time;
}
if (values.vibrate != null) {
this.nodes.vibrate.checked = values.vibrate;
}
return new Promise((resolve) => {
asyncStorage.getItem('timer-defaults', (values) => {
values = values || {};
if (values.sound != null) {
this.soundButton.value = values.sound;
}
if (values.time != null) {
this.picker.value = values.time;
}
if (values.vibrate != null) {
this.nodes.vibrate.checked = values.vibrate;
}
resolve();
});
});
};

Expand Down

0 comments on commit bbe5eae

Please sign in to comment.