Expose user's settings and defaults inline

This improves performance by removing two AJAX calls and a lot of
JavaScript promises.
This commit is contained in:
Francis Lachapelle
2017-06-01 13:48:45 -04:00
parent 1fa056bb25
commit 89bfa0c536
22 changed files with 441 additions and 484 deletions
@@ -8,7 +8,7 @@
*/
CalendarListController.$inject = ['$rootScope', '$scope', '$timeout', '$state', '$mdDialog', 'sgHotkeys', 'sgFocus', 'Dialog', 'Preferences', 'CalendarSettings', 'Calendar', 'Component', 'Alarm'];
function CalendarListController($rootScope, $scope, $timeout, $state, $mdDialog, sgHotkeys, focus, Dialog, Preferences, CalendarSettings, Calendar, Component, Alarm) {
var vm = this, hotkeys = [];
var vm = this, hotkeys = [], type;
vm.component = Component;
vm.componentType = 'events';
@@ -32,32 +32,32 @@
vm.mode = { search: false, multiple: 0 };
_registerHotkeys(hotkeys);
this.$onInit = function() {
_registerHotkeys(hotkeys);
// Select list based on user's settings
Preferences.ready().then(function() {
var type = 'events';
// Select list based on user's settings
type = 'events';
if (Preferences.settings.Calendar.SelectedList == 'tasksListView') {
vm.selectedList = 1;
type = 'tasks';
}
selectComponentType(type, { reload: true }); // fetch events/tasks lists
});
// Refresh current list when the list of calendars is modified
$rootScope.$on('calendars:list', function() {
Component.$filter(vm.componentType, { reload: true });
});
// Update the component being dragged
$rootScope.$on('calendar:dragend', updateComponentFromGhost);
$scope.$on('$destroy', function() {
// Deregister hotkeys
_.forEach(hotkeys, function(key) {
sgHotkeys.deregisterHotkey(key);
// Refresh current list when the list of calendars is modified
$rootScope.$on('calendars:list', function() {
Component.$filter(vm.componentType, { reload: true });
});
});
// Update the component being dragged
$rootScope.$on('calendar:dragend', updateComponentFromGhost);
$scope.$on('$destroy', function() {
// Deregister hotkeys
_.forEach(hotkeys, function(key) {
sgHotkeys.deregisterHotkey(key);
});
});
};
function _registerHotkeys(keys) {