Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7332 from timdream/ftu/time-label2
Browse files Browse the repository at this point in the history
Bug 826286 - time label should update should wait for moztimechange, r=kaze
  • Loading branch information
fabi1cazenave committed Jan 7, 2013
2 parents cffe591 + 1a007cc commit bedcb84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 5 additions & 7 deletions apps/communications/ftu/js/ui.js
Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion shared/js/tz_select.js
Expand Up @@ -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);
Expand Down

0 comments on commit bedcb84

Please sign in to comment.