mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-12 06:55:26 +00:00
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:
@@ -116,26 +116,24 @@
|
||||
});
|
||||
if ($location.url().length === 0) {
|
||||
// Restore user's last view
|
||||
Preferences.ready().then(function() {
|
||||
var url = '/calendar/',
|
||||
view = /(.+)view/.exec(Preferences.settings.Calendar.View);
|
||||
if (view)
|
||||
url += view[1];
|
||||
else
|
||||
url += 'week';
|
||||
// Append today's date or next enabled weekday
|
||||
var now = new Date();
|
||||
if (Preferences.defaults.SOGoCalendarWeekdays) {
|
||||
var weekDays = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'];
|
||||
var weekDay = weekDays[now.getDay()];
|
||||
while (Preferences.defaults.SOGoCalendarWeekdays.indexOf(weekDay) < 0) {
|
||||
now.addDays(1);
|
||||
weekDay = weekDays[now.getDay()];
|
||||
}
|
||||
var url = '/calendar/',
|
||||
view = /(.+)view/.exec(Preferences.settings.Calendar.View);
|
||||
if (view)
|
||||
url += view[1];
|
||||
else
|
||||
url += 'week';
|
||||
// Append today's date or next enabled weekday
|
||||
var now = new Date();
|
||||
if (Preferences.defaults.SOGoCalendarWeekdays) {
|
||||
var weekDays = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'];
|
||||
var weekDay = weekDays[now.getDay()];
|
||||
while (Preferences.defaults.SOGoCalendarWeekdays.indexOf(weekDay) < 0) {
|
||||
now.addDays(1);
|
||||
weekDay = weekDays[now.getDay()];
|
||||
}
|
||||
url += '/' + now.getDayString();
|
||||
$location.replace().url(url);
|
||||
});
|
||||
}
|
||||
url += '/' + now.getDayString();
|
||||
$location.replace().url(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user