Skip to content

Commit da4c0b2

Browse files
committed
Use Set for scopes instead of array
1 parent 7e39de7 commit da4c0b2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Demo App/Twift_SwiftUI/Twift_SwiftUIApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct Twift_SwiftUIApp: App {
4646
) {
4747
AsyncButton {
4848
let (user, _) = await Twift.Authentication().authenticateUser(clientId: "Sm5PSUhRNW9EZ3NXb0tJQkI5WU06MTpjaQ",
49-
redirectUri: URL(string: TWITTER_CALLBACK_URL)!,
50-
scope: Set(OAuth2Scope.allCases))
49+
redirectUri: URL(string: TWITTER_CALLBACK_URL)!,
50+
scope: Set(OAuth2Scope.allCases))
5151

5252
if let user = user {
5353
container.client = Twift(.oauth2UserAuth(user))

Sources/Twift+Authentication.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public struct OAuth2User: Decodable {
247247
public var expiresAt: Date
248248

249249
/// The scope of permissions for this access token.
250-
public var scope: [OAuth2Scope]
250+
public var scope: Set<OAuth2Scope>
251251

252252
/// Whether or not the access token has expired (i.e. whether `expiresAt` is in the past).
253253
public var expired: Bool {
@@ -271,7 +271,7 @@ public struct OAuth2User: Decodable {
271271
expiresAt = Date().addingTimeInterval(expiresIn)
272272

273273
let scopeArray = try values.decode(String.self, forKey: .scope)
274-
scope = scopeArray.split(separator: " ").compactMap { OAuth2Scope.init(rawValue: String($0)) }
274+
scope = Set(scopeArray.split(separator: " ").compactMap { OAuth2Scope.init(rawValue: String($0)) })
275275
}
276276
}
277277

0 commit comments

Comments
 (0)