mirror of
https://github.com/HackPlan/quark-shell-mac.git
synced 2026-04-29 20:16:05 +08:00
mw.notify() now supports time argument.
This commit is contained in:
@@ -37,6 +37,7 @@ mw.setAutoStart(true) // not implemented yet
|
||||
mw.notify({
|
||||
title: "Pomotodo",
|
||||
content: "Break is over!",
|
||||
time: "2038-01-19 03:14:07", // (optional) delivery date
|
||||
popupOnClick: true // popup when clicking notification
|
||||
})
|
||||
|
||||
|
||||
@@ -185,14 +185,26 @@ static const NSInteger kPreferencesDefaultHeight = 192;
|
||||
self.statusItemView.highlightedIcon = [NSImage imageNamed:@"StatusIconWhite"];
|
||||
}
|
||||
|
||||
- (void)notify:(WebScriptObject *)message
|
||||
- (void)notify:(WebScriptObject *)obj
|
||||
{
|
||||
LDYWebScriptObjectConverter *converter = [[LDYWebScriptObjectConverter alloc] initWithWebView:self.webView];
|
||||
NSDictionary *message = [converter dictionaryFromWebScriptObject:obj];
|
||||
|
||||
NSUserNotification *notification = [[NSUserNotification alloc] init];
|
||||
notification.title = [message valueForKey:@"title"];
|
||||
notification.informativeText = [message valueForKey:@"content"];
|
||||
notification.title = message[@"title"];
|
||||
notification.informativeText = message[@"content"];
|
||||
notification.deliveryDate = [NSDate date];
|
||||
notification.soundName = NSUserNotificationDefaultSoundName;
|
||||
notification.userInfo = @{@"popupOnClick": [message valueForKey:@"popupOnClick"]};
|
||||
notification.userInfo = @{@"popupOnClick": message[@"popupOnClick"]};
|
||||
|
||||
if (message[@"time"]) {
|
||||
static NSDateFormatter *formatter;
|
||||
if (!formatter) {
|
||||
formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
notification.deliveryDate = [formatter dateFromString:message[@"time"]];
|
||||
}
|
||||
|
||||
NSUserNotificationCenter *notificationCenter = [NSUserNotificationCenter defaultUserNotificationCenter];
|
||||
notificationCenter.delegate = self;
|
||||
|
||||
Reference in New Issue
Block a user