Ind.ie is now Small Technology Foundation.
Commit a70c5152 authored by Aral Balkan's avatar Aral Balkan

Notifications are working for private timelines.

parent 97953298
......@@ -25,6 +25,21 @@ func makeAccessibilityAnnouncement(message:String)
NSAccessibilityPostNotificationWithUserInfo(NSApp.mainWindow, NSAccessibilityAnnouncementRequestedNotification, [NSAccessibilityAnnouncementKey: message, NSAccessibilityPriorityKey: NSAccessibilityPriorityLevel.High.rawValue])
}
//
// MARK: NSTableView
//
//
// Seriously, how often is it that all you want to do is to select a darn row? :)
//
extension NSTableView
{
func selectRow(row:Int)
{
self.selectRowIndexes(NSIndexSet(index: row), byExtendingSelection: false)
}
}
//
// MARK: - Date
//
......
This diff is collapsed.
......@@ -11,6 +11,7 @@
import Cocoa
// MARK: - Class
class SidebarViewController:NSViewController
......@@ -24,7 +25,9 @@ class SidebarViewController:NSViewController
@IBOutlet weak var tableViewScrollView: NSScrollView!
var data: [Timeline]?
var timelineNavigationRequestHandler:NotificationHandler!
var data: [Timeline]!
// MARK: - View lifecycle
......@@ -67,7 +70,7 @@ class SidebarViewController:NSViewController
let timeline = Timeline(id: accountHandle, title: displayName, path: timelinePath, relativeWebPrefix: "/specific-friends/\(accountHandle)/to")
timeline.participants = [accountHandle]
self.data!.append(timeline)
self.data.append(timeline)
}
else
{
......@@ -97,7 +100,37 @@ class SidebarViewController:NSViewController
let nib = NSNib(nibNamed: "ConversationCellView", bundle: NSBundle.mainBundle())
tableView.registerNib(nib!, forIdentifier: "ConversationCellView")
}
//
// Notification handlers
//
timelineNavigationRequestHandler = timelineNavigationRequestHandler ?? handle(TimelineNavigationRequestNotification)
{
/* as */ notification in
println("Sidebar timeline navigation request handler. Checking if this is a conversation timeline…")
println(notification)
if let userInfo = notification.userInfo, isConversationTimeline:Bool = userInfo["isConversationTimeline"] as? Bool, timelineToShow:Timeline = userInfo["timeline"] as? Timeline
{
println("ℹ️ About to show conversation timeline: \(timelineToShow)")
for var i = 0; i < self.data!.count; i++
{
let timelineToCheck = self.data[i]
if timelineToCheck.id == timelineToShow.id
{
// This is the timeline we have to show. Select its index.
println("Found the timeline — selecting row!")
self.tableView.selectRow(i)
}
}
}
}
} /* end of viewDidLoad */
override func viewWillAppear()
{
......@@ -186,7 +219,9 @@ extension SidebarViewController:NSTableViewDataSource, NSTableViewDelegate
func tableView(tableView: NSTableView, shouldSelectRow row: Int) -> Bool
{
if data!.count == 0
println("ℹ️ Sidebar asked if row \(row) should be selected.")
if data.count == 0
{
println("ℹ️ Asked if first row should be selected — friends haven’t loaded yet, so no.")
return false
......
true
\ No newline at end of file
false
\ No newline at end of file
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