Main navigation now correctly navigating to All Friends or a conversation...

Main navigation now correctly navigating to All Friends or a conversation timeline when clicked through from a native notification. Closes #180.
parent f519fe72
......@@ -372,10 +372,14 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
// Hide the sidebar
// TODO: This should happen automatically when a non-specific friend’s timeline is being shown.
post(SidebarNotification.named(.HideSidebar), from: self)
// post(SidebarNotification.named(.HideSidebar), from: self)
let timelineNavigationRequestUserInfo = ["timeline":Timelines.sharedInstance[.AllFriends]!]
post(TimelineNavigationRequestNotification, from: nil, with: timelineNavigationRequestUserInfo)
// TODO: Refactor: there should be a single command that handles switching to a timeline with
// all necessary UI updates.
post(MainNavigationNotification.named(.ActivateAllFriendsTimelineButton))
// let timelineNavigationRequestUserInfo = ["timeline":Timelines.sharedInstance[.AllFriends]!]
// post(TimelineNavigationRequestNotification, from: nil, with: timelineNavigationRequestUserInfo)
//
// If there is a reply, send it.
......@@ -401,8 +405,9 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
// TODO: This should happen automatically with a request to show a specific friend’s timeline.
// Very hacky and time-based — could fail. The whole listen of loading friends must be
// refactored into a friends model class.
post(SidebarNotification.named(.ShowSidebar), from: self)
// post(SidebarNotification.named(.ShowSidebar), from: self)
post(MainNavigationNotification.named(.ActivateConversationsTimelineButton))
// TODO: Refactor this. Copied form SidebarViewController:
// TODO: This needs to be done at the start and kept in a friends model. (And updated on every friend add.)
......
......@@ -16,6 +16,8 @@ import Cocoa
public enum MainNavigationNotification:String
{
case ActivatePublicTimelineButton = "ActivatePublicTimelineButton"
case ActivateConversationsTimelineButton = "ActivateConversationsTimelineButton"
case ActivateAllFriendsTimelineButton = "ActivateAllFriendsTimelineButton"
static func named(notification:MainNavigationNotification) -> String
{
......@@ -41,6 +43,8 @@ class VerticalTabBarViewController: NSViewController
// Notification handlers
var activatePublicTimelineButtonHandler: NotificationHandler?
var activateConversationsTimelineButtonHandler: NotificationHandler?
var activateAllFriendsTimelineButtonHandler: NotificationHandler?
// MARK: View lifecycle
......@@ -86,6 +90,22 @@ class VerticalTabBarViewController: NSViewController
self.simulateButtonPress(self.publicButton)
}
activateConversationsTimelineButtonHandler = activateConversationsTimelineButtonHandler ?? handle(MainNavigationNotification.named(.ActivateConversationsTimelineButton))
{
/* as */ notification in
self.simulateButtonPress(self.conversationsButton)
}
activateAllFriendsTimelineButtonHandler = activateAllFriendsTimelineButtonHandler ?? handle(MainNavigationNotification.named(.ActivateAllFriendsTimelineButton))
{
/* as */ notification in
self.simulateButtonPress(self.allFriendsButton)
}
}
......
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