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

Adding a new friend now updates the entry in the friends sidebar on next...

Adding a new friend now updates the entry in the friends sidebar on next viewing (partial progress towards #98). New friends whose profile pics haven’t synced yet not get a placeholder image in the friends list. Closes #117.
parent 03f1c740
......@@ -90,6 +90,8 @@
A7A14C6E1A83A9C200586EAD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A7A14C701A83A9C200586EAD /* InfoPlist.strings */; };
A7A14C731A83D7DC00586EAD /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A7A14C751A83D7DC00586EAD /* Localizable.strings */; };
A7A14C791A83FBBF00586EAD /* NSString+Matcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A14C781A83FBBF00586EAD /* NSString+Matcher.m */; };
A7A9C1711B78AA780046B1C5 /* friend-placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = A7A9C16F1B78AA780046B1C5 /* friend-placeholder.png */; };
A7A9C1721B78AA780046B1C5 /* friend-placeholder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A7A9C1701B78AA780046B1C5 /* friend-placeholder@2x.png */; };
A7BCCF761B15E1FE00A29D15 /* TeleportationAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7BCCF751B15E1FE00A29D15 /* TeleportationAPI.swift */; };
A7C597B71AEDEDAB008CF983 /* TimelineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7C597B61AEDEDAB008CF983 /* TimelineModel.swift */; };
A7C597B91AEFE542008CF983 /* SidebarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7C597B81AEFE542008CF983 /* SidebarViewController.swift */; };
......@@ -254,6 +256,8 @@
A7A14C741A83D7DC00586EAD /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
A7A14C771A83FBBF00586EAD /* NSString+Matcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Matcher.h"; sourceTree = "<group>"; };
A7A14C781A83FBBF00586EAD /* NSString+Matcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Matcher.m"; sourceTree = "<group>"; };
A7A9C16F1B78AA780046B1C5 /* friend-placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend-placeholder.png"; sourceTree = "<group>"; };
A7A9C1701B78AA780046B1C5 /* friend-placeholder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "friend-placeholder@2x.png"; sourceTree = "<group>"; };
A7BCCF751B15E1FE00A29D15 /* TeleportationAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TeleportationAPI.swift; sourceTree = "<group>"; };
A7C597B61AEDEDAB008CF983 /* TimelineModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimelineModel.swift; sourceTree = "<group>"; };
A7C597B81AEFE542008CF983 /* SidebarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SidebarViewController.swift; sourceTree = "<group>"; };
......@@ -702,6 +706,8 @@
A7E7D7BC1A616B2A003501C1 /* Assets */ = {
isa = PBXGroup;
children = (
A7A9C16F1B78AA780046B1C5 /* friend-placeholder.png */,
A7A9C1701B78AA780046B1C5 /* friend-placeholder@2x.png */,
A7499B161AB4B47000B85BFB /* balloon_512x512@2x.png */,
A79C8BAC1A8D5F2800F1948A /* balloon@2x.png */,
A7E7D7BD1A616B31003501C1 /* Images */,
......@@ -906,6 +912,7 @@
A79C8BAD1A8D5F2800F1948A /* balloon@2x.png in Resources */,
A7A14C731A83D7DC00586EAD /* Localizable.strings in Resources */,
A7296C191AA337F900D64CDA /* Private-Template@2x.png in Resources */,
A7A9C1711B78AA780046B1C5 /* friend-placeholder.png in Resources */,
A7E7D7D11A616B3E003501C1 /* sidebar.png in Resources */,
A7E7D7CE1A616B3E003501C1 /* transparent.png in Resources */,
A7C597BD1AF0B30B008CF983 /* ConversationCellView.xib in Resources */,
......@@ -927,6 +934,7 @@
A74C9EF11A6688EB0083B288 /* Images.xcassets in Resources */,
A7E7D7D01A616B3E003501C1 /* conversations.png in Resources */,
A79EDA861AA4FDC400125690 /* last-panel-green-corner.png in Resources */,
A7A9C1721B78AA780046B1C5 /* friend-placeholder@2x.png in Resources */,
A7A14C6E1A83A9C200586EAD /* InfoPlist.strings in Resources */,
A7E7D7CD1A616B3E003501C1 /* content-white.png in Resources */,
A7E7D7CA1A616B3E003501C1 /* bottomRightCornerIndicatorTemplate@2x.png in Resources */,
......
......@@ -1132,7 +1132,7 @@
</subviews>
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="b4B-VU-vU0">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="b4B-VU-vU0">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner"/>
......@@ -13,7 +13,7 @@
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="WuB-MT-aL4" userLabel="Conversation Image View">
<rect key="frame" x="5" y="4" width="48" height="48"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="C5g-RB-t2Z"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="friend-placeholder" id="C5g-RB-t2Z"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8n3-fh-BXx" userLabel="Conversation name">
<rect key="frame" x="59" y="29" width="299" height="17"/>
......@@ -40,4 +40,7 @@
<point key="canvasLocation" x="18.5" y="210"/>
</customView>
</objects>
<resources>
<image name="friend-placeholder" width="48" height="48"/>
</resources>
</document>
......@@ -42,66 +42,9 @@ class SidebarViewController:NSViewController
data = []
// Get the friends data and create the data source
Node.sharedInstance.call(remoteFunction.named(.getFriends), withArguments: nil)
{
/* and handle */ response in
if let friends = response["friends"].array
{
println("ℹ️ Got list of friends.\n")
for friend in friends
{
if let key = friend["key"].string
{
let components = (key as NSString).componentsSeparatedByString("_")
if components.count == 2
{
let displayName = components[0] as! String
let accountHandle = components[1] as! String
let timelinePath = "2. Specific friends/\(accountHandle)/to"
println("ℹ️ About to create friend entry for \(displayName) (\(accountHandle)).\n")
println("ℹ️ Timeline path: \(timelinePath)")
let timeline = Timeline(id: accountHandle, title: displayName, path: timelinePath, relativeWebPrefix: "/specific-friends/\(accountHandle)/to")
timeline.participants = [accountHandle]
self.data.append(timeline)
}
else
{
println("⚠️ Could not get display name and account handle from friend \(friend).\n")
}
}
else
{
println("⚠️ Could not get key from friend \(friend).\n")
}
}
// Ask tableview to refresh now that we have the data.
self.tableView.reloadData()
}
else
{
println("⚠️ Could not get list of friends.\n")
}
}
// Dummy data for now.
// data = [
// Timeline(id: "laura-\(ISO8601DateString())", title: "Laura Kalbag", path: "DUMMY", relativeWebPrefix: "DUMMY"),
// Timeline(id: "jo-\(ISO8601DateString())", title: "Jo Porter", path: "DUMMY", relativeWebPrefix: "DUMMY")
// ]
let nib = NSNib(nibNamed: "ConversationCellView", bundle: NSBundle.mainBundle())
tableView.registerNib(nib!, forIdentifier: "ConversationCellView")
//
// Notification handlers
//
......@@ -136,9 +79,7 @@ class SidebarViewController:NSViewController
{
createConstraints()
// TODO: Select the last selected, not just the first
tableView.selectRowIndexes(NSIndexSet(index: 0), byExtendingSelection: false)
tableView(tableView, shouldSelectRow: 0)
updateFriendsList()
}
override func viewWillDisappear()
......@@ -165,8 +106,71 @@ class SidebarViewController:NSViewController
tableViewScrollView.width <= 300
}
}
func updateFriendsList()
{
data = []
// Get the friends data and create the data source
Node.sharedInstance.call(remoteFunction.named(.getFriends), withArguments: nil)
{
/* and handle */ response in
if let friends = response["friends"].array
{
println("ℹ️ Got list of friends.\n")
println(friends)
for friend in friends
{
if let key = friend["key"].string
{
let components = (key as NSString).componentsSeparatedByString("_")
if components.count == 2
{
let displayName = components[0] as! String
let accountHandle = components[1] as! String
let timelinePath = "2. Specific friends/\(accountHandle)/to"
println("ℹ️ About to create friend entry for \(displayName) (\(accountHandle)).\n")
println("ℹ️ Timeline path: \(timelinePath)")
let timeline = Timeline(id: accountHandle, title: displayName, path: timelinePath, relativeWebPrefix: "/specific-friends/\(accountHandle)/to")
timeline.participants = [accountHandle]
self.data.append(timeline)
}
else
{
println("⚠️ Could not get display name and account handle from friend \(friend).\n")
}
}
else
{
println("⚠️ Could not get key from friend \(friend).\n")
}
}
// Ask tableview to refresh now that we have the data.
self.tableView.reloadData()
// TODO: Select the last selected, not just the first
self.tableView.selectRowIndexes(NSIndexSet(index: 0), byExtendingSelection: false)
self.tableView(self.tableView, shouldSelectRow: 0)
}
else
{
println("⚠️ Could not get list of friends.\n")
}
}
}
}
// MARK: - Extension
extension SidebarViewController:NSTableViewDataSource, NSTableViewDelegate
{
......@@ -199,11 +203,14 @@ extension SidebarViewController:NSTableViewDataSource, NSTableViewDelegate
// Get the photo
let photoPath = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/3. All your friends/from/\(timeline.participants![0])/about/me.jpg")
println("Photo path: \(photoPath)")
// println("Photo path: \(photoPath)")
let photo = NSImage(contentsOfFile: photoPath)
let photo:NSImage? = NSImage(contentsOfFile: photoPath)
cell.conversationImage.image = photo
if let photo = photo
{
cell.conversationImage.image = photo
}
// Mask the conversation image with a circular mask.
if let conversationImageLayer = cell.conversationImage.layer
......
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