forked from insanj/Unread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unread.xm
56 lines (41 loc) · 1.61 KB
/
Unread.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#import "Unread.h"
@interface CKConversationListController (Unread)
-(void)ur_gestureRecognized:(UISwipeGestureRecognizer *)sender;
@end
%hook CKConversationListController
-(id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2{
CKConversationListCell *cell = %orig;
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(ur_gestureRecognized:)];
[cell addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
return cell;
}
%new -(void)ur_gestureRecognized:(UISwipeGestureRecognizer *)sender{
if(sender.direction == UISwipeGestureRecognizerDirectionRight) {
CKConversationListCell *cell = (CKConversationListCell *) sender.view;
UITableView *table = MSHookIvar<UITableView *>(self, "_table");
CKConversation *conversation = [[[%c(CKConversationList) sharedConversationList] conversations] objectAtIndex:[table indexPathForCell:cell].row];
IMChat *chat = conversation.chat;
//IMMessage *message = [chat lastIncomingMessage];
//[chat __clearReadMessageCache];
NSLog(@"[Unread] Detected swipe on %@, marking %@...", cell, chat);
[chat _setDBUnreadCount:(1-conversation.unreadCount)];
[chat _updateUnreadCount];
[self _chatUnreadCountDidChange:chat];
//[[%c(IMChatRegistry) sharedInstance] updateUnreadCountForChat:chat];
//[[%c(IMDChatRegistry) sharedInstance] updateUnreadCountForChat:chat];
}
}
%end
/*
%hook IMDaemonController
- (void)listener:(id)arg1 setValue:(id)arg2 ofPersistentProperty:(id)arg3{
%log;
%orig();
}
- (void)listener:(id)arg1 setValue:(id)arg2 ofProperty:(id)arg3{
%log;
%orig();
}
%end
*/