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

Matched re-implementation of default notices from Node. Progress towards #175....

Matched re-implementation of default notices from Node. Progress towards #175. Updated to use new namespaced timeline URLs.
parent 3d901086
......@@ -130,7 +130,7 @@ class SidebarViewController:NSViewController
println("No friends, closing the friends sidebar.")
post(SidebarNotification.named(.HideSidebar))
post(TimelineNoticeDisplayRequestNotification, from: self, with: ["title": "Private conversations", "body": "<p style='margin-bottom: 32px;'><strong>No friends yet? Let’s fix that!&nbsp;😜</strong></p><p>← This is the Everyone timeline. It’s the first item in the main navigation.</p><p>The Everyone timelime aggregates everyone’s public posts. You can also see who else has joined the pre-alpha and send them friendship requests.</p><p>Once you have friends, they will show up here and you can talk to them privately.</p>"]);
post(TimelineNoticeDisplayRequestNotification, from: self, with: ["notice": "no-friends"]);
}
for friend in friends
......
......@@ -44,7 +44,6 @@ public enum TimelineNotification:String
// MARK: .TimelineDidChange
case TimelineDidChange = "TimelineDidChangeNotification"
}
......
......@@ -132,49 +132,11 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
println("Received request to display a notice in the timeline area.")
if let userInfo = notification.userInfo, title = userInfo["title"] as? String, body = userInfo["body"] as? String
if let userInfo = notification.userInfo, notice = userInfo["notice"] as? String
{
let noticeObject =
[
"title": title,
"body": body
]
// Convert to JSON and pass to the function
var noticeAsJSONString = JSON(noticeObject).rawString()
if let noticeAsJSONString = noticeAsJSONString
{
println("Notice as JSON string: \(noticeAsJSONString)")
let javascript = "displayNotice(\(noticeAsJSONString));"
println("ℹ️ Displaying notice with title: \(title) and body: \(body)\n")
println(javascript)
self.webkit.evaluateJavaScript(javascript)
{
(result, error) -> Void in
if error != nil
{
println("\t❌ JavaScript Error while displaying notice with title \(title): \(error) (\(self))\n")
}
else
{
if result != nil
{
// There really shouldn’t be a result but let’s code defensively in case we break something later.
println("✅ Notice with title \(title) shown.Result: \(result)\n")
}
else
{
println("✅ Notice with title \(title) shown.\n")
}
}
}
}
println("Displaying notice: \(notice)")
CurrentTimeline.id = notice
self.loadIndexPage()
}
}
......@@ -350,25 +312,29 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
var timelineToLoad:String? = nil
if let currentTimelineID = CurrentTimeline.id
{
if currentTimelineID == "no-friends"
{
timelineToLoad = "http://127.0.0.1:42003/notice/no-friends"
}
if currentTimelineID == "everyone"
{
timelineToLoad = ApplicationModel.sharedInstance.waystoneURL
}
if currentTimelineID == "allfriends"
{
timelineToLoad = "http://127.0.0.1:42003/all-friends-timeline"
timelineToLoad = "http://127.0.0.1:42003/timeline/all-friends"
}
if currentTimelineID == "private"
{
timelineToLoad = "http://127.0.0.1:42003/private-timeline"
timelineToLoad = "http://127.0.0.1:42003/timeline/private"
}
if currentTimelineID == "public"
{
timelineToLoad = "http://127.0.0.1:42003/public-timeline"
timelineToLoad = "http://127.0.0.1:42003/timeline/public"
}
if currentTimelineID != "allfriends" && currentTimelineID != "conversations" && currentTimelineID != "private" && currentTimelineID != "everyone" && currentTimelineID != "public"
if currentTimelineID != "allfriends" && currentTimelineID != "conversations" && currentTimelineID != "private" && currentTimelineID != "everyone" && currentTimelineID != "public" && currentTimelineID != "no-friends"
{
timelineToLoad = "http://127.0.0.1:42003/conversation-with/\(currentTimelineID)"
timelineToLoad = "http://127.0.0.1:42003/timeline/conversation-with/\(currentTimelineID)"
}
}
......
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