Skip to content

Commit 7edb6f7

Browse files
committed
sort nick suggestions by last highlight, last spoken, then alphabetical
1 parent c3a6de6 commit 7edb6f7

4 files changed

Lines changed: 33 additions & 18 deletions

File tree

IRCCloud/Classes/MainViewController.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,10 +1465,6 @@ - (void)handleEvent:(NSNotification *)notification {
14651465
if(e.bid == self->_buffer.bid) {
14661466
if(e.isHighlight) {
14671467
[self showMentionTip];
1468-
User *u = [[UsersDataSource sharedInstance] getUser:e.from cid:e.cid bid:e.bid];
1469-
if(u && u.lastMention < e.eid) {
1470-
u.lastMention = e.eid;
1471-
}
14721468
}
14731469
if(!e.isSelf && !_buffer.scrolledUp && !self.view.accessibilityElementsHidden) {
14741470
[[NSOperationQueue mainQueue] addOperationWithBlock:^{

IRCCloud/Classes/NetworkConnection.m

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,29 @@ -(id)init {
381381
if((!backlog || self->_resuming || [[self->_oobQueue firstObject] bid] == -1) && event.eid > self->_highestEID) {
382382
self->_highestEID = event.eid;
383383
}
384-
if(event.eid > b.last_seen_eid && [event isImportant:b.type] && (event.isHighlight || [b.type isEqualToString:@"conversation"])) {
385-
BOOL show = YES;
386-
if([[self->_servers getServer:event.cid].ignore match:event.ignoreMask] || [[[[self prefs] objectForKey:@"buffer-disableTrackUnread"] objectForKey:@(b.bid)] integerValue]) {
387-
show = NO;
384+
if([event isImportant:b.type]) {
385+
User *u = [self->_users getUser:event.from cid:event.cid bid:event.bid];
386+
if(u) {
387+
if(u.lastMessage < event.eid) {
388+
u.lastMessage = event.eid;
389+
}
390+
if(event.isHighlight) {
391+
if(u.lastMention < event.eid) {
392+
u.lastMention = event.eid;
393+
}
394+
}
388395
}
389-
390-
if(show && ![self->_notifications getNotification:event.eid bid:event.bid]) {
391-
[self->_notifications notify:[NSString stringWithFormat:@"<%@> %@",event.from,event.msg] category:event.type cid:event.cid bid:event.bid eid:event.eid];
392-
if(!backlog)
393-
[self->_notifications updateBadgeCount];
396+
if(event.eid > b.last_seen_eid && (event.isHighlight || [b.type isEqualToString:@"conversation"])) {
397+
BOOL show = YES;
398+
if([[self->_servers getServer:event.cid].ignore match:event.ignoreMask] || [[[[self prefs] objectForKey:@"buffer-disableTrackUnread"] objectForKey:@(b.bid)] integerValue]) {
399+
show = NO;
400+
}
401+
402+
if(show && ![self->_notifications getNotification:event.eid bid:event.bid]) {
403+
[self->_notifications notify:[NSString stringWithFormat:@"<%@> %@",event.from,event.msg] category:event.type cid:event.cid bid:event.bid eid:event.eid];
404+
if(!backlog)
405+
[self->_notifications updateBadgeCount];
406+
}
394407
}
395408
}
396409
if((!backlog && !self->_resuming) || event.reqId > 0) {

IRCCloud/Classes/UsersDataSource.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
int _away;
3030
NSString *_away_msg;
3131
NSTimeInterval _lastMention;
32+
NSTimeInterval _lastMessage;
3233
NSString *_ircserver;
3334
BOOL _parted;
3435
}
3536
@property int cid, bid, away;
3637
@property NSString *nick, *old_nick, *hostmask, *mode, *away_msg, *ircserver, *display_name;
3738
@property (readonly) NSString *lowercase_nick;
38-
@property NSTimeInterval lastMention;
39+
@property NSTimeInterval lastMention, lastMessage;
3940
@property BOOL parted;
4041
-(NSComparisonResult)compare:(User *)aUser;
4142
-(NSComparisonResult)compareByMentionTime:(User *)aUser;

IRCCloud/Classes/UsersDataSource.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ -(NSComparisonResult)compare:(User *)aUser {
5555
}
5656

5757
-(NSComparisonResult)compareByMentionTime:(User *)aUser {
58-
if(self->_lastMention == aUser.lastMention)
59-
return [self->_lowercase_nick localizedStandardCompare:aUser.lowercase_nick];
60-
else if(self->_lastMention > aUser.lastMention)
58+
if(self->_lastMention < aUser.lastMention) {
59+
return NSOrderedDescending;
60+
} else if(self->_lastMention > aUser.lastMention) {
6161
return NSOrderedAscending;
62-
else
62+
} else if(self->_lastMessage < aUser.lastMessage) {
6363
return NSOrderedDescending;
64+
} else if(self->_lastMessage > aUser.lastMessage) {
65+
return NSOrderedAscending;
66+
} else {
67+
return [self->_lowercase_nick localizedStandardCompare:aUser.lowercase_nick];
68+
}
6469
}
6570

6671
-(id)initWithCoder:(NSCoder *)aDecoder {

0 commit comments

Comments
 (0)