adium 3516:9ef68db36629: When deleting a Timeline group, don't u...

commits at adium.im commits at adium.im
Sun Nov 14 15:29:37 UTC 2010


details:	http://hg.adium.im/adium/rev/9ef68db36629
revision:	3516:9ef68db36629
author:		Evan Schoenberg
date:		Sun Nov 14 09:29:02 2010 -0600

When deleting a Timeline group, don't unfollow all the contacts within; instead, just turn off their display. Fixes #12148
(transplanted from 3a23c59ac2ac230d45602b2f032631c3bbeda047)

diffs (178 lines):

diff -r 3eecd322a0bc -r 9ef68db36629 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Sat Nov 13 12:26:57 2010 -0600
+++ b/Adium.xcodeproj/project.pbxproj	Sun Nov 14 09:29:02 2010 -0600
@@ -9699,6 +9699,7 @@
 			};
 			buildConfigurationList = DADE8E3A085507450062B664 /* Build configuration list for PBXProject "Adium" */;
 			compatibilityVersion = "Xcode 3.1";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
diff -r 3eecd322a0bc -r 9ef68db36629 Frameworks/Adium Framework/Source/AIAbstractAccount.h
--- a/Frameworks/Adium Framework/Source/AIAbstractAccount.h	Sat Nov 13 12:26:57 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIAbstractAccount.h	Sun Nov 14 09:29:02 2010 -0600
@@ -80,6 +80,7 @@
 - (void)removeAllContacts;
 - (void)removePropertyValuesFromContact:(AIListContact *)listContact silently:(BOOL)silent;
 - (NSString *)fallbackAliasForContact:(AIListContact *)contact inChat:(AIChat *)chat;
+- (AIAccountGroupDeletionResponse)willDeleteGroup:(AIListGroup *)group;
 
 //Connectivity
 @property (readwrite, nonatomic) BOOL shouldBeOnline;
diff -r 3eecd322a0bc -r 9ef68db36629 Frameworks/Adium Framework/Source/AIAbstractAccount.m
--- a/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Sat Nov 13 12:26:57 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Sun Nov 14 09:29:02 2010 -0600
@@ -1096,6 +1096,20 @@
 	return nil;
 }
 
+/*!
+ * @brief How should deletion of a particular group be handled?
+ *
+ * If the account returns AIAccountGroupDeletionShouldRemoveContacts, then each contact will be removed from the contact list
+ * If instead AIAccountGroupDeletionShouldIgnoreContacts is returned, the group is removed from the contact list's display
+ *   but contacts are not affected.  In this case, the account should take action to avoid redisplaying the group in
+ *   the future. This is used for, for example, the Twitter timeline; a deletion is unlikely to mean the user actually
+ *   wanted to stop following all contained contacts.
+ */
+- (AIAccountGroupDeletionResponse)willDeleteGroup:(AIListGroup *)group
+{
+	return AIAccountGroupDeletionShouldRemoveContacts;
+}
+
 //Connectivity ---------------------------------------------------------------------------------------------------------
 #pragma mark Connectivity
 
diff -r 3eecd322a0bc -r 9ef68db36629 Frameworks/Adium Framework/Source/AIAccount.h
--- a/Frameworks/Adium Framework/Source/AIAccount.h	Sat Nov 13 12:26:57 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIAccount.h	Sun Nov 14 09:29:02 2010 -0600
@@ -79,6 +79,11 @@
 	AIAuthorizationAllowed
 } AIAuthorizationResponse;
 
+typedef enum {
+	AIAccountGroupDeletionShouldRemoveContacts = 0,
+	AIAccountGroupDeletionShouldIgnoreContacts
+} AIAccountGroupDeletionResponse;
+
 //Support for file transfer
 @protocol AIAccount_Files
 	//can the account send entire folders on its own?
diff -r 3eecd322a0bc -r 9ef68db36629 Frameworks/Adium Framework/Source/AIListBookmark.m
--- a/Frameworks/Adium Framework/Source/AIListBookmark.m	Sat Nov 13 12:26:57 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIListBookmark.m	Sun Nov 14 09:29:02 2010 -0600
@@ -402,7 +402,7 @@
 #pragma mark -
 - (NSString *)description
 {
-	return [NSString stringWithFormat:@"<%@:%x %@ - %@ on %@>",NSStringFromClass([self class]), self, self.formattedUID, [self chatCreationDictionary], self.account];
+	return [NSString stringWithFormat:@"<%@:%x %@ - %@ on %@ in %@>",NSStringFromClass([self class]), self, self.formattedUID, [self chatCreationDictionary], self.account, self.remoteGroups];
 }
 
 @end
diff -r 3eecd322a0bc -r 9ef68db36629 Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m	Sat Nov 13 12:26:57 2010 -0600
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m	Sun Nov 14 09:29:02 2010 -0600
@@ -213,12 +213,15 @@
 	//Clear any previous disconnection error
 	[self setLastDisconnectionError:nil];
 	
-	// Creating the fake timeline account.
+	// Creating the timeline chat's bookmark.
 	AIListBookmark *timelineBookmark = [adium.contactController existingBookmarkForChatName:self.timelineChatName
 																				  onAccount:self
 																		   chatCreationInfo:nil];
 	
-	if(!timelineBookmark) {
+	if (timelineBookmark) {
+		[timelineBookmark restoreGrouping];
+
+	} else {
 		AIChat *newTimelineChat = [adium.chatController chatWithName:self.timelineChatName
 														  identifier:nil
 														   onAccount:self 
@@ -953,6 +956,30 @@
 }
 
 /*!
+ * @brief How should deletion of a particular group be handled?
+ *
+ * If the account returns AIAccountGroupDeletionShouldRemoveContacts, then each contact will be removed from the contact list
+ * If instead AIAccountGroupDeletionShouldIgnoreContacts is returned, the group is removed from the contact list's display
+ *   but contacts are not affected.  In this case, the account should take action to avoid redisplaying the group in
+ *   the future. This is used for, for example, the Twitter timeline; a deletion is unlikely to mean the user actually
+ *   wanted to stop following all contained contacts.
+ */
+- (AIAccountGroupDeletionResponse)willDeleteGroup:(AIListGroup *)group
+{
+	if ([group.UID isEqualToString:self.timelineGroupName]) {
+		/* Hide the group by no longer loading Twitter contacts */
+		[self setPreference:[NSNumber numberWithBool:NO]
+					 forKey:TWITTER_PREFERENCE_LOAD_CONTACTS 
+					  group:TWITTER_PREFERENCE_GROUP_UPDATES];
+		return AIAccountGroupDeletionShouldIgnoreContacts;
+
+	} else {
+		return AIAccountGroupDeletionShouldRemoveContacts;
+	}
+}
+
+
+/*!
  * @brief Follow the requested contact, trigger an information pull for them.
  */
 - (void)addContact:(AIListContact *)contact toGroup:(AIListGroup *)group
diff -r 3eecd322a0bc -r 9ef68db36629 Source/AIContactController.m
--- a/Source/AIContactController.m	Sat Nov 13 12:26:57 2010 -0600
+++ b/Source/AIContactController.m	Sun Nov 14 09:29:02 2010 -0600
@@ -1506,11 +1506,36 @@
 #pragma mark Contact list editing
 - (void)removeListGroup:(AIListGroup *)group
 {
+	NSMutableSet *accountsToIgnore = nil;
+
+	for (AIAccount *account in adium.accountController.accounts) {
+		if (account.online) {
+			if ([account willDeleteGroup:group] == AIAccountGroupDeletionShouldIgnoreContacts) {
+				if (!accountsToIgnore)
+					accountsToIgnore = [NSMutableSet set];
+
+				[accountsToIgnore addObject:account];
+			}
+		}
+	}
+
 	AIContactList	*containingObject = group.contactList;
-	
+
 	//Remove all the contacts from this group
 	for (AIListContact *contact in group.containedObjects) {
-		[contact removeFromGroup:group];
+		if ([contact isKindOfClass:[AIMetaContact class]]) {
+			/* Look at each contact within the metaContact */
+			for (AIListContact *containedContact in (AIMetaContact *)contact) {
+				/* Remove it from the group if that contact's account isn't within accountstoIgnore */
+				if (![accountsToIgnore containsObject:containedContact.account])
+					[containedContact removeFromGroup:group];
+			}
+			
+		} else {
+			/* Remove it from the group if the contact's account isn't within accountstoIgnore */
+			if (![accountsToIgnore containsObject:contact.account])
+				[contact removeFromGroup:group];
+		}
 	}
 	
 	//Delete the group from all active accounts
diff -r 3eecd322a0bc -r 9ef68db36629 Source/AIContactListEditorPlugin.m
--- a/Source/AIContactListEditorPlugin.m	Sat Nov 13 12:26:57 2010 -0600
+++ b/Source/AIContactListEditorPlugin.m	Sun Nov 14 09:29:02 2010 -0600
@@ -325,6 +325,7 @@
 	
 	NSString *message = nil;
 
+	/* XXX Should allow the account to determine if the message will indicate the group is just hidden, not deleted, ‡ la Twitter */
 	if (array.count == 1) {
 		AIListObject *listObject = [[array objectAtIndex:0] objectForKey:@"ListObject"];
 		AIListObject <AIContainingObject> *containingObject = [[array objectAtIndex:0] objectForKey:@"ContainingObject"];




More information about the commits mailing list