From f86d8188b33fe4b386e72ce81c0e088a80fc9ffd Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Sun, 30 Aug 2020 16:59:49 -0700 Subject: [PATCH] Renaming --- Databases/ContentDatabase.swift | 12 ++++++------ Development Assets/DevelopmentModels.swift | 2 +- .../MastodonTarget+Stubbing.swift | 2 +- .../{MastodonError.swift => APIError.swift} | 4 ++-- .../{MastodonContext.swift => Context.swift} | 2 +- ...MastodonPreferences.swift => Preferences.swift} | 4 ++-- .../{MastodonClient.swift => APIClient.swift} | 14 +++++++------- .../{MastodonDecoder.swift => APIDecoder.swift} | 2 +- .../{MastodonEncoder.swift => APIEncoder.swift} | 2 +- .../{MastodonEndpoint.swift => Endpoint.swift} | 4 ++-- .../Endpoints/AccessTokenEndpoint.swift | 2 +- .../Mastodon API/Endpoints/AccountEndpoint.swift | 2 +- .../Endpoints/AppAuthorizationEndpoint.swift | 2 +- .../Mastodon API/Endpoints/ContextEndpoint.swift | 4 ++-- .../Mastodon API/Endpoints/DeletionEndpoint.swift | 2 +- .../Mastodon API/Endpoints/FilterEndpoint.swift | 2 +- .../Mastodon API/Endpoints/FiltersEndpoint.swift | 2 +- .../Mastodon API/Endpoints/InstanceEndpoint.swift | 2 +- .../Mastodon API/Endpoints/ListEndpoint.swift | 2 +- .../Mastodon API/Endpoints/ListsEndpoint.swift | 2 +- .../Networking/Mastodon API/Endpoints/Paged.swift | 4 ++-- .../Endpoints/PreferencesEndpoint.swift | 4 ++-- .../Endpoints/PushSubscriptionEndpoint.swift | 2 +- .../Mastodon API/Endpoints/StatusEndpoint.swift | 2 +- .../Mastodon API/Endpoints/TimelinesEndpoint.swift | 2 +- .../{MastodonTarget.swift => Target.swift} | 4 ++-- .../Property Wrappers/DecodableDefault.swift | 2 +- Metatext.xcodeproj/project.pbxproj | 2 +- Model/Identity.swift | 4 ++-- .../NotificationService.swift | 2 +- Services/AllIdentitiesService.swift | 2 +- Services/AuthenticationService.swift | 8 ++++---- Services/IdentityService.swift | 4 ++-- Services/Status List Services/ContextService.swift | 6 +++--- .../Status List Services/TimelineService.swift | 4 ++-- Services/StatusService.swift | 4 ++-- Views/PostingReadingPreferencesView.swift | 8 ++++---- 37 files changed, 67 insertions(+), 67 deletions(-) rename Mastodon/Sources/Mastodon/Entities/{MastodonError.swift => APIError.swift} (64%) rename Mastodon/Sources/Mastodon/Entities/{MastodonContext.swift => Context.swift} (85%) rename Mastodon/Sources/Mastodon/Entities/{MastodonPreferences.swift => Preferences.swift} (91%) rename Mastodon/Sources/Mastodon/Networking/Mastodon API/{MastodonClient.swift => APIClient.swift} (52%) rename Mastodon/Sources/Mastodon/Networking/Mastodon API/{MastodonDecoder.swift => APIDecoder.swift} (88%) rename Mastodon/Sources/Mastodon/Networking/Mastodon API/{MastodonEncoder.swift => APIEncoder.swift} (89%) rename Mastodon/Sources/Mastodon/Networking/Mastodon API/{MastodonEndpoint.swift => Endpoint.swift} (92%) rename Mastodon/Sources/Mastodon/Networking/Mastodon API/{MastodonTarget.swift => Target.swift} (90%) diff --git a/Databases/ContentDatabase.swift b/Databases/ContentDatabase.swift index db35f50..2bdd6f6 100644 --- a/Databases/ContentDatabase.swift +++ b/Databases/ContentDatabase.swift @@ -243,11 +243,11 @@ private extension ContentDatabase { extension Account: TableRecord, FetchableRecord, PersistableRecord { public static func databaseJSONDecoder(for column: String) -> JSONDecoder { - MastodonDecoder() + APIDecoder() } public static func databaseJSONEncoder(for column: String) -> JSONEncoder { - MastodonEncoder() + APIEncoder() } } @@ -325,11 +325,11 @@ private extension Timeline { extension Filter: TableRecord, FetchableRecord, PersistableRecord { public static func databaseJSONDecoder(for column: String) -> JSONDecoder { - MastodonDecoder() + APIDecoder() } public static func databaseJSONEncoder(for column: String) -> JSONEncoder { - MastodonEncoder() + APIEncoder() } } @@ -453,11 +453,11 @@ private extension StoredStatus { extension StoredStatus: TableRecord, FetchableRecord, PersistableRecord { static func databaseJSONDecoder(for column: String) -> JSONDecoder { - MastodonDecoder() + APIDecoder() } static func databaseJSONEncoder(for column: String) -> JSONEncoder { - MastodonEncoder() + APIEncoder() } } diff --git a/Development Assets/DevelopmentModels.swift b/Development Assets/DevelopmentModels.swift index f1c82d9..3afbf9c 100644 --- a/Development Assets/DevelopmentModels.swift +++ b/Development Assets/DevelopmentModels.swift @@ -5,7 +5,7 @@ import Combine import Mastodon // swiftlint:disable force_try -private let decoder = MastodonDecoder() +private let decoder = APIDecoder() private var cancellables = Set() private let devInstanceURL = URL(string: "https://mastodon.social")! private let devIdentityID = UUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")! diff --git a/Development Assets/Mastodon API Stubs/MastodonTarget+Stubbing.swift b/Development Assets/Mastodon API Stubs/MastodonTarget+Stubbing.swift index 4238482..e1a48e2 100644 --- a/Development Assets/Mastodon API Stubs/MastodonTarget+Stubbing.swift +++ b/Development Assets/Mastodon API Stubs/MastodonTarget+Stubbing.swift @@ -3,7 +3,7 @@ import Foundation import Mastodon -extension MastodonTarget: Stubbing { +extension Target: Stubbing { func stub(url: URL) -> HTTPStub? { (endpoint as? Stubbing)?.stub(url: url) } diff --git a/Mastodon/Sources/Mastodon/Entities/MastodonError.swift b/Mastodon/Sources/Mastodon/Entities/APIError.swift similarity index 64% rename from Mastodon/Sources/Mastodon/Entities/MastodonError.swift rename to Mastodon/Sources/Mastodon/Entities/APIError.swift index a32d802..e360df1 100644 --- a/Mastodon/Sources/Mastodon/Entities/MastodonError.swift +++ b/Mastodon/Sources/Mastodon/Entities/APIError.swift @@ -2,10 +2,10 @@ import Foundation -public struct MastodonError: Error, Codable { +public struct APIError: Error, Codable { public let error: String } -extension MastodonError: LocalizedError { +extension APIError: LocalizedError { public var errorDescription: String? { error } } diff --git a/Mastodon/Sources/Mastodon/Entities/MastodonContext.swift b/Mastodon/Sources/Mastodon/Entities/Context.swift similarity index 85% rename from Mastodon/Sources/Mastodon/Entities/MastodonContext.swift rename to Mastodon/Sources/Mastodon/Entities/Context.swift index fcdd891..c18f8cd 100644 --- a/Mastodon/Sources/Mastodon/Entities/MastodonContext.swift +++ b/Mastodon/Sources/Mastodon/Entities/Context.swift @@ -2,7 +2,7 @@ import Foundation -public struct MastodonContext: Codable, Hashable { +public struct Context: Codable, Hashable { public let ancestors: [Status] public let descendants: [Status] diff --git a/Mastodon/Sources/Mastodon/Entities/MastodonPreferences.swift b/Mastodon/Sources/Mastodon/Entities/Preferences.swift similarity index 91% rename from Mastodon/Sources/Mastodon/Entities/MastodonPreferences.swift rename to Mastodon/Sources/Mastodon/Entities/Preferences.swift index 05048b8..0f0c70e 100644 --- a/Mastodon/Sources/Mastodon/Entities/MastodonPreferences.swift +++ b/Mastodon/Sources/Mastodon/Entities/Preferences.swift @@ -2,7 +2,7 @@ import Foundation -public struct MastodonPreferences: Codable { +public struct Preferences: Codable { enum CodingKeys: String, CodingKey { case postingDefaultVisibility = "posting:default:visibility" case postingDefaultSensitive = "posting:default:sensitive" @@ -18,7 +18,7 @@ public struct MastodonPreferences: Codable { public let readingExpandSpoilers: Bool } -public extension MastodonPreferences { +public extension Preferences { enum ExpandMedia: String, Codable, Unknowable { case `default` case showAll diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonClient.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIClient.swift similarity index 52% rename from Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonClient.swift rename to Mastodon/Sources/Mastodon/Networking/Mastodon API/APIClient.swift index 7b91a3b..6e53704 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonClient.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIClient.swift @@ -3,27 +3,27 @@ import Foundation import Combine -public class MastodonClient: HTTPClient { +public class APIClient: HTTPClient { public var instanceURL: URL? public var accessToken: String? public required init(session: Session) { - super.init(session: session, decoder: MastodonDecoder()) + super.init(session: session, decoder: APIDecoder()) } public override func request(_ target: T) -> AnyPublisher { - super.request(target, decodeErrorsAs: MastodonError.self) + super.request(target, decodeErrorsAs: APIError.self) } } -extension MastodonClient { - public func request(_ endpoint: E) -> AnyPublisher { +extension APIClient { + public func request(_ endpoint: E) -> AnyPublisher { guard let instanceURL = instanceURL else { return Fail(error: URLError(.badURL)).eraseToAnyPublisher() } return super.request( - MastodonTarget(baseURL: instanceURL, endpoint: endpoint, accessToken: accessToken), - decodeErrorsAs: MastodonError.self) + Target(baseURL: instanceURL, endpoint: endpoint, accessToken: accessToken), + decodeErrorsAs: APIError.self) } } diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonDecoder.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIDecoder.swift similarity index 88% rename from Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonDecoder.swift rename to Mastodon/Sources/Mastodon/Networking/Mastodon API/APIDecoder.swift index 9d2f44e..3cf070f 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonDecoder.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIDecoder.swift @@ -2,7 +2,7 @@ import Foundation -public class MastodonDecoder: JSONDecoder { +public class APIDecoder: JSONDecoder { public override init() { super.init() diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEncoder.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIEncoder.swift similarity index 89% rename from Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEncoder.swift rename to Mastodon/Sources/Mastodon/Networking/Mastodon API/APIEncoder.swift index f683b12..54b3198 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEncoder.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/APIEncoder.swift @@ -2,7 +2,7 @@ import Foundation -public class MastodonEncoder: JSONEncoder { +public class APIEncoder: JSONEncoder { public override init() { super.init() diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoint.swift similarity index 92% rename from Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEndpoint.swift rename to Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoint.swift index a8ee81c..65a8815 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoint.swift @@ -2,7 +2,7 @@ import Foundation -public protocol MastodonEndpoint { +public protocol Endpoint { associatedtype ResultType: Decodable var APIVersion: String { get } var context: [String] { get } @@ -13,7 +13,7 @@ public protocol MastodonEndpoint { var headers: HTTPHeaders? { get } } -public extension MastodonEndpoint { +public extension Endpoint { var defaultContext: [String] { ["api", APIVersion] } diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccessTokenEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccessTokenEndpoint.swift index 0816028..6105e39 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccessTokenEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccessTokenEndpoint.swift @@ -13,7 +13,7 @@ public enum AccessTokenEndpoint { ) } -extension AccessTokenEndpoint: MastodonEndpoint { +extension AccessTokenEndpoint: Endpoint { public typealias ResultType = AccessToken public var context: [String] { [] } diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccountEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccountEndpoint.swift index a3143e3..9284b9e 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccountEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AccountEndpoint.swift @@ -6,7 +6,7 @@ public enum AccountEndpoint { case verifyCredentials } -extension AccountEndpoint: MastodonEndpoint { +extension AccountEndpoint: Endpoint { public typealias ResultType = Account public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AppAuthorizationEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AppAuthorizationEndpoint.swift index b887841..53998e9 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AppAuthorizationEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/AppAuthorizationEndpoint.swift @@ -6,7 +6,7 @@ public enum AppAuthorizationEndpoint { case apps(clientName: String, redirectURI: String, scopes: String, website: URL?) } -extension AppAuthorizationEndpoint: MastodonEndpoint { +extension AppAuthorizationEndpoint: Endpoint { public typealias ResultType = AppAuthorization public var pathComponentsInContext: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ContextEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ContextEndpoint.swift index 1ec70d3..2a7b9d5 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ContextEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ContextEndpoint.swift @@ -6,8 +6,8 @@ public enum ContextEndpoint { case context(id: String) } -extension ContextEndpoint: MastodonEndpoint { - public typealias ResultType = MastodonContext +extension ContextEndpoint: Endpoint { + public typealias ResultType = Context public var context: [String] { defaultContext + ["statuses"] diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/DeletionEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/DeletionEndpoint.swift index 6316ccd..d0211c9 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/DeletionEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/DeletionEndpoint.swift @@ -8,7 +8,7 @@ public enum DeletionEndpoint { case filter(id: String) } -extension DeletionEndpoint: MastodonEndpoint { +extension DeletionEndpoint: Endpoint { public typealias ResultType = [String: String] public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FilterEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FilterEndpoint.swift index 0674276..3a6f56d 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FilterEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FilterEndpoint.swift @@ -18,7 +18,7 @@ public enum FilterEndpoint { expiresIn: Date?) } -extension FilterEndpoint: MastodonEndpoint { +extension FilterEndpoint: Endpoint { public typealias ResultType = Filter public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FiltersEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FiltersEndpoint.swift index 2d31377..0ef8d7b 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FiltersEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/FiltersEndpoint.swift @@ -6,7 +6,7 @@ public enum FiltersEndpoint { case filters } -extension FiltersEndpoint: MastodonEndpoint { +extension FiltersEndpoint: Endpoint { public typealias ResultType = [Filter] public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/InstanceEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/InstanceEndpoint.swift index afae7ad..83b5034 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/InstanceEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/InstanceEndpoint.swift @@ -6,7 +6,7 @@ public enum InstanceEndpoint { case instance } -extension InstanceEndpoint: MastodonEndpoint { +extension InstanceEndpoint: Endpoint { public typealias ResultType = Instance public var pathComponentsInContext: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListEndpoint.swift index 281c0a6..74afc5f 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListEndpoint.swift @@ -6,7 +6,7 @@ public enum ListEndpoint { case create(title: String) } -extension ListEndpoint: MastodonEndpoint { +extension ListEndpoint: Endpoint { public typealias ResultType = MastodonList public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListsEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListsEndpoint.swift index ab0ace8..4450e1f 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListsEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/ListsEndpoint.swift @@ -6,7 +6,7 @@ public enum ListsEndpoint { case lists } -extension ListsEndpoint: MastodonEndpoint { +extension ListsEndpoint: Endpoint { public typealias ResultType = [MastodonList] public var pathComponentsInContext: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/Paged.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/Paged.swift index b7add26..0f39a26 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/Paged.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/Paged.swift @@ -2,7 +2,7 @@ import Foundation -public struct Paged { +public struct Paged { public let endpoint: T public let maxID: String? public let minID: String? @@ -18,7 +18,7 @@ public struct Paged { } } -extension Paged: MastodonEndpoint { +extension Paged: Endpoint { public typealias ResultType = T.ResultType public var APIVersion: String { endpoint.APIVersion } diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PreferencesEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PreferencesEndpoint.swift index 6b1046b..a715887 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PreferencesEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PreferencesEndpoint.swift @@ -6,8 +6,8 @@ public enum PreferencesEndpoint { case preferences } -extension PreferencesEndpoint: MastodonEndpoint { - public typealias ResultType = MastodonPreferences +extension PreferencesEndpoint: Endpoint { + public typealias ResultType = Preferences public var pathComponentsInContext: [String] { switch self { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PushSubscriptionEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PushSubscriptionEndpoint.swift index 4b17260..314c52d 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PushSubscriptionEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/PushSubscriptionEndpoint.swift @@ -13,7 +13,7 @@ public enum PushSubscriptionEndpoint { case delete } -extension PushSubscriptionEndpoint: MastodonEndpoint { +extension PushSubscriptionEndpoint: Endpoint { public typealias ResultType = PushSubscription public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/StatusEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/StatusEndpoint.swift index a935efe..ffd47e7 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/StatusEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/StatusEndpoint.swift @@ -8,7 +8,7 @@ public enum StatusEndpoint { case unfavourite(id: String) } -extension StatusEndpoint: MastodonEndpoint { +extension StatusEndpoint: Endpoint { public typealias ResultType = Status public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/TimelinesEndpoint.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/TimelinesEndpoint.swift index 5668d55..6cad9b4 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/TimelinesEndpoint.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Endpoints/TimelinesEndpoint.swift @@ -9,7 +9,7 @@ public enum TimelinesEndpoint { case list(id: String) } -extension TimelinesEndpoint: MastodonEndpoint { +extension TimelinesEndpoint: Endpoint { public typealias ResultType = [Status] public var context: [String] { diff --git a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonTarget.swift b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Target.swift similarity index 90% rename from Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonTarget.swift rename to Mastodon/Sources/Mastodon/Networking/Mastodon API/Target.swift index 4f8fb55..1a90785 100644 --- a/Mastodon/Sources/Mastodon/Networking/Mastodon API/MastodonTarget.swift +++ b/Mastodon/Sources/Mastodon/Networking/Mastodon API/Target.swift @@ -2,7 +2,7 @@ import Foundation -public struct MastodonTarget { +public struct Target { public let baseURL: URL public let endpoint: E public let accessToken: String? @@ -14,7 +14,7 @@ public struct MastodonTarget { } } -extension MastodonTarget: DecodableTarget { +extension Target: DecodableTarget { public typealias ResultType = E.ResultType public var pathComponents: [String] { endpoint.pathComponents } diff --git a/Mastodon/Sources/Mastodon/Property Wrappers/DecodableDefault.swift b/Mastodon/Sources/Mastodon/Property Wrappers/DecodableDefault.swift index 44e3fda..3b30907 100644 --- a/Mastodon/Sources/Mastodon/Property Wrappers/DecodableDefault.swift +++ b/Mastodon/Sources/Mastodon/Property Wrappers/DecodableDefault.swift @@ -57,7 +57,7 @@ public extension DecodableDefault { } public enum ExpandMediaDefault: Source { - public static var defaultValue: MastodonPreferences.ExpandMedia { .default } + public static var defaultValue: Preferences.ExpandMedia { .default } } } } diff --git a/Metatext.xcodeproj/project.pbxproj b/Metatext.xcodeproj/project.pbxproj index 2bd6bdb..3535c92 100644 --- a/Metatext.xcodeproj/project.pbxproj +++ b/Metatext.xcodeproj/project.pbxproj @@ -289,13 +289,13 @@ D047FA7F24C3E21000AF17C5 = { isa = PBXGroup; children = ( - D0E0F1E424FC49FC002C04BF /* Mastodon */, D0C7D45224F76169001EBDBB /* Assets.xcassets */, D0C7D46424F76169001EBDBB /* Databases */, D0ED1BB224CE3A1600B4899C /* Development Assets */, D0C7D46824F76169001EBDBB /* Extensions */, D0666A7924C7745A00F3F04B /* Frameworks */, D0C7D45624F76169001EBDBB /* Localizations */, + D0E0F1E424FC49FC002C04BF /* Mastodon */, D0C7D43824F76169001EBDBB /* Model */, D0C7D47324F76169001EBDBB /* Networking */, D0E5361A24E3EB4D00FB1CE1 /* Notification Service Extension */, diff --git a/Model/Identity.swift b/Model/Identity.swift index 8ba6d68..0f01a3e 100644 --- a/Model/Identity.swift +++ b/Model/Identity.swift @@ -40,7 +40,7 @@ extension Identity { @DecodableDefault.StatusVisibilityPublic var postingDefaultVisibility: Status.Visibility @DecodableDefault.False var postingDefaultSensitive var postingDefaultLanguage: String? - @DecodableDefault.ExpandMediaDefault var readingExpandMedia: MastodonPreferences.ExpandMedia + @DecodableDefault.ExpandMediaDefault var readingExpandMedia: Mastodon.Preferences.ExpandMedia @DecodableDefault.False var readingExpandSpoilers } } @@ -58,7 +58,7 @@ extension Identity { } extension Identity.Preferences { - func updated(from serverPreferences: MastodonPreferences) -> Self { + func updated(from serverPreferences: Preferences) -> Self { var mutable = self if useServerPostingReadingPreferences { diff --git a/Notification Service Extension/NotificationService.swift b/Notification Service Extension/NotificationService.swift index 64f2b67..6a77763 100644 --- a/Notification Service Extension/NotificationService.swift +++ b/Notification Service Extension/NotificationService.swift @@ -22,7 +22,7 @@ class NotificationService: UNNotificationServiceExtension { do { let decryptedJSON = try Self.extractAndDecrypt(userInfo: request.content.userInfo) - pushNotification = try MastodonDecoder().decode(PushNotification.self, from: decryptedJSON) + pushNotification = try APIDecoder().decode(PushNotification.self, from: decryptedJSON) } catch { contentHandler(bestAttemptContent) diff --git a/Services/AllIdentitiesService.swift b/Services/AllIdentitiesService.swift index 3848bb8..5bb6219 100644 --- a/Services/AllIdentitiesService.swift +++ b/Services/AllIdentitiesService.swift @@ -50,7 +50,7 @@ extension AllIdentitiesService { func deleteIdentity(_ identity: Identity) -> AnyPublisher { let secretsService = SecretsService(identityID: identity.id, keychainService: environment.keychainServiceType) - let networkClient = MastodonClient(session: environment.session) + let networkClient = APIClient(session: environment.session) networkClient.instanceURL = identity.url diff --git a/Services/AuthenticationService.swift b/Services/AuthenticationService.swift index 9fd80c8..0d58bcc 100644 --- a/Services/AuthenticationService.swift +++ b/Services/AuthenticationService.swift @@ -5,12 +5,12 @@ import Combine import Mastodon struct AuthenticationService { - private let networkClient: MastodonClient + private let networkClient: APIClient private let webAuthSessionType: WebAuthSession.Type private let webAuthSessionContextProvider = WebAuthSessionContextProvider() init(environment: AppEnvironment) { - networkClient = MastodonClient(session: environment.session) + networkClient = APIClient(session: environment.session) webAuthSessionType = environment.webAuthSessionType } } @@ -22,7 +22,7 @@ extension AuthenticationService { redirectURI: OAuth.callbackURL.absoluteString, scopes: OAuth.scopes, website: OAuth.website) - let target = MastodonTarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) + let target = Target(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) return networkClient.request(target) } @@ -63,7 +63,7 @@ extension AuthenticationService { grantType: OAuth.grantType, scopes: OAuth.scopes, redirectURI: OAuth.callbackURL.absoluteString) - let target = MastodonTarget(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) + let target = Target(baseURL: instanceURL, endpoint: endpoint, accessToken: nil) return networkClient.request(target) } diff --git a/Services/IdentityService.swift b/Services/IdentityService.swift index 9d4c5e5..45e5084 100644 --- a/Services/IdentityService.swift +++ b/Services/IdentityService.swift @@ -11,7 +11,7 @@ class IdentityService { private let identityDatabase: IdentityDatabase private let contentDatabase: ContentDatabase private let environment: AppEnvironment - private let networkClient: MastodonClient + private let networkClient: APIClient private let secretsService: SecretsService private let observationErrorsInput = PassthroughSubject() @@ -35,7 +35,7 @@ class IdentityService { secretsService = SecretsService( identityID: identityID, keychainService: environment.keychainServiceType) - networkClient = MastodonClient(session: environment.session) + networkClient = APIClient(session: environment.session) networkClient.instanceURL = identity.url networkClient.accessToken = try? secretsService.item(.accessToken) diff --git a/Services/Status List Services/ContextService.swift b/Services/Status List Services/ContextService.swift index 9ee16d9..d0bb30c 100644 --- a/Services/Status List Services/ContextService.swift +++ b/Services/Status List Services/ContextService.swift @@ -9,12 +9,12 @@ struct ContextService { let paginates = false private let status: Status - private let context = CurrentValueSubject(MastodonContext(ancestors: [], descendants: [])) - private let networkClient: MastodonClient + private let context = CurrentValueSubject(Context(ancestors: [], descendants: [])) + private let networkClient: APIClient private let contentDatabase: ContentDatabase private let collection: TransientStatusCollection - init(status: Status, networkClient: MastodonClient, contentDatabase: ContentDatabase) { + init(status: Status, networkClient: APIClient, contentDatabase: ContentDatabase) { self.status = status self.networkClient = networkClient self.contentDatabase = contentDatabase diff --git a/Services/Status List Services/TimelineService.swift b/Services/Status List Services/TimelineService.swift index 91ee21a..98443c1 100644 --- a/Services/Status List Services/TimelineService.swift +++ b/Services/Status List Services/TimelineService.swift @@ -8,10 +8,10 @@ struct TimelineService { let statusSections: AnyPublisher<[[Status]], Error> private let timeline: Timeline - private let networkClient: MastodonClient + private let networkClient: APIClient private let contentDatabase: ContentDatabase - init(timeline: Timeline, networkClient: MastodonClient, contentDatabase: ContentDatabase) { + init(timeline: Timeline, networkClient: APIClient, contentDatabase: ContentDatabase) { self.timeline = timeline self.networkClient = networkClient self.contentDatabase = contentDatabase diff --git a/Services/StatusService.swift b/Services/StatusService.swift index fc84557..784b54d 100644 --- a/Services/StatusService.swift +++ b/Services/StatusService.swift @@ -6,10 +6,10 @@ import Mastodon struct StatusService { let status: Status - private let networkClient: MastodonClient + private let networkClient: APIClient private let contentDatabase: ContentDatabase - init(status: Status, networkClient: MastodonClient, contentDatabase: ContentDatabase) { + init(status: Status, networkClient: APIClient, contentDatabase: ContentDatabase) { self.status = status self.networkClient = networkClient self.contentDatabase = contentDatabase diff --git a/Views/PostingReadingPreferencesView.swift b/Views/PostingReadingPreferencesView.swift index 543c5b5..c1b86d9 100644 --- a/Views/PostingReadingPreferencesView.swift +++ b/Views/PostingReadingPreferencesView.swift @@ -2,7 +2,7 @@ import SwiftUI import class Mastodon.Status -import struct Mastodon.MastodonPreferences +import struct Mastodon.Preferences struct PostingReadingPreferencesView: View { @StateObject var viewModel: PostingReadingPreferencesViewModel @@ -33,9 +33,9 @@ struct PostingReadingPreferencesView: View { Text("preferences.reading-expand-media") Picker("", selection: $viewModel.preferences.readingExpandMedia, content: { - Text("preferences.expand-media.default").tag(MastodonPreferences.ExpandMedia.default) - Text("preferences.expand-media.show-all").tag(MastodonPreferences.ExpandMedia.showAll) - Text("preferences.expand-media.hide-all").tag(MastodonPreferences.ExpandMedia.hideAll) + Text("preferences.expand-media.default").tag(Preferences.ExpandMedia.default) + Text("preferences.expand-media.show-all").tag(Preferences.ExpandMedia.showAll) + Text("preferences.expand-media.hide-all").tag(Preferences.ExpandMedia.hideAll) }) .pickerStyle(SegmentedPickerStyle()) }