|
@@ -32,8 +32,9 @@
|
32
|
32
|
|
33
|
33
|
NSInteger itemsBeforeLinkList = 2;
|
34
|
34
|
NSInteger numberOfStaticMenuItems = 10;
|
|
35
|
+
|
35
|
36
|
#define MULTIPLIER_PM_INTERVALL_TO_SEC 60
|
36
|
|
-#define RECHECK_PM_AFTER_OPEN 10
|
|
37
|
+#define RECHECK_PM_AFTER_OPEN 7
|
37
|
38
|
#define SUBMENU_INDEX_LINK 0
|
38
|
39
|
#define SUBMENU_INDEX_COMMENTS 1
|
39
|
40
|
#define SUBMENU_INDEX_BOTH 2
|
|
@@ -58,6 +59,15 @@ NSInteger numberOfStaticMenuItems = 10;
|
58
|
59
|
lastFullName = nil;
|
59
|
60
|
[self reloadListWithOptions];
|
60
|
61
|
[self recreateRefreshTimer];
|
|
62
|
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
|
|
63
|
+}
|
|
64
|
+
|
|
65
|
+-(BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
|
|
66
|
+ return YES;
|
|
67
|
+}
|
|
68
|
+
|
|
69
|
+-(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
|
|
70
|
+ [self openUnread:nil];
|
61
|
71
|
}
|
62
|
72
|
|
63
|
73
|
-(void)recreateRefreshTimer {
|
|
@@ -71,8 +81,8 @@ NSInteger numberOfStaticMenuItems = 10;
|
71
|
81
|
[NSThread detachNewThreadSelector:@selector(readPMs:) toTarget:api withObject:self];
|
72
|
82
|
}
|
73
|
83
|
|
74
|
|
--(void)readPMsCallback:(NSNumber *)items {
|
75
|
|
- if ((items == nil) || ([items integerValue] == 0)) {
|
|
84
|
+-(void)readPMsCallback:(NSArray *)items {
|
|
85
|
+ if ((items == nil) || ([items count] < 1) || (((NSNumber *)[items objectAtIndex:0]).integerValue == 0)) {
|
76
|
86
|
[statusItem setImage:statusImage];
|
77
|
87
|
[statusItem setAlternateImage:statusHighlightImage];
|
78
|
88
|
[PMItem setHidden:TRUE];
|
|
@@ -80,9 +90,20 @@ NSInteger numberOfStaticMenuItems = 10;
|
80
|
90
|
} else {
|
81
|
91
|
[statusItem setImage:orangeredImage];
|
82
|
92
|
[statusItem setAlternateImage:orangeredHighlightImage];
|
83
|
|
- [PMItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"You've got %ld unread PMs!", @"PM message"), (long)items.integerValue]];
|
|
93
|
+ [PMItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"You've got %ld unread PMs.", @"PM message"), (long)((NSNumber *)[items objectAtIndex:0]).integerValue]];
|
84
|
94
|
[PMItem setHidden:FALSE];
|
85
|
95
|
[PMSeparator setHidden:FALSE];
|
|
96
|
+
|
|
97
|
+ if ([items count] >= 2) {
|
|
98
|
+ if (![currentState.lastNotifiedPM isEqualToString:[items objectAtIndex:1]]) {
|
|
99
|
+ currentState.lastNotifiedPM = [items objectAtIndex:1];
|
|
100
|
+ [currentState savePreferences];
|
|
101
|
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
|
|
102
|
+ notification.title = NSLocalizedString(@"New Reddit PM!", @"Notification Title");
|
|
103
|
+ notification.informativeText = [NSString stringWithFormat:NSLocalizedString(@"You've got %ld unread PMs.", nil), (long)((NSNumber *)[items objectAtIndex:0]).integerValue];
|
|
104
|
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
|
105
|
+ }
|
|
106
|
+ }
|
86
|
107
|
}
|
87
|
108
|
}
|
88
|
109
|
|