Only prepare group members for migration just before the migration.

This commit is contained in:
Matthew Chen 2020-10-30 10:39:22 -03:00
parent 43944545b6
commit 11368d5b28
3 changed files with 4 additions and 4 deletions

View File

@ -171,7 +171,7 @@ class TestingViewController: OWSTableViewController {
let section = OWSTableSection()
section.footerTitle = LocalizationNotNeeded("Make sure to force-enable auto-migrations above first.")
section.add(OWSTableItem.actionItem(withText: LocalizationNotNeeded("Groups v2: Auto-migrate all v1 groups")) {
GroupsV2Migration.tryToAutoMigrateAllGroups()
GroupsV2Migration.tryToAutoMigrateAllGroups(shouldLimitBatchSize: false)
})
contents.addSection(section)
}

View File

@ -78,7 +78,7 @@ public class GroupsV2Impl: NSObject, GroupsV2Swift {
Self.enqueueRestoreGroupPass()
GroupsV2Migration.tryToAutoMigrateAllGroups()
GroupsV2Migration.tryToAutoMigrateAllGroups(shouldLimitBatchSize: true)
}
observeNotifications()

View File

@ -160,7 +160,7 @@ public extension GroupsV2Migration {
return true
}
static func tryToAutoMigrateAllGroups() {
static func tryToAutoMigrateAllGroups(shouldLimitBatchSize: Bool) {
AssertIsOnMainThread()
guard FeatureFlags.groupsV2Migrations else {
@ -211,7 +211,7 @@ public extension GroupsV2Migration {
// Check up to N groups on every launch.
let maxCheckCount: Int = 50
if groupThreads.count > maxCheckCount {
if shouldLimitBatchSize, groupThreads.count > maxCheckCount {
groupThreads.shuffle()
groupThreads = Array(groupThreads.prefix(upTo: maxCheckCount))
}