Rework maxGroupsV2MemberCount remote config flag.

This commit is contained in:
Matthew Chen 2020-08-10 15:55:26 -03:00
parent bdc9dd33a8
commit eb6f43cf07
6 changed files with 19 additions and 12 deletions

View File

@ -162,7 +162,7 @@ public class BaseGroupMemberViewController: OWSViewController {
memberCountLabel.text = String(format: format,
OWSFormat.formatInt(memberCount),
OWSFormat.formatUInt(GroupManager.maxGroupMemberCount))
OWSFormat.formatUInt(GroupManager.maxGroupsV2MemberCount))
}
public func removeRecipient(_ recipient: PickedRecipient) {

View File

@ -96,7 +96,7 @@ extension NewGroupMembersViewController: GroupMemberViewDelegate {
guard RemoteConfig.groupsV2CreateGroups else {
return false
}
return groupMemberViewGroupMemberCount(withSelf: true) >= GroupManager.maxGroupMemberCount
return groupMemberViewGroupMemberCount(withSelf: true) >= GroupManager.maxGroupsV2MemberCount
}
func groupMemberViewIsPreExistingMember(_ recipient: PickedRecipient) -> Bool {

View File

@ -256,12 +256,12 @@ extension AddGroupMembersViewController: GroupMemberViewDelegate {
guard groupThread.isGroupV2Thread else {
return false
}
return groupMemberViewGroupMemberCountForDisplay() >= GroupManager.maxGroupMemberCount
return groupMemberViewGroupMemberCountForDisplay() >= GroupManager.maxGroupsV2MemberCount
}
func groupMemberViewMaxMemberCount() -> UInt? {
return (groupThread.isGroupV2Thread
? GroupManager.maxGroupMemberCount
? GroupManager.maxGroupsV2MemberCount
: nil)
}

View File

@ -474,7 +474,7 @@ public class GroupsV2ChangeSetImpl: NSObject, GroupsV2ChangeSet {
continue
}
guard allMemberCount <= GroupManager.maxGroupMemberCount else {
guard allMemberCount <= GroupManager.maxGroupsV2MemberCount else {
throw GroupsV2Error.tooManyMembers
}

View File

@ -82,13 +82,13 @@ public class RemoteConfig: BaseFlags {
}
@objc
public static var groupsV2maxMemberCount: UInt {
public static var maxGroupsV2MemberCount: UInt {
let defaultValue: UInt = 151
guard AppReadiness.isAppReady else {
owsFailDebug("Storage is not yet ready.")
return defaultValue
}
guard let rawValue: AnyObject = value(.groupsV2memberCountMax) else {
guard let rawValue: AnyObject = value(.maxGroupsV2MemberCount) else {
return defaultValue
}
guard let stringValue = rawValue as? String else {
@ -212,7 +212,7 @@ private struct Flags {
// Values defined in this array remain set once they are
// set regardless of the remote state.
enum StickyValuesFlags: String, FlagType {
case groupsV2memberCountMax
case maxGroupsV2MemberCount
}
// We filter the received config down to just the supported values.
@ -220,7 +220,7 @@ private struct Flags {
// set because we cached a value before it went public. e.g. if we set
// a sticky value to X in beta then remove it before going to production.
enum SupportedValuesFlags: String, FlagType {
case groupsV2memberCountMax
case maxGroupsV2MemberCount
}
}
@ -235,7 +235,14 @@ private protocol FlagType: CaseIterable {
// MARK: -
private extension FlagType {
var rawFlag: String { Flags.prefix + rawValue }
var rawFlag: String {
if rawValue == "maxGroupsV2MemberCount" {
return "all.groupsv2.capacity"
} else {
return Flags.prefix + rawValue
}
}
static var allRawFlags: [String] { allCases.map { $0.rawFlag } }
}

View File

@ -91,8 +91,8 @@ public class GroupManager: NSObject {
// GroupsV2 TODO: Finalize this value with the designers.
public static let groupUpdateTimeoutDuration: TimeInterval = 30
public static var maxGroupMemberCount: UInt {
return RemoteConfig.groupsV2maxMemberCount
public static var maxGroupsV2MemberCount: UInt {
return RemoteConfig.maxGroupsV2MemberCount
}
public static let maxGroupNameLength: Int = 32