perf(calendar(web)): initiate Web calendars reload from the frontend
The Web calendars subsciptions marked to be reloaded on login are no longer reloaded from the backend; the sync operation is now activated from the frontend in XHR calls to avoid blocking the Web interface. Fixes #4939master
parent
ef64c13410
commit
f017c42608
|
@ -35,8 +35,6 @@
|
|||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <NGExtensions/NSObject+Values.h>
|
||||
|
||||
#import <Appointments/SOGoAppointmentFolders.h>
|
||||
|
||||
#import <SOGo/NSString+Crypto.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/SOGoBuild.h>
|
||||
|
@ -49,6 +47,7 @@
|
|||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/SOGoWebAuthenticator.h>
|
||||
|
||||
#if defined(MFA_CONFIG)
|
||||
|
@ -173,6 +172,26 @@
|
|||
andJSONRepresentation: jsonError];
|
||||
}
|
||||
|
||||
- (void) _checkAutoReloadWebCalendars: (SOGoUser *) loggedInUser
|
||||
{
|
||||
NSDictionary *autoReloadedWebCalendars;
|
||||
NSMutableDictionary *moduleSettings;
|
||||
SOGoUserSettings *us;
|
||||
|
||||
us = [loggedInUser userSettings];
|
||||
moduleSettings = [us objectForKey: @"Calendar"];
|
||||
|
||||
if (moduleSettings)
|
||||
{
|
||||
autoReloadedWebCalendars = [moduleSettings objectForKey: @"AutoReloadedWebCalendars"];
|
||||
if ([[autoReloadedWebCalendars allValues] containsObject: [NSNumber numberWithInt: 1]])
|
||||
{
|
||||
[moduleSettings setObject: [NSNumber numberWithBool: YES] forKey: @"ReloadWebCalendars"];
|
||||
[us synchronize];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
@ -182,7 +201,6 @@
|
|||
WORequest *request;
|
||||
WOCookie *authCookie, *xsrfCookie;
|
||||
SOGoWebAuthenticator *auth;
|
||||
SOGoAppointmentFolders *calendars;
|
||||
SOGoUserDefaults *ud;
|
||||
SOGoUser *loggedInUser;
|
||||
NSDictionary *params;
|
||||
|
@ -294,6 +312,8 @@
|
|||
}
|
||||
#endif
|
||||
|
||||
[self _checkAutoReloadWebCalendars: loggedInUser];
|
||||
|
||||
json = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[loggedInUser cn], @"cn",
|
||||
[NSNumber numberWithInt: expire], @"expire",
|
||||
|
@ -323,10 +343,6 @@
|
|||
[ud setLanguage: language];
|
||||
[ud synchronize];
|
||||
}
|
||||
|
||||
calendars = [loggedInUser calendarsFolderInContext: context];
|
||||
if ([calendars respondsToSelector: @selector (reloadWebCalendars:)])
|
||||
[calendars reloadWebCalendars: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,7 +398,6 @@
|
|||
{
|
||||
WOResponse *response;
|
||||
NSString *login, *logoutRequest, *newLocation, *oldLocation, *ticket;
|
||||
SOGoAppointmentFolders *calendars;
|
||||
SOGoCASSession *casSession;
|
||||
SOGoUser *loggedInUser;
|
||||
SOGoWebAuthenticator *auth;
|
||||
|
@ -450,9 +465,7 @@
|
|||
}
|
||||
|
||||
loggedInUser = [SOGoUser userWithLogin: login];
|
||||
calendars = [loggedInUser calendarsFolderInContext: context];
|
||||
if ([calendars respondsToSelector: @selector (reloadWebCalendars:)])
|
||||
[calendars reloadWebCalendars: NO];
|
||||
[self _checkAutoReloadWebCalendars: loggedInUser];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -476,6 +489,7 @@
|
|||
{
|
||||
WOResponse *response;
|
||||
NSString *login, *newLocation, *oldLocation;
|
||||
SOGoUser *loggedInUser;
|
||||
WOCookie *saml2LocationCookie;
|
||||
WORequest *rq;
|
||||
|
||||
|
@ -500,6 +514,9 @@
|
|||
newLocation = [NSString stringWithFormat: @"%@%@",
|
||||
oldLocation, [login stringByEscapingURL]];
|
||||
}
|
||||
|
||||
loggedInUser = [SOGoUser userWithLogin: login];
|
||||
[self _checkAutoReloadWebCalendars: loggedInUser];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1567,6 +1567,14 @@ static NSArray *reminderValues = nil;
|
|||
|
||||
if ((v = [o objectForKey: @"settings"]))
|
||||
{
|
||||
// Remove ReloadWebCalendars if necessary
|
||||
NSMutableDictionary *calendarModule = [o objectForKey: @"Calendar"];
|
||||
if (calendarModule && [calendarModule objectForKey: @"ReloadWebCalendars"] == nil)
|
||||
{
|
||||
calendarModule = [[user userSettings] objectForKey: @"Calendar"];
|
||||
[calendarModule removeObjectForKey: @"ReloadWebCalendars"];
|
||||
}
|
||||
|
||||
[[[user userSettings] source] setValues: v];
|
||||
[[user userSettings] synchronize];
|
||||
}
|
||||
|
|
|
@ -180,8 +180,30 @@
|
|||
data = {};
|
||||
}
|
||||
|
||||
// We convert our PreventInvitationsWhitelist hash into a array of user
|
||||
if (data.Calendar) {
|
||||
|
||||
// When the Calendar settings include "AutoReloadedWebCalendars", reload the Web calendars
|
||||
// marked to be reloaded on login (AutoReloadedWebCalendars). Once completed, remove the
|
||||
// parameter and save the settings.
|
||||
if (data.Calendar.ReloadWebCalendars && data.Calendar.AutoReloadedWebCalendars) {
|
||||
var reloadPromises = [];
|
||||
_.map(data.Calendar.AutoReloadedWebCalendars, function (autoReload, id) {
|
||||
if (autoReload) {
|
||||
var calendarId = id.split('/')[1],
|
||||
deferred = Preferences.$q.defer();
|
||||
Preferences.$$resource.quietFetch('Calendar/' + calendarId, 'reload').finally(deferred.resolve);
|
||||
reloadPromises.push(deferred.promise);
|
||||
}
|
||||
});
|
||||
Preferences.$q.all(reloadPromises).then(function() {
|
||||
delete _this.settings.Calendar.ReloadWebCalendars;
|
||||
Preferences.$$resource.save("Preferences", { settings: _this.$omit(true).settings }).then(function () {
|
||||
Preferences.$rootScope.$emit('calendars:list');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// We convert our PreventInvitationsWhitelist hash into a array of user
|
||||
if (data.Calendar.PreventInvitationsWhitelist) {
|
||||
data.Calendar.PreventInvitationsWhitelist = _.map(data.Calendar.PreventInvitationsWhitelist, function(value, key) {
|
||||
var match = /^(.+)\s<(\S+)>$/.exec(value),
|
||||
|
@ -204,10 +226,11 @@
|
|||
* @desc The factory we'll use to register with Angular
|
||||
* @returns the Preferences constructor
|
||||
*/
|
||||
Preferences.$factory = ['$window', '$document', '$q', '$timeout', '$log', '$state', '$mdDateLocale', '$mdToast', 'sgSettings', 'Gravatar', 'Resource', 'User', function($window, $document, $q, $timeout, $log, $state, $mdDateLocaleProvider, $mdToast, Settings, Gravatar, Resource, User) {
|
||||
Preferences.$factory = ['$window', '$document', '$rootScope', '$q', '$timeout', '$log', '$state', '$mdDateLocale', '$mdToast', 'sgSettings', 'Gravatar', 'Resource', 'User', function($window, $document, $rootScope, $q, $timeout, $log, $state, $mdDateLocaleProvider, $mdToast, Settings, Gravatar, Resource, User) {
|
||||
angular.extend(Preferences, {
|
||||
$window: $window,
|
||||
$document: $document,
|
||||
$rootScope: $rootScope,
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
|
|
Loading…
Reference in New Issue