Skip to content

Commit

Permalink
feat: improvement initializer of Instance.Platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
makinosp committed Nov 4, 2024
1 parent 44d2e02 commit 56492ad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/VRCKit/Models/World/InstanceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public struct Instance: Sendable, Identifiable, Hashable, Decodable {
public let userCount: Int
public let world: World

@MemberwiseInit(.public)
public struct Platforms: Sendable, Hashable, Codable {
@Init(default: 0) public let android: Int
@Init(default: 0) public let ios: Int
Expand Down Expand Up @@ -93,6 +92,18 @@ public extension Instance {
}
}

public extension Instance.Platforms {
/// Initialize from an array of UserPlatform
/// - Parameter platforms: An array of UserPlatform
init(platforms: [UserPlatform]) {
self.init(
android: platforms.contains(.android) ? 1 : 0,
ios: platforms.contains(.ios) ? 1 : 0,
standalonewindows: platforms.contains(.standalonewindows) ? 1 : 0
)
}
}

extension Instance.GroupAccessType {
var typeDescription: Instance.InstanceTypeAlias {
switch self {
Expand Down

0 comments on commit 56492ad

Please sign in to comment.