mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Remove more Reddit references, including code in the Account framework.
This commit is contained in:
@@ -11,28 +11,25 @@ import Account
|
||||
import RSCore
|
||||
|
||||
enum ExtensionPointIdentifer: Hashable {
|
||||
#if os(macOS)
|
||||
#if os(macOS)
|
||||
case marsEdit
|
||||
case microblog
|
||||
#endif
|
||||
case reddit(String)
|
||||
#endif
|
||||
|
||||
var extensionPointType: ExtensionPoint.Type {
|
||||
switch self {
|
||||
#if os(macOS)
|
||||
#if os(macOS)
|
||||
case .marsEdit:
|
||||
return SendToMarsEditCommand.self
|
||||
case .microblog:
|
||||
return SendToMicroBlogCommand.self
|
||||
#endif
|
||||
case .reddit:
|
||||
return RedditFeedProvider.self
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public var userInfo: [AnyHashable: AnyHashable] {
|
||||
switch self {
|
||||
#if os(macOS)
|
||||
#if os(macOS)
|
||||
case .marsEdit:
|
||||
return [
|
||||
"type": "marsEdit"
|
||||
@@ -41,12 +38,7 @@ enum ExtensionPointIdentifer: Hashable {
|
||||
return [
|
||||
"type": "microblog"
|
||||
]
|
||||
#endif
|
||||
case .reddit(let username):
|
||||
return [
|
||||
"type": "reddit",
|
||||
"username": username
|
||||
]
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,15 +46,12 @@ enum ExtensionPointIdentifer: Hashable {
|
||||
guard let type = userInfo["type"] as? String else { return nil }
|
||||
|
||||
switch type {
|
||||
#if os(macOS)
|
||||
#if os(macOS)
|
||||
case "marsEdit":
|
||||
self = ExtensionPointIdentifer.marsEdit
|
||||
case "microblog":
|
||||
self = ExtensionPointIdentifer.microblog
|
||||
#endif
|
||||
case "reddit":
|
||||
guard let username = userInfo["username"] as? String else { return nil }
|
||||
self = ExtensionPointIdentifer.reddit(username)
|
||||
#endif
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@@ -70,16 +59,12 @@ enum ExtensionPointIdentifer: Hashable {
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
switch self {
|
||||
#if os(macOS)
|
||||
#if os(macOS)
|
||||
case .marsEdit:
|
||||
hasher.combine("marsEdit")
|
||||
case .microblog:
|
||||
hasher.combine("microblog")
|
||||
#endif
|
||||
case .reddit(let username):
|
||||
hasher.combine("reddit")
|
||||
hasher.combine(username)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,12 +69,8 @@ final class ExtensionPointManager: FeedProviderManagerDelegate {
|
||||
return activeExtensionPoints.values.compactMap({ return $0 as? FeedProvider })
|
||||
}
|
||||
|
||||
var isRedditEnabled: Bool {
|
||||
return activeExtensionPoints.values.contains(where: { $0 is RedditFeedProvider })
|
||||
}
|
||||
|
||||
init() {
|
||||
possibleExtensionPointTypes = [RedditFeedProvider.self]
|
||||
possibleExtensionPointTypes = []
|
||||
loadExtensionPoints()
|
||||
}
|
||||
|
||||
@@ -117,19 +113,6 @@ private extension ExtensionPointManager {
|
||||
|
||||
func extensionPoint(for extensionPointType: ExtensionPoint.Type, tokenSuccess: OAuthSwift.TokenSuccess?, completion: @escaping (Result<ExtensionPoint, Error>) -> Void) {
|
||||
switch extensionPointType {
|
||||
case is RedditFeedProvider.Type:
|
||||
if let tokenSuccess = tokenSuccess {
|
||||
RedditFeedProvider.create(tokenSuccess: tokenSuccess) { result in
|
||||
switch result {
|
||||
case .success(let reddit):
|
||||
completion(.success(reddit))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
completion(.failure(ExtensionPointManagerError.unableToCreate))
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -137,8 +120,6 @@ private extension ExtensionPointManager {
|
||||
|
||||
func extensionPoint(for extensionPointID: ExtensionPointIdentifer) -> ExtensionPoint? {
|
||||
switch extensionPointID {
|
||||
case .reddit(let username):
|
||||
return RedditFeedProvider(username: username)
|
||||
#if os(macOS)
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// RedditFeedProvider-Extensions.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 5/2/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Account
|
||||
|
||||
extension RedditFeedProvider: ExtensionPoint {
|
||||
|
||||
static var isSinglton = false
|
||||
static var isDeveloperBuildRestricted = true
|
||||
static var title = NSLocalizedString("Reddit", comment: "Reddit")
|
||||
static var image = AppAssets.extensionPointReddit
|
||||
static var description: NSAttributedString = {
|
||||
return RedditFeedProvider.makeAttrString("This extension enables you to subscribe to Reddit URLs as if they were RSS feeds. It only works with \(Account.defaultLocalAccountName) or iCloud accounts.")
|
||||
}()
|
||||
|
||||
var extensionPointID: ExtensionPointIdentifer {
|
||||
guard let username = username else {
|
||||
fatalError()
|
||||
}
|
||||
return ExtensionPointIdentifer.reddit(username)
|
||||
}
|
||||
|
||||
var title: String {
|
||||
guard let username = username else {
|
||||
fatalError()
|
||||
}
|
||||
return "u/\(username)"
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user