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

Removed all instances of the message clock.

parent c4f1c522
......@@ -80,12 +80,8 @@ class MessageSplitViewController: NSSplitViewController
//
let messageDirectoryWrapper:NSFileWrapper? = messageAttributedString.fileWrapperFromRange(NSMakeRange(0, messageAttributedString.length), documentAttributes: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding, NSExcludedElementsDocumentAttribute: ["xml", "html", "head", "body", "font", "span"], NSPrefixSpacesDocumentAttribute: 4], error: nil)
// The file name of the message folder (this is the unique ID — unique per message folder):
// Local message clock (padding to 9 digits — which should be large enough for any timeline as it would take
// about a thousand years to fill it up at ten seconds a message, every ten seconds, eight hours a day, continuously) + current timestamp in ISO 8601 format
CurrentTimeline.messageClock++
let messageFileName = String(format:"%09d-\(ISO8601DateString())", CurrentTimeline.messageClock)
// The file name of the message folder (this is the unique ID — unique per message folder): Current timestamp in ISO 8601 format
let messageFileName = ISO8601DateString()
// This is the URL that will be prefixed to all assets in the HTML (images, etc.)
let assetURLPrefix = CurrentTimeline.relativeWebPrefix!.stringByAppendingPathComponent(messageFileName)
......
......@@ -18,8 +18,6 @@ public class Timeline:NSObject
public var relativeWebPrefix:String?
public var participants:[String]?
var messageClock:UInt = 0
init(id:String, title:String, path:String?, relativeWebPrefix:String?)
{
self.id = id
......@@ -57,7 +55,6 @@ public class CurrentTimeline
static var name:String?
static var path:String?
static var relativeWebPrefix:String?
static var messageClock:Int = 0
static var _nextID:String?
......@@ -69,8 +66,7 @@ public class CurrentTimeline
static func nextID() -> String
{
self.messageClock++
self._nextID = String(format:"%09d-\(ISO8601DateString())", self.messageClock)
self._nextID = ISO8601DateString()
return self._nextID!
}
......
......@@ -576,11 +576,6 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
CurrentTimeline.relativeWebPrefix = timeline.relativeWebPrefix
CurrentTimeline.id = timeline.id
// Reset the current timeline clock to zero.
// (The timeline will be requested again in Webkit Load Complete handler and the local clock will be updated based on the messages.)
// TODO: Review this whole process — it’s evolving quite organically (read: it’s quite a mess)
CurrentTimeline.messageClock = 0
// Notify anyone who cares that the timeline has changed.
post(TimelineNotification.named(.TimelineDidChange), from: self)
......@@ -660,24 +655,6 @@ class TimelineViewController: NSViewController, WKNavigationDelegate
}
}
}
//
// Update the message clock based on either the message clock in the last received message
// or our current local clock, whichever is higher.
//
if let clockFromMessage = ((message.id as NSString).firstMatchedGroupWithRegex("^(\\d+)-"))?.toInt()
{
println("\tClock:\n\n\t\tFrom message: \(clockFromMessage)")
println("\t\tLocal: \(CurrentTimeline.messageClock) (\(self))")
CurrentTimeline.messageClock = max(CurrentTimeline.messageClock, clockFromMessage)
}
else
{
println("\t\t⚠️ Could not get clock from message. Malformed message ID?")
CurrentTimeline.messageClock++
}
println("\t\tNew: \(CurrentTimeline.messageClock)\n")
}
//
......
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