Commit 32669001 authored by Aral Balkan's avatar Aral Balkan

Native notifications for conversation timelines and the All Friends timeline...

Native notifications for conversation timelines and the All Friends timeline now only display when necessary. Closes #179.
parent 240aa37d
......@@ -143,12 +143,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NodeDelegate
}
func applicationDidBecomeActive(notification: NSNotification)
{
// println("::: Cocoa ::: Application did become active.")
// let timeElapsed = CFAbsoluteTimeGetCurrent() - self.startTime!
// println("Took: \(timeElapsed)")
}
// func applicationDidBecomeActive(notification: NSNotification)
// {
// println("ℹ️ Application did become active.")
// // let timeElapsed = CFAbsoluteTimeGetCurrent() - self.startTime!
// // println("Took: \(timeElapsed)")
// }
//
// func applicationDidResignActive(notification: NSNotification) {
// println("ℹ️ Application did resign active.")
//
// }
func applicationWillTerminate(aNotification: NSNotification)
......
......@@ -107,7 +107,7 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
//
func handleTimelineNotification(notification:NSNotification)
{
println("Received all friends notification.")
println("Received timeline notification.")
println(notification)
if let userInfo = notification.userInfo, notificationType:String = userInfo["type"] as? String, data:AnyObject = userInfo["data"], repo = data["repo"] as? String, name = data["name"] as? String
......@@ -124,6 +124,41 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
var notificationTitle = fromPerson
//
// Don’t display the notification if the app is active and the timeline that the message
// came in for is the timeline that is currently active.
//
println("Current timeline ID: \(CurrentTimeline.id)")
let applicationIsActive:Bool = NSApplication.sharedApplication().active
let isConversationTimelineNotification = (notificationType == PulseNotification.named(PulseNotification.ConversationTimelineUpdated))
let isAllFriendsTimelineNotification = (notificationType == PulseNotification.named(PulseNotification.AllFriendsTimelineUpdated))
println("applicationIsActive: \(applicationIsActive)")
println("isConversationTimelineNotification: \(isConversationTimelineNotification)")
println("isAllFriendsTimelineNotification: \(isAllFriendsTimelineNotification)")
let appIsActiveAndTheMessageIsForTheCurrentlyActiveConversationTimeline = (applicationIsActive && isConversationTimelineNotification && fromPerson == CurrentTimeline.id)
let appIsActiveAndTheMessageIsForTheCurrentlyActiveAllFriendsTimeline = (applicationIsActive && isAllFriendsTimelineNotification && CurrentTimeline.id == "allfriends")
println("appIsActiveAndTheMessageIsForTheCurrentlyActiveConversationTimeline: \(appIsActiveAndTheMessageIsForTheCurrentlyActiveConversationTimeline)")
println("appIsActiveAndTheMessageIsForTheCurrentlyActiveAllFriendsTimeline: \(appIsActiveAndTheMessageIsForTheCurrentlyActiveAllFriendsTimeline)")
let shouldNotDisplayNativeNotification = (appIsActiveAndTheMessageIsForTheCurrentlyActiveConversationTimeline || appIsActiveAndTheMessageIsForTheCurrentlyActiveAllFriendsTimeline)
println("shouldNotDisplayNativeNotification: \(shouldNotDisplayNativeNotification)")
if shouldNotDisplayNativeNotification
{
println("App is active and the message is for the currently active timeline: not showing native notification.")
return
}
//
// Continue to display the native notification.
//
var filePathPrefix:String!
var imageTagPrefix:String!
var notificationUserInfo:[NSObject:AnyObject]!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment