Skip to content

Commit

Permalink
refact: refactoring trust rank model
Browse files Browse the repository at this point in the history
  • Loading branch information
makinosp committed Nov 13, 2024
1 parent 6f568ff commit 041ff7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Sources/VRCKit/Models/Tag/SystemTagModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public enum SystemTag: String, Hashable, Codable, Sendable {
case systemWorldAccess = "system_world_access"
}

extension SystemTag {
static let rankTags: Set<Self> = [
.systemTrustVeteran,
.systemTrustTrusted,
.systemTrustKnown,
.systemTrustBasic
]
}

extension SystemTag: Identifiable {
public var id: String { rawValue }
}
14 changes: 5 additions & 9 deletions Sources/VRCKit/Models/Tag/TrustRankModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@ public enum TrustRank: Equatable, Sendable {
}

public extension ProfileElementRepresentable {
var systemTag: SystemTag? {
SystemTag.rankTags.first { tags.systemTags.contains($0) }
}
var trustRank: TrustRank {
let rankTags: [SystemTag] = [
.systemTrustVeteran,
.systemTrustTrusted,
.systemTrustKnown,
.systemTrustBasic
]
let rankTag = rankTags.first { tags.systemTags.contains($0) }
guard let rankTag = rankTag else { return .visitor }
return switch rankTag {
switch systemTag {
case .systemTrustVeteran: .trusted
case .systemTrustTrusted: .known
case .systemTrustKnown: .user
case .systemTrustBasic: .newUser
case nil: .visitor
default: .unknown
}
}
Expand Down

0 comments on commit 041ff7e

Please sign in to comment.