Commit 8d414d76 authored by Aral Balkan's avatar Aral Balkan

Refactored the SetupData model to the Person Model. Integrated the new all...

Refactored the SetupData model to the Person Model. Integrated the new all friends timeline from Heartbeat Node.
parent be165bdd
This diff is collapsed.
......@@ -103,11 +103,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NodeDelegate
// interface. Otherwise, we’ll only start the web socket connection in
// preparation for showing the setup process.
//
let wasAbleToLoadSetupData = SetupData.load()
let wasAbleToLoadCurrentPerson = CurrentPerson.sharedInstance.load()
ApplicationModel.sharedInstance.isInSetupProcess = !wasAbleToLoadSetupData
ApplicationModel.sharedInstance.isInSetupProcess = !wasAbleToLoadCurrentPerson
self.node.start(startAllServicesAtLaunch: wasAbleToLoadSetupData)
self.node.start(startAllServicesAtLaunch: wasAbleToLoadCurrentPerson)
//
// Listen for when the initial animated Balloon preloader is done.
......
......@@ -42,7 +42,7 @@ class IndieURLSchemeHandler:NSObject
println("Received command to friend \(personToFriend)…")
// TODO: this so that the Send Friendship link is not displayed for the person themselves and then remove this.
if personToFriend == SetupData.accountHandle
if personToFriend == CurrentPerson.sharedInstance.accountHandle
{
let confirmationSheet = NSAlert()
confirmationSheet.messageText = "You cannot friend yourself."
......
......@@ -363,7 +363,7 @@ class MainInterfaceSplitViewController: NSSplitViewController
println("ℹ️ About to post the new person message. (\(self))\n")
// Create the message, persist it, and notify the timeline to show it.
let messageString = "<p>Hey everyone, \(SetupData.displayName!) just joined Ind.ie! <a href='indie://friend/\(SetupData.accountHandle!)'>Send friendship request.</a></p>"
let messageString = "<p>Hey everyone, \(CurrentPerson.sharedInstance.displayName!) just joined Ind.ie! <a href='indie://friend/\(CurrentPerson.sharedInstance.accountHandle!)'>Send friendship request.</a></p>"
let messageData = messageString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
let messageAttributedString = NSAttributedString(HTML: messageData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding], documentAttributes: nil)!
......
......@@ -59,7 +59,7 @@ class MainWindowController: NSWindowController
{
/* with */ notification in
let profileImage:NSImage = SetupData.photo
let profileImage:NSImage = CurrentPerson.sharedInstance.photo
// BUTT UGLY, DANGEROUS CODE — REFACTOR!!!
......
......@@ -129,7 +129,7 @@ class MessageSplitViewController: NSSplitViewController
indexHTML = indexHTML.stringByReplacingOccurrencesOfString("<p><br></p>", withString: "")
// Change objects to links
indexHTML = indexHTML.stringByReplacingOccurrencesOfString("<object data=\"", withString: "<a href=\"download://\(SetupData.accountHandle!)")
indexHTML = indexHTML.stringByReplacingOccurrencesOfString("<object data=\"", withString: "<a href=\"download://\(CurrentPerson.sharedInstance.accountHandle!)")
indexHTML = indexHTML.stringByReplacingOccurrencesOfString("</object>", withString: "</a>")
//
......
......@@ -142,7 +142,7 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
responsePlaceholder = "\(responsePlaceholder) to \(fromPerson) privately."
imageTagPrefix = "<img src=\"/specific-friends/\(SetupData.accountHandle)/to/"
imageTagPrefix = "<img src=\"/specific-friends/\(CurrentPerson.sharedInstance.accountHandle)/to/"
notificationUserInfo = ["type": NativeNotificationType.named(.ConversationTimelineMessage)]
}
......@@ -223,7 +223,7 @@ public class NativeNotification: NSObject, NSUserNotificationCenterDelegate
// This is just so ugly that I am ashamed of it before I’ve even written it and yet
// it’s almost midnight, so…
// TODO: Move this method into its own singleton or something.
let sendersProfileImageWithRoundedCorners = SetupData.roundCorners(sendersProfileImage, width: sendersProfileImage.size.width, height: sendersProfileImage.size.height)
let sendersProfileImageWithRoundedCorners = CurrentPerson.sharedInstance.roundCorners(sendersProfileImage, width: sendersProfileImage.size.width, height: sendersProfileImage.size.height)
n.setValue(sendersProfileImageWithRoundedCorners, forKey: "_identityImage")
n.setValue(false, forKey: "_identityImageHasBorder")
......
......@@ -178,7 +178,7 @@ public class Node: NSObject, WebSocketDelegate
let applicationModel = ApplicationModel.sharedInstance
self.nodeTask!.launchPath = applicationModel.pathToNode
self.nodeTask!.arguments = [applicationModel.pathToNodeApp, NSHomeDirectory(), (startAllServicesAtLaunch ? "startAllServices":"justStartTheWebSocket"), "\(processIdentifier)", applicationModel.buildType, applicationModel.waystoneURL, applicationModel.invitationsURL, SetupData.accountHandle ?? ""]
self.nodeTask!.arguments = [applicationModel.pathToNodeApp, NSHomeDirectory(), (startAllServicesAtLaunch ? "startAllServices":"justStartTheWebSocket"), "\(processIdentifier)", applicationModel.buildType, applicationModel.waystoneURL, applicationModel.invitationsURL, CurrentPerson.sharedInstance.accountHandle ?? ""]
self.nodeTask!.standardOutput = NSPipe()
//
......
......@@ -16,13 +16,13 @@ import Collaboration
//
// TODO: rename this to the Person Model Notification.
//
public enum SetupDataNotification:String
public enum CurrentPersonNotification:String
{
// Fired when the profile image is updated by the user.
case ProfileImageDidChange = "ProfileImageDidChange"
// Static convenience function so consuming code can have clearer intent
public static func named(notification:SetupDataNotification) -> String
// convenience function so consuming code can have clearer intent
public static func named(notification:CurrentPersonNotification) -> String
{
return notification.rawValue
}
......@@ -30,31 +30,26 @@ public enum SetupDataNotification:String
//
// TODO: rename this to the Person Model.
// Represents a person on Heartbeat.
//
struct SetupData
class PersonModel
{
static var accountHandle:String?
static var displayName:String?
static var bio:String?
static var invitationCode:String?
static var photoImage:NSImage?
var accountHandle:String?
var displayName:String?
var bio:String?
var invitationCode:String?
var photoImage:NSImage?
// TODO: This needs to be an array of device IDs for when we start supporting multiple devices.
static var deviceID:String?
var deviceID:String?
static var photo:NSImage
var photo:NSImage
{
get
{
if photoImage == nil
{
//
// Get the system account image for the user as the default image and display it.
// (Courtesy: http://stackoverflow.com/a/7306038/253485)
//
let identity:CBIdentity = CBIdentity(name: NSUserName(), authority: CBIdentityAuthority.defaultIdentityAuthority())
photoImage = identity.image()
photoImage = NSImage(named:"friend-placeholder")
}
return photoImage!
}
......@@ -62,35 +57,22 @@ struct SetupData
set(image)
{
photoImage = image
// Notify anyone who cares that the image has changed.
post(SetupDataNotification.named(.ProfileImageDidChange))
}
}
static var photoWithRoundedCorners:NSImage
var photoWithRoundedCorners:NSImage
{
get
{
let photo = self.photo
let photoWithRoundedCorners = SetupData.roundCorners(photo, width: photo.size.width, height: photo.size.height)
let photoWithRoundedCorners = roundCorners(photo, width: photo.size.width, height: photo.size.height)
return photoWithRoundedCorners
}
}
static var photoPath:String
{
get
{
let publicFolder:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/5. Everyone (public)/to/about/")
let photoPath = publicFolder.stringByAppendingPathComponent("me.jpg")
return photoPath
}
}
static var json:JSON
var json:JSON
{
get
{
......@@ -108,7 +90,8 @@ struct SetupData
}
}
static var publicTextualDataDictionary:[String:String]
var publicTextualDataDictionary:[String:String]
{
get
{
......@@ -123,7 +106,98 @@ struct SetupData
}
}
static func load() -> Bool
//
// MARK: - Round corners of profile image
//
// Courtesy: Paul Miller et. al.
// http://stackoverflow.com/a/27157566
//
func roundCorners(image: NSImage, width: CGFloat = 192, height: CGFloat = 192) -> NSImage {
let xRad = width / 2
let yRad = height / 2
let existing = image
let esize = existing.size
let newSize = NSMakeSize(esize.height, esize.width)
let composedImage = NSImage(size: newSize)
composedImage.lockFocus()
let ctx = NSGraphicsContext.currentContext()
ctx?.imageInterpolation = NSImageInterpolation.High
let imageFrame = NSRect(x: 0, y: 0, width: width, height: height)
let clipPath = NSBezierPath(roundedRect: imageFrame, xRadius: xRad, yRadius: yRad)
clipPath.windingRule = NSWindingRule.EvenOddWindingRule
clipPath.addClip()
let rect = NSRect(x: 0, y: 0, width: newSize.width, height: newSize.height)
image.drawAtPoint(NSZeroPoint, fromRect: rect, operation: NSCompositingOperation.CompositeSourceOver, fraction: 1)
composedImage.unlockFocus()
return composedImage
}
}
//
// Specialised model for the person currently using this Heartbeat instance.
//
// Singleton.
//
class CurrentPerson : PersonModel
{
//
// MARK: - Singleton access: sharedInstance
//
class var sharedInstance:CurrentPerson
{
struct Static
{
static let instance:CurrentPerson = CurrentPerson()
}
return Static.instance
}
override var photo:NSImage
{
get
{
if photoImage == nil
{
//
// Get the system account image for the user as the default image and display it.
// (Courtesy: http://stackoverflow.com/a/7306038/253485)
//
let identity:CBIdentity = CBIdentity(name: NSUserName(), authority: CBIdentityAuthority.defaultIdentityAuthority())
photoImage = identity.image()
}
return super.photo
}
set(image)
{
super.photo = image
post(CurrentPersonNotification.named(.ProfileImageDidChange))
}
}
var photoPath:String
{
get
{
let publicFolder:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/5. Everyone (public)/to/about/")
let photoPath = publicFolder.stringByAppendingPathComponent("me.jpg")
return photoPath
}
}
func load() -> Bool
{
//
// Try to load the account details. If setup is complete, the details
......@@ -150,51 +224,21 @@ struct SetupData
println("✅ Loaded profile details. (\(self))\n")
// Save the data
SetupData.json = JSON(data: accountDetailsData!)
json = JSON(data: accountDetailsData!)
// Load and save the account image in the Setup data model.
if let accountImage = NSImage(contentsOfFile: accountImageFile)
{
SetupData.photo = accountImage
photo = accountImage
}
else
{
println("Warning: could not load the profile image: \(accountImageFile) (\(self))")
}
return true
}
}
//
// MARK: - Round corners of profile image
//
// Courtesy: Paul Miller et. al.
// http://stackoverflow.com/a/27157566
//
static func roundCorners(image: NSImage, width: CGFloat = 192, height: CGFloat = 192) -> NSImage {
let xRad = width / 2
let yRad = height / 2
let existing = image
let esize = existing.size
let newSize = NSMakeSize(esize.height, esize.width)
let composedImage = NSImage(size: newSize)
composedImage.lockFocus()
let ctx = NSGraphicsContext.currentContext()
ctx?.imageInterpolation = NSImageInterpolation.High
let imageFrame = NSRect(x: 0, y: 0, width: width, height: height)
let clipPath = NSBezierPath(roundedRect: imageFrame, xRadius: xRad, yRadius: yRad)
clipPath.windingRule = NSWindingRule.EvenOddWindingRule
clipPath.addClip()
let rect = NSRect(x: 0, y: 0, width: newSize.width, height: newSize.height)
image.drawAtPoint(NSZeroPoint, fromRect: rect, operation: NSCompositingOperation.CompositeSourceOver, fraction: 1)
composedImage.unlockFocus()
return composedImage
}
}
......@@ -168,7 +168,7 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
// Display the account image (either the default one for the
// person’s Mac account or the one they specifically chose.)
displayImage(SetupData.photo)
displayImage(CurrentPerson.sharedInstance.photo)
//
// Listen for notifications from the control panel.
......@@ -609,7 +609,7 @@ class ProfileImageComponentViewController: NSViewController, NSComboBoxDataSourc
post(ProfileImageComponentNotification.named(.ProfileImageSnapshotReady), from: self, with: ["image": smallerImage])
// Save the image in the Setup Data model
SetupData.photo = smallerImage
CurrentPerson.sharedInstance.photo = smallerImage
return smallerImage
}
......
......@@ -65,7 +65,7 @@ class ProfileViewController: NSViewController, NSPopoverDelegate
displayProfileImage()
profileImageChangeHandler = profileImageChangeHandler ?? handle(SetupDataNotification.named(.ProfileImageDidChange))
profileImageChangeHandler = profileImageChangeHandler ?? handle(CurrentPersonNotification.named(.ProfileImageDidChange))
{
/* as */ notification in
......@@ -90,7 +90,7 @@ class ProfileViewController: NSViewController, NSPopoverDelegate
func displayProfileImage()
{
profileButton.image = SetupData.photo
profileButton.image = CurrentPerson.sharedInstance.photo
if let profileButtonLayer = profileButton.layer
{
......
......@@ -32,7 +32,7 @@ class SetupPrereleaseProgramWelcomeAndCodeViewController: NSViewController {
{
let invitationCode = self.invitationCode.stringValue
println("About to check if invitation code \(invitationCode) is valid…")
Node.sharedInstance.call(remoteFunction.named(.isInvitationCodeValid), withArguments: [invitationCode, SetupData.accountHandle!])
Node.sharedInstance.call(remoteFunction.named(.isInvitationCodeValid), withArguments: [invitationCode, CurrentPerson.sharedInstance.accountHandle!])
{
/* and handle the */ response in
......
......@@ -193,7 +193,7 @@ class SetupStepOneViewController: SetupStepViewController
{
println("ℹ️ Persisting profile data for Step One of the Setup process. (\(self))\n")
SetupData.accountHandle = nameTextField.stringValue
CurrentPerson.sharedInstance.accountHandle = nameTextField.stringValue
}
......
......@@ -55,9 +55,9 @@ class SetupStepTwoViewController: SetupStepViewController
{
println("ℹ️ Persisting profile data for Step Two of the Setup process. (\(self))\n")
// Persist data in the global SetupData struct.
SetupData.displayName = self.personNameTextField.stringValue
SetupData.bio = self.bioTextField.stringValue
// Persist data in the global CurrentPerson instance.
CurrentPerson.sharedInstance.displayName = self.personNameTextField.stringValue
CurrentPerson.sharedInstance.bio = self.bioTextField.stringValue
// TODO: ^^^ Move these to the handlers also and persist immediately.
}
......@@ -213,10 +213,10 @@ class SetupStepTwoViewController: SetupStepViewController
self.delegate?.showTip(NSLocalizedString("Create a public profile with your full name, bio, and photo.", comment:"Setup screen usage tip."))
// Try and get the person’s name from the Setup data
personName = SetupData.displayName ?? ""
personName = CurrentPerson.sharedInstance.displayName ?? ""
// Try and get the bio from the Setup data.
bio = SetupData.bio ?? ""
bio = CurrentPerson.sharedInstance.bio ?? ""
personNameTextField.stringValue = personName!
bioTextField.stringValue = bio!
......@@ -240,7 +240,7 @@ class SetupStepTwoViewController: SetupStepViewController
if let userInfo = notification.userInfo, croppedPhoto = userInfo["image"] as? NSImage
{
SetupData.photo = croppedPhoto
CurrentPerson.sharedInstance.photo = croppedPhoto
// If we’re running in the setup flow, we’ll have our delegate set.
// If so, do *not* persist yet as the folder structure for the person’s account is not ready and
......@@ -260,14 +260,14 @@ class SetupStepTwoViewController: SetupStepViewController
// a. Save the photo at @3x resolution (216 DPI)
//
println("ℹ️ Saving the profile image…")
let photo:NSImage = SetupData.photo
let photo:NSImage = CurrentPerson.sharedInstance.photo
let jpegData:NSData? = photo.JPEGFileData(dpi: 216, properties: [NSImageCompressionFactor:0.75])
if let jpegData = jpegData
{
// TODO: Do this in an operation queue so as not to block the UI thread + refactor
let success1:Bool = NSFileManager.defaultManager().createFileAtPath(/*SetupData.photoPath*/publicCopy, contents: jpegData, attributes: nil)
let success2:Bool = NSFileManager.defaultManager().createFileAtPath(/*SetupData.photoPath*/allFriendsCopy, contents: jpegData, attributes: nil)
let success1:Bool = NSFileManager.defaultManager().createFileAtPath(/*CurrentPerson.sharedInstance.photoPath*/publicCopy, contents: jpegData, attributes: nil)
let success2:Bool = NSFileManager.defaultManager().createFileAtPath(/*CurrentPerson.sharedInstance.photoPath*/allFriendsCopy, contents: jpegData, attributes: nil)
if (success1 && success2)
{
......@@ -297,12 +297,12 @@ class SetupStepTwoViewController: SetupStepViewController
self.personName = self.personNameTextField.stringValue
// If the person name is empty, use the account handle.
self.personName = self.personName == "" ? SetupData.accountHandle! : self.personName
self.personName = self.personName == "" ? CurrentPerson.sharedInstance.accountHandle! : self.personName
println("Updating person name to: \(self.personName)")
// Save it in the Setup model
SetupData.displayName = self.personName
CurrentPerson.sharedInstance.displayName = self.personName
// If we’re running in the setup flow, we’ll have our delegate set.
// If so, do *not* persist yet as the folder structure for the person’s account is not ready and
......@@ -326,7 +326,7 @@ class SetupStepTwoViewController: SetupStepViewController
//println("Updating bio to: \(self.bio)")
// Save it in the Setup model.
SetupData.bio = self.bio
CurrentPerson.sharedInstance.bio = self.bio
// If we’re running in the setup flow, we’ll have our delegate set.
// If so, do *not* persist yet as the folder structure for the person’s account is not ready and
......@@ -350,12 +350,12 @@ class SetupStepTwoViewController: SetupStepViewController
//
// If the person name is empty, use the account handle.
self.personName = self.personName == "" ? SetupData.accountHandle! : self.personName
self.personName = self.personName == "" ? CurrentPerson.sharedInstance.accountHandle! : self.personName
let publicCopy:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/5. Everyone (public)/to/about/me.json")
let allFriendsCopy:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/3. All your friends/to/about/me.json")
let accountInfo = SetupData.publicTextualDataDictionary
let accountInfo = CurrentPerson.sharedInstance.publicTextualDataDictionary
let accountInfoJSON:JSON = JSON(accountInfo)
let accountInfoData:NSData = accountInfoJSON.rawData()!
......
......@@ -25,9 +25,7 @@ class SetupViewController: NSViewController, SetupDelegate
var currentStep:Int = 1
let numberOfSteps:Int = 2
var setupData = [String:AnyObject?]()
// Child view controllers
weak var message:SetupMessageViewController?
weak var progressIndicator:SetupProgressIndicatorViewController!
......@@ -301,10 +299,10 @@ class SetupViewController: NSViewController, SetupDelegate
//
println("Creating Waystone account…")
println(SetupData)
println(CurrentPerson)
// Get the account handle safely.
Node.sharedInstance.call(remoteFunction.named(remoteFunction.initialiseHeartbeatWithWaystoneAccount), withArguments: [SetupData.accountHandle!, SetupData.invitationCode!])
Node.sharedInstance.call(remoteFunction.named(remoteFunction.initialiseHeartbeatWithWaystoneAccount), withArguments: [CurrentPerson.sharedInstance.accountHandle!, CurrentPerson.sharedInstance.invitationCode!])
{
/* and handle */ response in
......@@ -346,7 +344,7 @@ class SetupViewController: NSViewController, SetupDelegate
// Response was successful, continue with local setup.
//
SetupData.deviceID = response["deviceID"].stringValue
CurrentPerson.sharedInstance.deviceID = response["deviceID"].stringValue
//
// Update the account information to include the device ID.
......@@ -361,7 +359,7 @@ class SetupViewController: NSViewController, SetupDelegate
// a. Save the photo at @3x resolution (216 DPI)
//
println("ℹ️ Saving the profile image.")
let photo:NSImage = SetupData.photo
let photo:NSImage = CurrentPerson.sharedInstance.photo
let jpegData:NSData? = photo.JPEGFileData(dpi: 216, properties: [NSImageCompressionFactor:0.75])
if let jpegData = jpegData
......@@ -383,7 +381,7 @@ class SetupViewController: NSViewController, SetupDelegate
let publicCopyOfProfileData:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/5. Everyone (public)/to/about/me.json")
let allFriendsCopyOfProfileData:String = NSHomeDirectory().stringByAppendingPathComponent("Pulse/Sync/3. All your friends/to/about/me.json")
let accountInfo = SetupData.publicTextualDataDictionary
let accountInfo = CurrentPerson.sharedInstance.publicTextualDataDictionary
let accountInfoJSON:JSON = JSON(accountInfo)
let accountInfoData:NSData = accountInfoJSON.rawData()!
......@@ -529,7 +527,7 @@ class SetupViewController: NSViewController, SetupDelegate
{
if let invitationCode = userInfo["invitationCode"] as? String
{
SetupData.invitationCode = invitationCode
CurrentPerson.sharedInstance.invitationCode = invitationCode
createWaystoneAccount()
}
else
......
......@@ -199,13 +199,13 @@ public class TeleportationAPI:NSObject
println("ℹ️ Teleportation API: sending friendship request to \(toPerson). Optional message: \(optionalMessage)\n")
let message =
[
"fromPersonHandle": SetupData.accountHandle!,
"fromPersonName": SetupData.displayName!,
"fromPersonHandle": CurrentPerson.sharedInstance.accountHandle!,
"fromPersonName": CurrentPerson.sharedInstance.displayName!,
"toPerson": toPerson,
"optionalMessage": optionalMessage,
// TODO: This needs to be an array of all the device IDs for the person once we start supporting multiple devices.
"deviceID": SetupData.deviceID!
"deviceID": CurrentPerson.sharedInstance.deviceID!
]
let messageJSON = JSON(message)
......@@ -217,13 +217,13 @@ public class TeleportationAPI:NSObject
println("ℹ️ Teleportation API: sending friendship acceptance to \(toPerson).\n")
let message =
[
"fromPersonHandle": SetupData.accountHandle!,
"fromPersonName": SetupData.displayName!,
"fromPersonHandle": CurrentPerson.sharedInstance.accountHandle!,
"fromPersonName": CurrentPerson.sharedInstance.displayName!,
"toPerson": toPerson,
// TODO: This needs to be an array of all the device IDs for the person once we start supporting multiple devices.
// LEFT OFF HERE — TEST!!!!
"deviceID": SetupData.deviceID!
"deviceID": CurrentPerson.sharedInstance.deviceID!
]
let messageJSON = JSON(message)
......@@ -236,8 +236,8 @@ public class TeleportationAPI:NSObject
let message =
[
"fromPersonHandle": SetupData.accountHandle!,
"fromPersonName": SetupData.displayName!,
"fromPersonHandle": CurrentPerson.sharedInstance.accountHandle!,
"fromPersonName": CurrentPerson.sharedInstance.displayName!,
"toPerson": toPerson,
"optionalMessage": optionalMessage
]
......
......@@ -63,7 +63,7 @@ public class CurrentTimeline
public static func message(html:String, synced:Bool = false) -> Message
{
return Message(id: self.nextID(), assetURLPrefix: self.assetURLPrefix(), folderURL: self.folderURL()!, html: html, personHandle: SetupData.accountHandle!, synced: synced)
return Message(id: self.nextID(), assetURLPrefix: self.assetURLPrefix(), folderURL: self.folderURL()!, html: html, personHandle: CurrentPerson.sharedInstance.accountHandle!, synced: synced)
}
......
......@@ -433,7 +433,7 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
if self.currentTimeline.id == fromPersonHandle
{
// For the specific friends timeline, massage the assetURLPrefix to remove the person handle first.
relativeWebPrefix = relativeWebPrefix.stringByReplacingOccurrencesOfString("\(fromPersonHandle)/", replacement: "\(SetupData.accountHandle!)/")
relativeWebPrefix = relativeWebPrefix.stringByReplacingOccurrencesOfString("\(fromPersonHandle)/", replacement: "\(CurrentPerson.sharedInstance.accountHandle!)/")
println("Relative web prefix after massaging for specific friends timeline: \(relativeWebPrefix)")
}
......@@ -463,7 +463,7 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
if self.currentTimeline.id == fromPersonHandle
{
// Specific friends
assetURLPrefix = assetURLPrefix.stringByReplacingOccurrencesOfString("/\(SetupData.accountHandle!)/to", replacement: "/\(fromPersonHandle)/from")
assetURLPrefix = assetURLPrefix.stringByReplacingOccurrencesOfString("/\(CurrentPerson.sharedInstance.accountHandle!)/to", replacement: "/\(fromPersonHandle)/from")
}
else
{
......@@ -509,6 +509,15 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
func loadIndexPage()
{
var urlRequest = NSURLRequest(URL: NSURL(string: "http://127.0.0.1:42003/index.html")!)
// Refactoring: moving to timelines served via the private web server.
if CurrentTimeline.id == "allfriends"
{
println("Showing all friends timeline from the private web server.")
urlRequest = NSURLRequest(URL: NSURL(string: "http://127.0.0.1:42003/all-friends-timeline")!)
}
webkit.loadRequest(urlRequest)
}
......@@ -713,7 +722,7 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
// return
// }
if theCommand == SetupData.accountHandle
if theCommand == CurrentPerson.sharedInstance.accountHandle
{
// It’s us:
......
//
// PersonModelTest.swift
// Heartbeat
//
// Created by Aral Balkan on 17/08/2015.
// Copyright (c) 2015 Ind.ie. All rights reserved.
//
import Cocoa
import XCTest
class PersonModelTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
}
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