forked from signalapp/Signal-iOS
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09ea92c
commit 7ae43ef
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
SignalMessaging/Loki/Migrations/LK002RemoveFriendRequests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
@objc | ||
public class LK002RemoveFriendRequests : OWSDatabaseMigration { | ||
|
||
@objc | ||
class func migrationId() -> String { | ||
return "971284781" | ||
} | ||
|
||
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) { | ||
self.doMigrationAsync(completion: completion) | ||
} | ||
|
||
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) { | ||
DispatchQueue.global().async { | ||
try! Storage.writeSync { transaction in | ||
var interactionIDsToRemove: [String] = [] | ||
transaction.enumerateRows(inCollection: TSInteraction.collection()) { key, object, _, _ in | ||
if !(object is TSInteraction) { | ||
interactionIDsToRemove.append(key) | ||
} | ||
} | ||
interactionIDsToRemove.forEach { transaction.removeObject(forKey: $0, inCollection: TSInteraction.collection()) } | ||
self.save(with: transaction) | ||
} | ||
completion() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters