Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 826286 - time label should update should wait for moztimechange #7332

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 8 deletions.
  1. +5 −7 apps/communications/ftu/js/ui.js
  2. +7 −1 shared/js/tz_select.js
View
12 apps/communications/ftu/js/ui.js
@@ -232,13 +232,11 @@ var UIManager = {
document.getElementById('tz-continent-label').textContent =
timezone.id.replace(/\/.*$/, '');
document.getElementById('tz-city-label').textContent = timezone.city;
- // it can take a few milliseconds before the TZ change is reflected on time
- setTimeout(function updateTime() {
- var f = new navigator.mozL10n.DateTimeFormat();
- var now = new Date();
- var timeLabel = document.getElementById('time-configuration-label');
- timeLabel.innerHTML = f.localeFormat(now, _('shortTimeFormat'));
- });
+
+ var f = new navigator.mozL10n.DateTimeFormat();
+ var now = new Date();
+ var timeLabel = document.getElementById('time-configuration-label');
+ timeLabel.innerHTML = f.localeFormat(now, _('shortTimeFormat'));
},
chooseNetwork: function ui_cn(event) {
View
8 shared/js/tz_select.js
@@ -103,7 +103,13 @@ function tzSelect(contSelector, citySelector, onchange) {
var req = settings.createLock().set({ 'time.timezone': tz.id });
if (onchange) {
req.onsuccess = function updateTZ_callback() {
- onchange(tz);
+ // Wait until the timezone is actually set
+ // before calling the callback.
+ window.addEventListener('moztimechange', function timeChanged() {
+ window.removeEventListener('moztimechange', timeChanged);
+
+ onchange(tz);
+ });
}
}
}, lastMozSettingValue);
Something went wrong with that request. Please try again.