adium 5456:96a70c52c6eb: Fix the highlights to not match the sen...
commits at adium.im
commits at adium.im
Thu May 2 00:30:10 UTC 2013
details: http://hg.adium.im/adium/rev/96a70c52c6eb
revision: 5456:96a70c52c6eb
branch: adium-1.6
author: Thijs Alkemade <me at thijsalkema.de>
date: Thu May 02 02:30:00 2013 +0200
Fix the highlights to not match the senders name, but your own.
diffs (73 lines):
diff -r 315d12906aa9 -r 96a70c52c6eb Frameworks/Adium Framework/Source/AIGroupChat.h
--- a/Frameworks/Adium Framework/Source/AIGroupChat.h Thu May 02 02:20:21 2013 +0200
+++ b/Frameworks/Adium Framework/Source/AIGroupChat.h Thu May 02 02:30:00 2013 +0200
@@ -46,7 +46,7 @@
- (void)setContact:(AIListContact *)contact forNick:(NSString *)nick;
- (void)changeNick:(NSString *)from to:(NSString *)to;
- (void)removeSavedValuesForNick:(NSString *)nick;
-- (NSArray *)nicksForContact:(AIListContact *)contact;
+- (NSArray *)nicksForContact:(AIListObject *)contact;
- (void)addParticipatingNick:(NSString *)inObject notify:(BOOL)notify;
- (void)addParticipatingNicks:(NSArray *)inObjects notify:(BOOL)notify;
diff -r 315d12906aa9 -r 96a70c52c6eb Frameworks/Adium Framework/Source/AIGroupChat.m
--- a/Frameworks/Adium Framework/Source/AIGroupChat.m Thu May 02 02:20:21 2013 +0200
+++ b/Frameworks/Adium Framework/Source/AIGroupChat.m Thu May 02 02:30:00 2013 +0200
@@ -314,7 +314,7 @@
[participatingNicksContacts removeObjectForKey:nick];
}
-- (NSArray *)nicksForContact:(AIListContact *)contact
+- (NSArray *)nicksForContact:(AIListObject *)contact
{
NSMutableArray *nicks = [NSMutableArray array];
diff -r 315d12906aa9 -r 96a70c52c6eb Source/AIMentionEventPlugin.m
--- a/Source/AIMentionEventPlugin.m Thu May 02 02:20:21 2013 +0200
+++ b/Source/AIMentionEventPlugin.m Thu May 02 02:30:00 2013 +0200
@@ -67,23 +67,25 @@
return inAttributedString;
AIContentMessage *message = (AIContentMessage *)context;
- AIChat *chat = message.chat;
- if(!chat.isGroupChat || message.isOutgoing)
+ if(!message.chat.isGroupChat || message.isOutgoing)
return inAttributedString;
-
+
+ AIGroupChat *chat = (AIGroupChat *)message.chat;
NSString *messageString = [inAttributedString string];
-
AIAccount *account = (AIAccount *)message.destination;
-
+
// XXX When we fix user lists to contain accounts, fix this too.
- NSArray *myPredicates = [NSArray arrayWithObjects:
- [NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [account.UID stringByEscapingForRegexp]]],
- [NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [account.displayName stringByEscapingForRegexp]]],
- /* can be nil */ message.sourceNick ? [NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [message.sourceNick stringByEscapingForRegexp]]] : nil,
- nil];
+ NSMutableArray *myPredicates = [NSMutableArray arrayWithObjects:
+ [NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [account.UID stringByEscapingForRegexp]]],
+ [NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [account.displayName stringByEscapingForRegexp]]],
+ nil];
- myPredicates = [myPredicates arrayByAddingObjectsFromArray:self.mentionPredicates];
+ for (NSString *nick in [chat nicksForContact:account]) {
+ [myPredicates addObject:[NSPredicate predicateWithFormat:@"SELF MATCHES[cd] %@", [NSString stringWithFormat:@".*\\b%@\\b.*", [nick stringByEscapingForRegexp]]]];
+ }
+
+ [myPredicates addObjectsFromArray:self.mentionPredicates];
for(NSPredicate *predicate in myPredicates) {
if([predicate evaluateWithObject:messageString]) {
@@ -94,7 +96,7 @@
break;
}
}
-
+
return inAttributedString;
}
More information about the commits
mailing list