mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Refactoring
This commit is contained in:
parent
895927cc04
commit
24a8662813
3
submodules/AsyncDisplayKit/BUILD
vendored
3
submodules/AsyncDisplayKit/BUILD
vendored
@ -14,6 +14,9 @@ objc_library(
|
||||
"Source/**/*.m",
|
||||
"Source/**/*.mm",
|
||||
]) + private_headers,
|
||||
copts = [
|
||||
"-Werror",
|
||||
],
|
||||
hdrs = public_headers,
|
||||
defines = [
|
||||
"MINIMAL_ASDK",
|
||||
|
@ -68,6 +68,9 @@ static ASDisplayNodeNonFatalErrorBlock _nonFatalErrorBlock = nil;
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wincomplete-implementation"
|
||||
|
||||
@implementation ASDisplayNode
|
||||
|
||||
@dynamic layoutElementType;
|
||||
@ -386,9 +389,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
- (instancetype)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
|
||||
if (!(self = [self init])) {
|
||||
return nil;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
[self setViewBlock:viewBlock];
|
||||
if (didLoadBlock != nil) {
|
||||
@ -405,9 +411,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
|
||||
if (!(self = [self init])) {
|
||||
return nil;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
[self setLayerBlock:layerBlock];
|
||||
if (didLoadBlock != nil) {
|
||||
@ -3816,3 +3825,5 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
@ -687,7 +687,10 @@
|
||||
}
|
||||
|
||||
- (bool)isCurrentlyEmoji {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
NSString *value = [[UITextInputMode currentInputMode] primaryLanguage];
|
||||
#pragma clang diagnostic pop
|
||||
if ([value isEqualToString:@"emoji"]) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -133,7 +133,6 @@ AS_CATEGORY_IMPLEMENTABLE
|
||||
* @note This method should not be called directly outside of ASDisplayNode; use -layoutThatFits: or -calculatedLayout instead.
|
||||
*/
|
||||
- (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize;
|
||||
- (CGSize)calculateSizeThatFits:(CGSize)contrainedSize;
|
||||
|
||||
/**
|
||||
* ASDisplayNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size
|
||||
|
@ -16,10 +16,6 @@
|
||||
#import <map>
|
||||
#import <mutex>
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#warning "Texture must be compiled with std=c++11 to prevent layout issues. gnu++ is not supported. This is hopefully temporary."
|
||||
#endif
|
||||
|
||||
AS_EXTERN NSRunLoopMode const UITrackingRunLoopMode;
|
||||
|
||||
NSInteger const ASDefaultTransactionPriority = 0;
|
||||
|
@ -294,9 +294,7 @@ static void CollectAccessibilityElementsForView(UIView *view, NSMutableArray *el
|
||||
if (viewNode == nil) {
|
||||
return @[];
|
||||
}
|
||||
if (true || _accessibilityElements == nil) {
|
||||
_accessibilityElements = [viewNode accessibilityElements];
|
||||
}
|
||||
_accessibilityElements = [viewNode accessibilityElements];
|
||||
return _accessibilityElements;
|
||||
}
|
||||
|
||||
|
@ -588,8 +588,8 @@ static UIColor *defaultTintColor = nil;
|
||||
_flags.setSemanticContentAttribute = YES;
|
||||
}
|
||||
|
||||
- (void)setAccessibilityCustomActions:(NSArray<UIAccessibilityCustomAction *> *)accessibilityCustomActions {
|
||||
self->accessibilityCustomActions = accessibilityCustomActions;
|
||||
- (void)setAccessibilityCustomActions:(NSArray<UIAccessibilityCustomAction *> *)accessibilityCustomActions_ {
|
||||
self->accessibilityCustomActions = accessibilityCustomActions_;
|
||||
_flags.setAccessibilityCustomActions = YES;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ objc_library(
|
||||
"Sources/*.m",
|
||||
]),
|
||||
copts = [
|
||||
"-Werror",
|
||||
"-DAPP_CONFIG_API_ID={}".format(telegram_api_id),
|
||||
"-DAPP_CONFIG_API_HASH=\\\"{}\\\"".format(telegram_api_hash),
|
||||
"-DAPP_CONFIG_APP_CENTER_ID=\\\"{}\\\"".format(telegram_app_center_id),
|
||||
|
@ -22,8 +22,8 @@
|
||||
+ (DeviceSpecificEncryptionParameters * _Nonnull)deviceSpecificEncryptionParameters:(NSString * _Nonnull)rootPath baseAppBundleId:(NSString * _Nonnull)baseAppBundleId;
|
||||
- (NSData * _Nullable)bundleDataWithAppToken:(NSData * _Nullable)appToken signatureDict:(NSDictionary * _Nullable)signatureDict;
|
||||
|
||||
+ (void)getHardwareEncryptionAvailableWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable))completion;
|
||||
+ (void)encryptApplicationSecret:(NSData * _Nonnull)secret baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable, NSData * _Nullable))completion;
|
||||
+ (void)decryptApplicationSecret:(NSData * _Nonnull)secret publicKey:(NSData * _Nonnull)publicKey baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^)(NSData * _Nullable, bool))completion;
|
||||
+ (void)getHardwareEncryptionAvailableWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable))completion;
|
||||
+ (void)encryptApplicationSecret:(NSData * _Nonnull)secret baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable, NSData * _Nullable))completion;
|
||||
+ (void)decryptApplicationSecret:(NSData * _Nonnull)secret publicKey:(NSData * _Nonnull)publicKey baseAppBundleId:(NSString * _Nonnull)baseAppBundleId completion:(void (^ _Nonnull)(NSData * _Nullable, bool))completion;
|
||||
|
||||
@end
|
||||
|
@ -207,7 +207,7 @@ API_AVAILABLE(ios(10))
|
||||
return bundleSeedID;
|
||||
}
|
||||
|
||||
+ (NSString * _Nonnull)applicationSecretTag:(bool)isCheckKey {
|
||||
+ (NSData * _Nullable)applicationSecretTag:(bool)isCheckKey {
|
||||
if (isCheckKey) {
|
||||
return [[telegramApplicationSecretKey stringByAppendingString:@"_check"] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
} else {
|
||||
@ -349,7 +349,7 @@ API_AVAILABLE(ios(10))
|
||||
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
|
||||
|
||||
NSString *filePath = [rootPath stringByAppendingPathComponent:@".tempkey"];
|
||||
NSString *encryptedPath = [rootPath stringByAppendingPathComponent:@".tempkeyEncrypted"];
|
||||
//NSString *encryptedPath = [rootPath stringByAppendingPathComponent:@".tempkeyEncrypted"];
|
||||
|
||||
NSData *currentData = [NSData dataWithContentsOfFile:filePath];
|
||||
NSData *resultData = nil;
|
||||
|
@ -7,6 +7,9 @@ objc_library(
|
||||
"Sources/**/*.m",
|
||||
"Sources/**/*.h",
|
||||
]),
|
||||
copts = [
|
||||
"-Werror",
|
||||
],
|
||||
hdrs = glob([
|
||||
"PublicHeaders/**/*.h",
|
||||
]),
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
@interface BuildConfigExtra : NSObject
|
||||
|
||||
- (instancetype _Nonnull)initWithBaseAppBundleId:(NSString * _Nonnull)baseAppBundleId;
|
||||
|
||||
+ (NSDictionary * _Nonnull)signatureDict;
|
||||
|
||||
@end
|
||||
|
@ -11,7 +11,6 @@ swift_library(
|
||||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/MtProtoKit:MtProtoKit",
|
||||
"//submodules/EncryptionProvider:EncryptionProvider",
|
||||
],
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ItemListUI
|
||||
@ -11,6 +10,7 @@ import AccountContext
|
||||
import AlertUI
|
||||
import PresentationDataUtils
|
||||
import TextFormat
|
||||
import Postbox
|
||||
|
||||
private struct OrderedLinkedListItemOrderingId: RawRepresentable, Hashable {
|
||||
var rawValue: Int
|
||||
@ -423,7 +423,7 @@ private struct CreatePollControllerState: Equatable {
|
||||
var isEditingSolution: Bool = false
|
||||
}
|
||||
|
||||
private func createPollControllerEntries(presentationData: PresentationData, peer: Peer, state: CreatePollControllerState, limitsConfiguration: LimitsConfiguration, defaultIsQuiz: Bool?) -> [CreatePollEntry] {
|
||||
private func createPollControllerEntries(presentationData: PresentationData, peer: EnginePeer, state: CreatePollControllerState, limitsConfiguration: EngineConfiguration.Limits, defaultIsQuiz: Bool?) -> [CreatePollEntry] {
|
||||
var entries: [CreatePollEntry] = []
|
||||
|
||||
var textLimitText = ItemListSectionHeaderAccessoryText(value: "", color: .generic)
|
||||
@ -453,7 +453,7 @@ private func createPollControllerEntries(presentationData: PresentationData, pee
|
||||
}
|
||||
|
||||
var canBePublic = true
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
if case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||
canBePublic = false
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ private func createPollControllerEntries(presentationData: PresentationData, pee
|
||||
return entries
|
||||
}
|
||||
|
||||
public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bool? = nil, completion: @escaping (EnqueueMessage) -> Void) -> ViewController {
|
||||
public func createPollController(context: AccountContext, peer: EnginePeer, isQuiz: Bool? = nil, completion: @escaping (EnqueueMessage) -> Void) -> ViewController {
|
||||
var initialState = CreatePollControllerState()
|
||||
if let isQuiz = isQuiz {
|
||||
initialState.isQuiz = isQuiz
|
||||
@ -742,12 +742,13 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo
|
||||
})
|
||||
|
||||
let previousOptionIds = Atomic<[Int]?>(value: nil)
|
||||
|
||||
let limitsKey = PostboxViewKey.preferences(keys: Set([PreferencesKeys.limitsConfiguration]))
|
||||
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get() |> deliverOnMainQueue, context.account.postbox.combinedView(keys: [limitsKey]))
|
||||
|> map { presentationData, state, combinedView -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
let limitsConfiguration: LimitsConfiguration = (combinedView.views[limitsKey] as? PreferencesView)?.values[PreferencesKeys.limitsConfiguration] as? LimitsConfiguration ?? LimitsConfiguration.defaultValue
|
||||
|
||||
|
||||
let signal = combineLatest(queue: .mainQueue(),
|
||||
context.sharedContext.presentationData,
|
||||
statePromise.get(),
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.Limits())
|
||||
)
|
||||
|> map { presentationData, state, limitsConfiguration -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
var enabled = true
|
||||
if processPollText(state.text).isEmpty {
|
||||
enabled = false
|
||||
|
@ -0,0 +1,93 @@
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
||||
public enum EngineConfiguration {
|
||||
public struct Limits: Equatable {
|
||||
public static let timeIntervalForever: Int32 = 0x7fffffff
|
||||
|
||||
public var maxPinnedChatCount: Int32
|
||||
public var maxArchivedPinnedChatCount: Int32
|
||||
public var maxGroupMemberCount: Int32
|
||||
public var maxSupergroupMemberCount: Int32
|
||||
public var maxMessageForwardBatchSize: Int32
|
||||
public var maxSavedGifCount: Int32
|
||||
public var maxRecentStickerCount: Int32
|
||||
public var maxMessageEditingInterval: Int32
|
||||
public var maxMediaCaptionLength: Int32
|
||||
public var canRemoveIncomingMessagesInPrivateChats: Bool
|
||||
public var maxMessageRevokeInterval: Int32
|
||||
public var maxMessageRevokeIntervalInPrivateChats: Int32
|
||||
|
||||
public init(
|
||||
maxPinnedChatCount: Int32,
|
||||
maxArchivedPinnedChatCount: Int32,
|
||||
maxGroupMemberCount: Int32,
|
||||
maxSupergroupMemberCount: Int32,
|
||||
maxMessageForwardBatchSize: Int32,
|
||||
maxSavedGifCount: Int32,
|
||||
maxRecentStickerCount: Int32,
|
||||
maxMessageEditingInterval: Int32,
|
||||
maxMediaCaptionLength: Int32,
|
||||
canRemoveIncomingMessagesInPrivateChats: Bool,
|
||||
maxMessageRevokeInterval: Int32,
|
||||
maxMessageRevokeIntervalInPrivateChats: Int32
|
||||
) {
|
||||
self.maxPinnedChatCount = maxPinnedChatCount
|
||||
self.maxArchivedPinnedChatCount = maxArchivedPinnedChatCount
|
||||
self.maxGroupMemberCount = maxGroupMemberCount
|
||||
self.maxSupergroupMemberCount = maxSupergroupMemberCount
|
||||
self.maxMessageForwardBatchSize = maxMessageForwardBatchSize
|
||||
self.maxSavedGifCount = maxSavedGifCount
|
||||
self.maxRecentStickerCount = maxRecentStickerCount
|
||||
self.maxMessageEditingInterval = maxMessageEditingInterval
|
||||
self.maxMediaCaptionLength = maxMediaCaptionLength
|
||||
self.canRemoveIncomingMessagesInPrivateChats = canRemoveIncomingMessagesInPrivateChats
|
||||
self.maxMessageRevokeInterval = maxMessageRevokeInterval
|
||||
self.maxMessageRevokeIntervalInPrivateChats = maxMessageRevokeIntervalInPrivateChats
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension EngineConfiguration.Limits {
|
||||
init(_ limitsConfiguration: LimitsConfiguration) {
|
||||
self.init(
|
||||
maxPinnedChatCount: limitsConfiguration.maxPinnedChatCount,
|
||||
maxArchivedPinnedChatCount: limitsConfiguration.maxArchivedPinnedChatCount,
|
||||
maxGroupMemberCount: limitsConfiguration.maxGroupMemberCount,
|
||||
maxSupergroupMemberCount: limitsConfiguration.maxSupergroupMemberCount,
|
||||
maxMessageForwardBatchSize: limitsConfiguration.maxMessageForwardBatchSize,
|
||||
maxSavedGifCount: limitsConfiguration.maxSavedGifCount,
|
||||
maxRecentStickerCount: limitsConfiguration.maxRecentStickerCount,
|
||||
maxMessageEditingInterval: limitsConfiguration.maxMessageEditingInterval,
|
||||
maxMediaCaptionLength: limitsConfiguration.maxMediaCaptionLength,
|
||||
canRemoveIncomingMessagesInPrivateChats: limitsConfiguration.canRemoveIncomingMessagesInPrivateChats,
|
||||
maxMessageRevokeInterval: limitsConfiguration.maxMessageRevokeInterval,
|
||||
maxMessageRevokeIntervalInPrivateChats: limitsConfiguration.maxMessageRevokeIntervalInPrivateChats
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public extension TelegramEngine.EngineData.Item {
|
||||
enum Configuration {
|
||||
public struct Limits: TelegramEngineDataItem, PostboxViewDataItem {
|
||||
public typealias Result = EngineConfiguration.Limits
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
var key: PostboxViewKey {
|
||||
return .preferences(keys: Set([PreferencesKeys.limitsConfiguration]))
|
||||
}
|
||||
|
||||
func extract(view: PostboxView) -> Result {
|
||||
guard let view = view as? PreferencesView else {
|
||||
preconditionFailure()
|
||||
}
|
||||
guard let limitsConfiguration = view.values[PreferencesKeys.limitsConfiguration] as? LimitsConfiguration else {
|
||||
return EngineConfiguration.Limits(LimitsConfiguration.defaultValue)
|
||||
}
|
||||
return EngineConfiguration.Limits(limitsConfiguration)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9689,7 +9689,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
private func presentPollCreation(isQuiz: Bool? = nil) {
|
||||
if let peer = self.presentationInterfaceState.renderedPeer?.peer {
|
||||
self.effectiveNavigationController?.pushViewController(createPollController(context: self.context, peer: peer, isQuiz: isQuiz, completion: { [weak self] message in
|
||||
self.effectiveNavigationController?.pushViewController(createPollController(context: self.context, peer: EnginePeer(peer), isQuiz: isQuiz, completion: { [weak self] message in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user