Clean
This commit is contained in:
parent
74d1bfd1ec
commit
918a346d66
|
@ -156,7 +156,7 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|||
self?.dismiss(animated: true, completion: nil) // Dismiss the loader
|
||||
var title = "Couldn't Join"
|
||||
var message = ""
|
||||
if case OnionRequestAPI.Error.httpRequestFailedAtTargetSnode(statusCode: let statusCode, json: _) = error, statusCode == 401 || statusCode == 403 {
|
||||
if case OnionRequestAPI.Error.httpRequestFailedAtDestination(let statusCode, _) = error, statusCode == 401 || statusCode == 403 {
|
||||
title = "Unauthorized"
|
||||
message = "Please ask the open group operator to add you to the group."
|
||||
}
|
||||
|
|
|
@ -187,7 +187,11 @@ const CGFloat kIconViewLength = 24;
|
|||
|
||||
- (BOOL)isOpenGroupChat
|
||||
{
|
||||
return [self isGroupThread] && ![self isPrivateGroupChat];
|
||||
if ([self isGroupThread]) {
|
||||
TSGroupThread *thread = (TSGroupThread *)self.thread;
|
||||
return thread.isPublicChat;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
-(BOOL)isPrivateGroupChat
|
||||
|
@ -541,14 +545,13 @@ const CGFloat kIconViewLength = 24;
|
|||
[topRow autoPinEdgesToSuperviewMarginsExcludingEdge:ALEdgeBottom];
|
||||
|
||||
UILabel *subtitleLabel = [UILabel new];
|
||||
NSString *threadName;
|
||||
// TODO: Modify the text content
|
||||
NSString *displayName;
|
||||
if (self.thread.isGroupThread) {
|
||||
threadName = @"the group";
|
||||
displayName = @"the group";
|
||||
} else {
|
||||
threadName = [LKUserDisplayNameUtilities getPrivateChatDisplayNameFor:self.thread.contactIdentifier];
|
||||
displayName = [LKUserDisplayNameUtilities getPrivateChatDisplayNameFor:self.thread.contactIdentifier];
|
||||
}
|
||||
subtitleLabel.text = [NSString stringWithFormat:NSLocalizedString(@"When enabled, messages between you and %@ will disappear after they have been seen.", ""), threadName];
|
||||
subtitleLabel.text = [NSString stringWithFormat:NSLocalizedString(@"When enabled, messages between you and %@ will disappear after they have been seen.", ""), displayName];
|
||||
subtitleLabel.textColor = LKColors.text;
|
||||
subtitleLabel.font = [UIFont systemFontOfSize:LKValues.smallFontSize];
|
||||
subtitleLabel.numberOfLines = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@ public enum OnionRequestAPI {
|
|||
|
||||
// MARK: Error
|
||||
public enum Error : LocalizedError {
|
||||
case httpRequestFailedAtTargetSnode(statusCode: UInt, json: JSON)
|
||||
case httpRequestFailedAtDestination(statusCode: UInt, json: JSON)
|
||||
case insufficientSnodes
|
||||
case invalidURL
|
||||
case missingSnodeVersion
|
||||
|
@ -37,7 +37,7 @@ public enum OnionRequestAPI {
|
|||
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case .httpRequestFailedAtTargetSnode(let statusCode): return "HTTP request failed at target snode with status code: \(statusCode)."
|
||||
case .httpRequestFailedAtDestination(let statusCode): return "HTTP request failed at destination with status code: \(statusCode)."
|
||||
case .insufficientSnodes: return "Couldn't find enough snodes to build a path."
|
||||
case .invalidURL: return "Invalid URL"
|
||||
case .missingSnodeVersion: return "Missing snode version."
|
||||
|
@ -226,7 +226,7 @@ public enum OnionRequestAPI {
|
|||
internal static func sendOnionRequest(to snode: Snode, invoking method: Snode.Method, with parameters: JSON, associatedWith publicKey: String) -> Promise<JSON> {
|
||||
let payload: JSON = [ "method" : method.rawValue, "params" : parameters ]
|
||||
return sendOnionRequest(with: payload, to: Destination.snode(snode)).recover2 { error -> Promise<JSON> in
|
||||
guard case OnionRequestAPI.Error.httpRequestFailedAtTargetSnode(let statusCode, let json) = error else { throw error }
|
||||
guard case OnionRequestAPI.Error.httpRequestFailedAtDestination(let statusCode, let json) = error else { throw error }
|
||||
throw SnodeAPI.handleError(withStatusCode: statusCode, json: json, forSnode: snode, associatedWith: publicKey) ?? error
|
||||
}
|
||||
}
|
||||
|
@ -322,10 +322,10 @@ public enum OnionRequestAPI {
|
|||
let b = try JSONSerialization.jsonObject(with: bodyAsData, options: [ .fragmentsAllowed ]) as? JSON else { return seal.reject(HTTP.Error.invalidJSON) }
|
||||
body = b
|
||||
}
|
||||
guard 200...299 ~= statusCode else { return seal.reject(Error.httpRequestFailedAtTargetSnode(statusCode: UInt(statusCode), json: body)) }
|
||||
guard 200...299 ~= statusCode else { return seal.reject(Error.httpRequestFailedAtDestination(statusCode: UInt(statusCode), json: body)) }
|
||||
seal.fulfill(body)
|
||||
} else {
|
||||
guard 200...299 ~= statusCode else { return seal.reject(Error.httpRequestFailedAtTargetSnode(statusCode: UInt(statusCode), json: json)) }
|
||||
guard 200...299 ~= statusCode else { return seal.reject(Error.httpRequestFailedAtDestination(statusCode: UInt(statusCode), json: json)) }
|
||||
seal.fulfill(json)
|
||||
}
|
||||
} catch {
|
||||
|
|
|
@ -529,7 +529,7 @@ internal extension Promise {
|
|||
|
||||
internal func handlingInvalidAuthTokenIfNeeded(for server: String) -> Promise<T> {
|
||||
return recover2 { error -> Promise<T> in
|
||||
if case OnionRequestAPI.Error.httpRequestFailedAtTargetSnode(let statusCode, _) = error, statusCode == 401 || statusCode == 403 {
|
||||
if case OnionRequestAPI.Error.httpRequestFailedAtDestination(let statusCode, _) = error, statusCode == 401 || statusCode == 403 {
|
||||
print("[Loki] Auth token for: \(server) expired; dropping it.")
|
||||
PublicChatAPI.removeAuthToken(for: server)
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public final class LokiPushNotificationManager : NSObject {
|
|||
return print("[Loki] Couldn't acknowledge delivery for message with hash: \(hash) due to error: \(json["message"] as? String ?? "nil").")
|
||||
}
|
||||
}, failure: { _, error in
|
||||
print("[Loki] Couldn't acknowledge delivery for message with hash: \(hash).")
|
||||
print("[Loki] Couldn't acknowledge delivery for message with hash: \(hash) due to error: \(error).")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue