Examine any open chats when a bookmark is initialized to set its defaults. Fixes #12771.
authorZachary West <zacw@adium.im>
Wed Oct 28 20:48:18 2009 -0400 (2009-10-28)
changeset 28042b6a6cd8c92f
parent 2803 4eb14b524627
child 2805 9b757472094b
Examine any open chats when a bookmark is initialized to set its defaults. Fixes #12771.

This was occurring since the "saved chats" were opened/created before the AIListBookmark.
Frameworks/Adium Framework/Source/AIListBookmark.m
     1.1 --- a/Frameworks/Adium Framework/Source/AIListBookmark.m	Wed Oct 28 20:35:26 2009 -0400
     1.2 +++ b/Frameworks/Adium Framework/Source/AIListBookmark.m	Wed Oct 28 20:48:18 2009 -0400
     1.3 @@ -28,6 +28,8 @@
     1.4  - (BOOL)chatIsOurs:(AIChat *)chat;
     1.5  - (AIChat *)openChatWithoutActivating;
     1.6  - (void)restoreGrouping;
     1.7 +
     1.8 +- (void)claimChatIfOurs:(AIChat *)chat;
     1.9  @end
    1.10  
    1.11  @implementation AIListBookmark
    1.12 @@ -58,6 +60,11 @@
    1.13  										 name:Chat_DidOpen
    1.14  									   object:nil];
    1.15  		
    1.16 +		// Scan all open chats to claim them, if we loaded after they were available.
    1.17 +		for (AIChat *chat in adium.interfaceController.openChats) {
    1.18 +			[self claimChatIfOurs:chat];
    1.19 +		}
    1.20 +		
    1.21  		AILog(@"Created %@", self);
    1.22  		
    1.23  	}
    1.24 @@ -293,8 +300,19 @@
    1.25  - (void)chatDidOpen:(NSNotification *)notification
    1.26  {
    1.27  	AIChat *chat = [notification object];
    1.28 -	
    1.29 -	// If this is our chat, we should set it up appropriately.
    1.30 +
    1.31 +	[self claimChatIfOurs:chat];
    1.32 +}
    1.33 +
    1.34 +/*!
    1.35 + * @brief Claim a chat
    1.36 + *
    1.37 + * Has no effect if the chat is not ours.
    1.38 + *
    1.39 + * Establishes any defaults we wish for our chats to have. Called when they are created.
    1.40 + */
    1.41 +- (void)claimChatIfOurs:(AIChat *)chat
    1.42 +{
    1.43  	if ([self chatIsOurs:chat]) {
    1.44  		chat.displayName = self.displayName;
    1.45  	}