diff --git a/Frameworks/FeedProvider/Twitter/TwitterFeedProvider.swift b/Frameworks/FeedProvider/Twitter/TwitterFeedProvider.swift index 4a8236894..a84182d91 100644 --- a/Frameworks/FeedProvider/Twitter/TwitterFeedProvider.swift +++ b/Frameworks/FeedProvider/Twitter/TwitterFeedProvider.swift @@ -26,9 +26,9 @@ public struct TwitterFeedProvider { // TODO: save credentials here } - public init(username: String) { - self.userID = username - self.screenName = "Stored Somewhere" + public init(userID: String, screenName: String) { + self.userID = userID + self.screenName = screenName // TODO: load credentials here } diff --git a/Mac/Preferences/ExtensionPoints/ExtensionPointEnableWindowController.swift b/Mac/Preferences/ExtensionPoints/ExtensionPointEnableWindowController.swift index 3b222b9ea..c70251a33 100644 --- a/Mac/Preferences/ExtensionPoints/ExtensionPointEnableWindowController.swift +++ b/Mac/Preferences/ExtensionPoints/ExtensionPointEnableWindowController.swift @@ -120,12 +120,8 @@ private extension ExtensionPointEnableWindowController { switch result { case .success(let tokenSuccess): - ExtensionPointManager.shared.activateExtensionPoint(extensionPointType, tokenSuccess: tokenSuccess) - let screenName = tokenSuccess.parameters["screen_name"] as? String ?? "" - print("******************* \(screenName)") self.hostWindow!.endSheet(self.window!, returnCode: NSApplication.ModalResponse.OK) - case .failure(let oauthSwiftError): NSApplication.shared.presentError(oauthSwiftError) } diff --git a/Shared/ExtensionPoints/ExtensionPoint.swift b/Shared/ExtensionPoints/ExtensionPoint.swift index fede4fbfe..8d8355b30 100644 --- a/Shared/ExtensionPoints/ExtensionPoint.swift +++ b/Shared/ExtensionPoints/ExtensionPoint.swift @@ -24,11 +24,11 @@ protocol ExtensionPoint { extension ExtensionPoint { var templateImage: RSImage { - return extensionPointID.type.templateImage + return extensionPointID.extensionPointType.templateImage } var description: NSAttributedString { - return extensionPointID.type.description + return extensionPointID.extensionPointType.description } static func makeAttrString(_ text: String) -> NSMutableAttributedString { diff --git a/Shared/ExtensionPoints/ExtensionPointIdentifer.swift b/Shared/ExtensionPoints/ExtensionPointIdentifer.swift index 099b4196d..97c471656 100644 --- a/Shared/ExtensionPoints/ExtensionPointIdentifer.swift +++ b/Shared/ExtensionPoints/ExtensionPointIdentifer.swift @@ -10,13 +10,12 @@ import Foundation import FeedProvider import RSCore - enum ExtensionPointIdentifer: Hashable { case marsEdit case microblog - case twitter(String) + case twitter(String, String) - var type: ExtensionPoint.Type { + var extensionPointType: ExtensionPoint.Type { switch self { case .marsEdit: return SendToMarsEditCommand.self @@ -37,10 +36,11 @@ enum ExtensionPointIdentifer: Hashable { return [ "type": "microblog" ] - case .twitter(let username): + case .twitter(let userID, let screenName): return [ - "type": "feed", - "username": username + "type": "twitter", + "userID": userID, + "screenName": screenName ] } } @@ -54,8 +54,8 @@ enum ExtensionPointIdentifer: Hashable { case "microblog": self = ExtensionPointIdentifer.microblog case "twitter": - guard let username = userInfo["username"] as? String else { return nil } - self = ExtensionPointIdentifer.twitter(username) + guard let userID = userInfo["userID"] as? String, let screenName = userInfo["screenName"] as? String else { return nil } + self = ExtensionPointIdentifer.twitter(userID, screenName) default: return nil } @@ -67,9 +67,11 @@ enum ExtensionPointIdentifer: Hashable { hasher.combine("marsEdit") case .microblog: hasher.combine("microblog") - case .twitter(let username): + case .twitter(let userID, let screenName): hasher.combine("twitter") - hasher.combine(username) + hasher.combine(userID) + hasher.combine(screenName) } } + } diff --git a/Shared/ExtensionPoints/ExtensionPointManager.swift b/Shared/ExtensionPoints/ExtensionPointManager.swift index e62db219c..d0c3c857e 100644 --- a/Shared/ExtensionPoints/ExtensionPointManager.swift +++ b/Shared/ExtensionPoints/ExtensionPointManager.swift @@ -23,7 +23,7 @@ final class ExtensionPointManager { let possibleExtensionPointTypes: [ExtensionPoint.Type] var availableExtensionPointTypes: [ExtensionPoint.Type] { - let activeExtensionPointTypes = activeExtensionPoints.keys.compactMap({ ObjectIdentifier($0.type) }) + let activeExtensionPointTypes = activeExtensionPoints.keys.compactMap({ ObjectIdentifier($0.extensionPointType) }) var available = [ExtensionPoint.Type]() for possibleExtensionPointType in possibleExtensionPointTypes { if possibleExtensionPointType.isSinglton { @@ -118,8 +118,8 @@ private extension ExtensionPointManager { return SendToMarsEditCommand() case .microblog: return SendToMicroBlogCommand() - case .twitter(let username): - return TwitterFeedProvider(username: username) + case .twitter(let userID, let screenName): + return TwitterFeedProvider(userID: userID, screenName: screenName) } } diff --git a/Shared/ExtensionPoints/SendToMarsEditCommand.swift b/Shared/ExtensionPoints/SendToMarsEditCommand.swift index 820ace4e2..3208ed8aa 100644 --- a/Shared/ExtensionPoints/SendToMarsEditCommand.swift +++ b/Shared/ExtensionPoints/SendToMarsEditCommand.swift @@ -28,7 +28,7 @@ final class SendToMarsEditCommand: ExtensionPoint, SendToCommand { let extensionPointID = ExtensionPointIdentifer.marsEdit var title: String { - return extensionPointID.type.title + return extensionPointID.extensionPointType.title } var image: NSImage? { diff --git a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift index a48eca60e..b6149c58d 100644 --- a/Shared/ExtensionPoints/SendToMicroBlogCommand.swift +++ b/Shared/ExtensionPoints/SendToMicroBlogCommand.swift @@ -31,7 +31,7 @@ final class SendToMicroBlogCommand: ExtensionPoint, SendToCommand { let extensionPointID = ExtensionPointIdentifer.microblog var title: String { - return extensionPointID.type.title + return extensionPointID.extensionPointType.title } var image: NSImage? { diff --git a/Shared/ExtensionPoints/TwitterFeedProvider+Extensions.swift b/Shared/ExtensionPoints/TwitterFeedProvider+Extensions.swift index 162326492..9a1fa2c43 100644 --- a/Shared/ExtensionPoints/TwitterFeedProvider+Extensions.swift +++ b/Shared/ExtensionPoints/TwitterFeedProvider+Extensions.swift @@ -28,7 +28,7 @@ extension TwitterFeedProvider: ExtensionPoint { }() var extensionPointID: ExtensionPointIdentifer { - return ExtensionPointIdentifer.twitter(userID) + return ExtensionPointIdentifer.twitter(userID, screenName) } var title: String {