For the dock icon, don't keep track of what chats have content; just ask the chat controller what the count is. This way, we can avoid flapping if we're only counting mentions for group chats.
authorZachary West <zacw@adiumx.com>
Sat, 04 Apr 2009 16:06:02 +0000
changeset 1521 9bb0830ecc18
parent 1520 a4c781f5c56f
child 1522 40337716e183
For the dock icon, don't keep track of what chats have content; just ask the chat controller what the count is. This way, we can avoid flapping if we're only counting mentions for group chats.
Source/AIDockUnviewedContentPlugin.h
Source/AIDockUnviewedContentPlugin.m
--- a/Source/AIDockUnviewedContentPlugin.h	Sat Apr 04 15:44:32 2009 +0000
+++ b/Source/AIDockUnviewedContentPlugin.h	Sat Apr 04 16:06:02 2009 +0000
@@ -18,9 +18,7 @@
 #import <Adium/AIChatControllerProtocol.h>
 
 @interface AIDockUnviewedContentPlugin : AIPlugin <AIChatObserver> {
-    NSMutableArray		*unviewedObjectsArray;
     BOOL				unviewedState;
-	
 	BOOL				animateDockIcon;
 }
 
--- a/Source/AIDockUnviewedContentPlugin.m	Sat Apr 04 15:44:32 2009 +0000
+++ b/Source/AIDockUnviewedContentPlugin.m	Sat Apr 04 16:06:02 2009 +0000
@@ -40,7 +40,6 @@
 - (void)installPlugin
 {
     //init
-    unviewedObjectsArray = [[NSMutableArray alloc] init];
     unviewedState = NO;
 
 	//Register our default preferences
@@ -99,8 +98,7 @@
 - (NSSet *)updateChat:(AIChat *)inChat keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
 {
     if ([inModifiedKeys containsObject:KEY_UNVIEWED_CONTENT]) {
-		
-        if ([inChat unviewedContentCount]) {
+        if (adium.chatController.unviewedContentCount) {
             //If this is the first contact with unviewed content, animate the dock
             if (!unviewedState) {
 				NSString *iconState;
@@ -115,18 +113,9 @@
                 [adium.dockController setIconStateNamed:iconState];
                 unviewedState = YES;
             }
-
-            [unviewedObjectsArray addObject:inChat];
-
-        } else {
-            if ([unviewedObjectsArray containsObjectIdenticalTo:inChat]) {
-                [unviewedObjectsArray removeObject:inChat];
-
-                //If there are no more contacts with unviewed content, stop animating the dock
-                if ([unviewedObjectsArray count] == 0 && unviewedState) {
-					[self removeAlert];
-                }
-            }
+        } else if (unviewedState) {
+			//If there are no more contacts with unviewed content, stop animating the dock
+			[self removeAlert];
         }
     }
 
@@ -150,15 +139,9 @@
  */
 - (void)chatWillClose:(NSNotification *)notification
 {
-	AIChat	*inChat = [notification object];
-
-	if ([unviewedObjectsArray containsObjectIdenticalTo:inChat]) {
-		[unviewedObjectsArray removeObject:inChat];
-		
+	if (!adium.chatController.unviewedContentCount && unviewedState) {
 		//If there are no more contacts with unviewed content, stop animating the dock
-		if ([unviewedObjectsArray count] == 0 && unviewedState) {
-			[self removeAlert];
-		}
+		[self removeAlert];
 	}
 }