Ind.ie is now
Small Technology Foundation
.
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Heartbeat Cocoa
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adam Procter
Heartbeat Cocoa
Commits
f860a823
Commit
f860a823
authored
Jul 14, 2015
by
Aral Balkan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added special case for asset URL massaging for specific-friends timelines. Fixes
#97
.
parent
66c024fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
Heartbeat/TimelineViewController.swift
Heartbeat/TimelineViewController.swift
+32
-10
No files found.
Heartbeat/TimelineViewController.swift
View file @
f860a823
...
...
@@ -342,9 +342,6 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
let
messageID
=
(
message
[
"key"
])
.
string
!
var
messageHTML
=
(
message
[
"value"
])
.
string
!
var
assetURLPrefix
=
CurrentTimeline
.
relativeWebPrefix
!.
stringByAppendingPathComponent
(
messageID
)
var
filePath
=
NSHomeDirectory
()
.
stringByAppendingPathComponent
(
"Pulse/Sync"
)
.
stringByAppendingPathComponent
(
CurrentTimeline
.
path
!
)
.
stringByAppendingPathComponent
(
messageID
)
//
// Check if this is a message *from* someone to the all friends timeline.
// If so, we need to massage the assetURLPrefix and filePath to take this into consideration.
...
...
@@ -352,9 +349,26 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
println
(
"Message ID:
\(
messageID
)
"
)
var
fromPersonHandle
:
String
=
(
messageID
as
NSString
)
.
firstMatchedGroupWithRegex
(
".+?Z-(.+?)$"
)
println
(
"From person:
\(
fromPersonHandle
)
."
)
var
relativeWebPrefix
=
CurrentTimeline
.
relativeWebPrefix
!
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
!
)
/"
)
println
(
"Relative web prefix after massaging for specific friends timeline:
\(
relativeWebPrefix
)
"
)
}
var
assetURLPrefix
=
relativeWebPrefix
.
stringByAppendingPathComponent
(
messageID
)
var
filePath
=
NSHomeDirectory
()
.
stringByAppendingPathComponent
(
"Pulse/Sync"
)
.
stringByAppendingPathComponent
(
CurrentTimeline
.
path
!
)
.
stringByAppendingPathComponent
(
messageID
)
// println("Asset URL prefix: \(assetURLPrefix)")
// println("filePath: \(filePath)")
if
fromPersonHandle
!=
""
{
println
(
"The message was sent from person
\(
fromPersonHandle
)
. Massaging the asset URL prefix and the file path."
)
...
...
@@ -370,7 +384,15 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
let
oldAssetURLPrefix
=
assetURLPrefix
// Add the correct folder path.
assetURLPrefix
=
assetURLPrefix
.
stringByReplacingOccurrencesOfString
(
"/to"
,
replacement
:
"/from/
\(
fromPersonHandle
)
"
)
if
self
.
currentTimeline
.
id
==
fromPersonHandle
{
// Specific friends
assetURLPrefix
=
assetURLPrefix
.
stringByReplacingOccurrencesOfString
(
"/
\(
SetupData
.
accountHandle
!
)
/to"
,
replacement
:
"/
\(
fromPersonHandle
)
/from"
)
}
else
{
assetURLPrefix
=
assetURLPrefix
.
stringByReplacingOccurrencesOfString
(
"/to"
,
replacement
:
"/from/
\(
fromPersonHandle
)
"
)
}
filePath
=
filePath
.
stringByReplacingOccurrencesOfString
(
"/to"
,
replacement
:
"/from/
\(
fromPersonHandle
)
"
)
...
...
@@ -378,15 +400,15 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
let
filePathIndexOfThePersonsHandle
=
count
(
filePath
)
-
fromPersonHandleLengthIncludingDash
filePath
=
filePath
.
substringToIndex
(
filePathIndexOfThePersonsHandle
)
println
(
"Message HTML:
\(
messageHTML
)
"
)
println
(
"Old assetURLPrefix:
\(
oldAssetURLPrefix
)
"
)
println
(
"New assetURLPrefix:
\(
assetURLPrefix
)
"
)
println
(
"New filePath:
\(
filePath
)
"
)
//
println("Message HTML: \(messageHTML)")
//
println("Old assetURLPrefix: \(oldAssetURLPrefix)")
//
println("New assetURLPrefix: \(assetURLPrefix)")
//
println("New filePath: \(filePath)")
// Actually replace the old asset URL prefix with the new one in the message HTML.
messageHTML
=
messageHTML
.
stringByReplacingOccurrencesOfString
(
oldAssetURLPrefix
,
replacement
:
assetURLPrefix
)
println
(
"Message HTML after:
\(
messageHTML
)
"
)
//
println("Message HTML after: \(messageHTML)")
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment