Skip to content

Commit

Permalink
rename to AvailabilityKind
Browse files Browse the repository at this point in the history
  • Loading branch information
billypchan committed May 31, 2021
1 parent 136c16c commit 0c1453a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Source/Model/User/UserType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public protocol UserType: NSObjectProtocol, UserConnections {
var isFederated: Bool { get }

/// The availability of the user
var availability: Availability { get set }
var availability: AvailabilityKind { get set }

/// The name of the team the user belongs to.
var teamName: String? { get }
Expand Down
2 changes: 1 addition & 1 deletion Source/Model/User/ZMSearchUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class ZMSearchUser: NSObject, UserType {
}
}

public var availability: Availability {
public var availability: AvailabilityKind {
get { return user?.availability ?? .none }
set { user?.availability = newValue }
}
Expand Down
10 changes: 5 additions & 5 deletions Source/Model/User/ZMUser+Availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import Foundation

@objc
public enum Availability : Int, CaseIterable {
public enum AvailabilityKind : Int, CaseIterable {
case none, available, busy, away

public init(proto: WireProtos.Availability) {
Expand Down Expand Up @@ -125,13 +125,13 @@ extension ZMUser {
return Set(result)
}

@objc public var availability : Availability {
@objc public var availability : AvailabilityKind {
get {
self.willAccessValue(forKey: AvailabilityKey)
let value = (self.primitiveValue(forKey: AvailabilityKey) as? NSNumber) ?? NSNumber(value: 0)
self.didAccessValue(forKey: AvailabilityKey)

return Availability(rawValue: value.intValue) ?? .none
return AvailabilityKind(rawValue: value.intValue) ?? .none
}

set {
Expand All @@ -141,14 +141,14 @@ extension ZMUser {
}
}

internal func updateAvailability(_ newValue : Availability) {
internal func updateAvailability(_ newValue : AvailabilityKind) {
self.willChangeValue(forKey: AvailabilityKey)
self.setPrimitiveValue(NSNumber(value: newValue.rawValue), forKey: AvailabilityKey)
self.didChangeValue(forKey: AvailabilityKey)
}

public func updateAvailability(from genericMessage : GenericMessage) {
updateAvailability(Availability(proto: genericMessage.availability))
updateAvailability(AvailabilityKind(proto: genericMessage.availability))
}

private static let needsToNotifyAvailabilityBehaviourChangeKey = "needsToNotifyAvailabilityBehaviourChange"
Expand Down
2 changes: 1 addition & 1 deletion Source/Utilis/Protos/GenericMessage+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public enum MentionFactory {
// MARK: - Availability

public enum AvailabilityFactory {
public static func createAvailability(availability: Availability) -> WireProtos.Availability {
public static func createAvailability(availability: AvailabilityKind) -> WireProtos.Availability {
return WireProtos.Availability.with {
switch availability {
case .none:
Expand Down

0 comments on commit 0c1453a

Please sign in to comment.