diff --git a/UI/MailerUI/UIxMailActions.m b/UI/MailerUI/UIxMailActions.m index d14c17031..3da8b7540 100644 --- a/UI/MailerUI/UIxMailActions.m +++ b/UI/MailerUI/UIxMailActions.m @@ -34,6 +34,7 @@ #import #import #import +#import #import #import "../Common/WODirectAction+SOGo.h" @@ -164,13 +165,11 @@ if (isCollapsing) { // Check if the module threadsCollapsed is created in the userSettings - if ([[moduleSettings objectForKey:@"threadsCollapsed"] boolValue]) + if ((threadsCollapsed = [moduleSettings objectForKey:@"threadsCollapsed"])) { - threadsCollapsed = [moduleSettings objectForKey:@"threadsCollapsed"]; // Check if the currentMailbox already have other threads saved and add the new collapsed thread - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ((mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs])) { - mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs]; if (![mailboxThreadsCollapsed containsObject:msguid]) [mailboxThreadsCollapsed addObject:msguid]; } @@ -191,13 +190,11 @@ else { // Check if the module threadsCollapsed is created in the userSettings - if ([[moduleSettings objectForKey:@"threadsCollapsed"] boolValue]) + if ((threadsCollapsed = [moduleSettings objectForKey:@"threadsCollapsed"])) { - threadsCollapsed = [moduleSettings objectForKey:@"threadsCollapsed"]; // Check if the currentMailbox already have other threads saved and remove the uncollapsed thread - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ((mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs])) { - mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs]; [mailboxThreadsCollapsed removeObject:msguid]; if ([mailboxThreadsCollapsed count] == 0) diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index becfbad5d..30f1816cd 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -92,7 +92,7 @@ SOGoUserSettings *us; WOResponse *response; NSException *error; - NSString *newFolderName, *oldFolderName, *currentMailbox, *currentAccount, *keyForMsgUIDs, *newKeyForMsgUIDs; + NSString *newFolderName, *currentMailbox, *currentAccount, *keyForMsgUIDs, *newKeyForMsgUIDs; NSMutableDictionary *moduleSettings, *threadsCollapsed; NSArray *values; @@ -116,9 +116,9 @@ else { // Verify if the current folder have any collapsed threads save under it old name and adjust the folderName - if ([threadsCollapsed boolValue]) + if (threadsCollapsed) { - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ([threadsCollapsed objectForKey:keyForMsgUIDs]) { values = [NSArray arrayWithArray:[threadsCollapsed objectForKey:keyForMsgUIDs]]; [threadsCollapsed setObject:values forKey:newKeyForMsgUIDs]; @@ -209,9 +209,9 @@ currentAccount = [[co container] nameInContainer]; keyForMsgUIDs = [NSString stringWithFormat:@"/%@/%@", currentAccount, currentMailbox]; - if ([threadsCollapsed boolValue]) + if (threadsCollapsed) { - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ([threadsCollapsed objectForKey:keyForMsgUIDs]) { [threadsCollapsed removeObjectForKey:keyForMsgUIDs]; [us synchronize]; @@ -273,11 +273,10 @@ currentAccount = [[co container] nameInContainer]; keyForMsgUIDs = [NSString stringWithFormat:@"/%@/%@", currentAccount, currentMailbox]; - if ([threadsCollapsed boolValue]) + if (threadsCollapsed) { - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ((mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs])) { - mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs]; for (i = 0; i < [uids count]; i++) [mailboxThreadsCollapsed removeObject:[uids objectAtIndex:i]]; [us synchronize]; @@ -411,11 +410,10 @@ currentAccount = [[co container] nameInContainer]; keyForMsgUIDs = [NSString stringWithFormat:@"/%@/%@", currentAccount, currentMailbox]; - if ([threadsCollapsed boolValue]) + if (threadsCollapsed) { - if ([[threadsCollapsed objectForKey:keyForMsgUIDs] boolValue]) + if ((mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs])) { - mailboxThreadsCollapsed = [threadsCollapsed objectForKey:keyForMsgUIDs]; for (i = 0; i < [uids count]; i++) [mailboxThreadsCollapsed removeObject:[uids objectAtIndex:i]]; [us synchronize]; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index d28d92c99..395cebbd0 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -33,6 +33,10 @@ var deleteMessageRequestCount = 0; var messageCheckTimer; +// Variables for feature threadsCollapsing +var displayThreadElement = false; +var cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; + /* We need to override this method since it is adapted to GCS-based folder references, which we do not use here */ function URLForFolderID(folderID, application) { @@ -958,8 +962,6 @@ function openMailbox(mailbox, reload) { /* * Called from SOGoDataTable.render() */ -var show = false; -var cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; function messageListCallback(row, data, isNew) { var currentMessage = Mailer.currentMessages[Mailer.currentMailbox]; @@ -978,7 +980,7 @@ function messageListCallback(row, data, isNew) { var collapsedList = cachedThreadsCollapsed[mailbox]; if (collapsedList != undefined && collapsedList.indexOf(row.id.split("_")[1]) != -1) { row.addClassName('closedThread'); - show = true; + displayThreadElement = true; } else { row.addClassName('openedThread'); @@ -991,12 +993,12 @@ function messageListCallback(row, data, isNew) { row.addClassName('thread'); row.addClassName('thread' + data['ThreadLevel']); - if (show) + if (displayThreadElement) row.hide(); } else - show = false; + displayThreadElement = false; var cells = row.childElements(); for (var j = 0; j < cells.length; j++) { @@ -2604,10 +2606,19 @@ function onMenuToggleMessageFlag(event) { mailListToggleMessagesFlagged(); } +function refreshUserSettingsCallback(http) { + var allUserSettings = http.response.evalJSON(); + UserSettings.Mail = allUserSettings.Mail; + cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; + refreshMailbox(); +} + function folderOperationCallback(http) { - if (http.readyState == 4 - && isHttpStatus204(http.status)) + if (http.readyState == 4 && isHttpStatus204(http.status)) { initMailboxTree(); + var url = ApplicationBaseURL.split("Mail")[0]; + triggerAjaxRequest(url + "/jsonSettings", refreshUserSettingsCallback); + } else showAlertDialog(http.callbackData); }