Merge pull request #247 from RyanRory/crash-fix

Crash Fixes
pull/248/head
Niels Andriesse 4 years ago committed by GitHub
commit 8cbad6c69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -199,7 +199,14 @@ public class MessageFetcherJob: NSObject {
}
private func fetchUndeliveredMessages() -> Promise<Set<Promise<[SSKProtoEnvelope]>>> {
return SnodeAPI.getMessages(for: getUserHexEncodedPublicKey())
// In some cases like deleting an account
// the backgroud fetch was not stopped
// so the identityKeyPair can be nil
let userPublickKey = getUserHexEncodedPublicKey()
if !userPublickKey.isEmpty {
return SnodeAPI.getMessages(for: userPublickKey)
}
return Promise.value(Set())
}
private func acknowledgeDelivery(envelope: SSKProtoEnvelope) {

@ -705,7 +705,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
if (self.hasBodyText && message.linkPreview) {
self.linkPreview = message.linkPreview;
if (message.linkPreview.imageAttachmentId.length > 0) {
if (message.linkPreview.imageAttachmentId && message.linkPreview.imageAttachmentId.length) {
TSAttachment *_Nullable linkPreviewAttachment =
[TSAttachment fetchObjectWithUniqueID:message.linkPreview.imageAttachmentId transaction:transaction];
if (!linkPreviewAttachment) {

@ -127,11 +127,19 @@ class SendMediaNavigationController: OWSNavigationController {
}
private func didTapCameraModeButton() {
fadeTo(viewControllers: [captureViewController])
self.ows_ask(forCameraPermissions: { granted in
if (granted) {
self.fadeTo(viewControllers: [self.captureViewController])
}
})
}
private func didTapMediaLibraryModeButton() {
fadeTo(viewControllers: [mediaLibraryViewController])
self.ows_ask(forMediaLibraryPermissions: { granted in
if (granted) {
self.fadeTo(viewControllers: [self.mediaLibraryViewController])
}
})
}
// MARK: Views

@ -192,7 +192,7 @@ public enum PushRegistrationError: Error {
}.map { (pushTokenData: Data) -> String in
if self.isSusceptibleToFailedPushRegistration {
// Sentinal in case this bug is fixed
owsFailDebug("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
OWSLogger.debug("Device was unexpectedly able to complete push registration even though it was susceptible to failure.")
}
return pushTokenData.hexEncodedString

@ -456,7 +456,7 @@ typedef void (^BuildOutgoingMessageCompletionBlock)(TSOutgoingMessage *savedMess
} else {
TSInteraction *_Nullable firstUnseenInteraction =
[[TSDatabaseView unseenDatabaseViewExtension:transaction] firstObjectInGroup:thread.uniqueId];
if (firstUnseenInteraction) {
if (firstUnseenInteraction && firstUnseenInteraction.sortId != NULL) {
firstUnseenSortId = @(firstUnseenInteraction.sortId);
}
}

@ -1,4 +1,10 @@
public func getUserHexEncodedPublicKey() -> String {
return OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
// In some cases like deleting an account
// the backgroud fetch was not stopped
// so the identityKeyPair can be nil
if let keyPair = OWSIdentityManager.shared().identityKeyPair() {
return keyPair.hexEncodedPublicKey
}
return ""
}

Loading…
Cancel
Save