Skip to content

Commit

Permalink
Fixed issue with wrong deltas being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Aug 4, 2016
1 parent f3fd386 commit 0e0ad64
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions example/localTimeSystem/src/LocalTimeSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define([
], function (TimeSystem, LocalClock, LADTickSource) {
var FIFTEEN_MINUTES = 15 * 60 * 1000,
THIRTY_MINUTES = 30 * 60 * 1000,
ONE_HOUR = 60 * 60 * 1000,
DEFAULT_PERIOD = 1000;

/**
Expand Down Expand Up @@ -73,8 +74,7 @@ define([
key: 'local-default',
name: 'Local 12 hour time system defaults',
mode: 'fixed',
deltas: {start: FIFTEEN_MINUTES, end: 0},
bounds: {start: now - FIFTEEN_MINUTES, end: now}
bounds: {start: now - ONE_HOUR, end: now}
},
{
key: 'local-default',
Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ define([
'./platform/search/bundle',
'./platform/status/bundle',
'./platform/commonUI/regions/bundle'
//'./example/localTimeSystem/bundle'

], function (Main, legacyRegistry) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ define(
break;
}
newMode.initialize();
this.setDeltasFromDefaults(newMode.defaults());

this.conductorService.mode(newMode);

//Synchronize scope with time system on mode
Expand All @@ -275,8 +277,7 @@ define(
/**
* @private
*/
TimeConductorController.prototype.setDeltasFromMode = function (mode) {
var defaults = mode.defaults();
TimeConductorController.prototype.setDeltasFromDefaults = function (defaults) {
var deltas = defaults.deltas;

/*
Expand Down Expand Up @@ -312,12 +313,16 @@ define(
*/
TimeConductorController.prototype.setTimeSystem = function (newTimeSystem) {
if (newTimeSystem && newTimeSystem !== this.$scope.timeSystemModel.selected) {

var mode = this.conductorService.mode();
mode.timeSystem(newTimeSystem);
var defaults = mode.defaults();

this.$scope.timeSystemModel.selected = newTimeSystem;
this.$scope.timeSystemModel.format = newTimeSystem.formats()[0];
this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat();
var mode = this.conductorService.mode();
mode.timeSystem(newTimeSystem);
this.setDeltasFromMode(mode);

this.setDeltasFromDefaults(defaults);

// If current mode supports ticking, set an appropriate tick
// source from the new time system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ define([
key: 'utc-default',
name: 'UTC time system defaults',
mode: 'fixed',
deltas: {start: FIFTEEN_MINUTES, end: 0},
bounds: {start: now - FIFTEEN_MINUTES, end: now}
}
];
Expand Down

0 comments on commit 0e0ad64

Please sign in to comment.