diff --git a/TelegramUI/ChatController.swift b/TelegramUI/ChatController.swift index 360e2f8a93..d030b16afc 100644 --- a/TelegramUI/ChatController.swift +++ b/TelegramUI/ChatController.swift @@ -1258,7 +1258,7 @@ public final class ChatController: TelegramController, UIViewControllerPreviewin if case let .peer(peerId) = self.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat { self.screenCaptureEventsDisposable = screenCaptureEvents().start(next: { [weak self] _ in - if let strongSelf = self, strongSelf.canReadHistoryValue { + if let strongSelf = self, strongSelf.canReadHistoryValue, strongSelf.traceVisibility() { let _ = addSecretChatMessageScreenshot(account: account, peerId: peerId).start() } }) @@ -3562,7 +3562,10 @@ public final class ChatController: TelegramController, UIViewControllerPreviewin } private func enqueueChatContextResult(_ results: ChatContextResultCollection, _ result: ChatContextResult) { - if let message = outgoingMessageWithChatContextResult(results, result), canSendMessagesToChat(self.presentationInterfaceState) { + guard case let .peer(peerId) = self.chatLocation else { + return + } + if let message = outgoingMessageWithChatContextResult(to: peerId, results: results, result: result), canSendMessagesToChat(self.presentationInterfaceState) { let replyMessageId = self.presentationInterfaceState.interfaceState.replyMessageId self.chatDisplayNode.setupSendActionOnViewUpdate({ [weak self] in if let strongSelf = self { diff --git a/TelegramUI/DefaultPresentationTheme.swift b/TelegramUI/DefaultPresentationTheme.swift index bbe7851c16..877846f0da 100644 --- a/TelegramUI/DefaultPresentationTheme.swift +++ b/TelegramUI/DefaultPresentationTheme.swift @@ -120,7 +120,7 @@ private func makeDefaultPresentationTheme(accentColor: UIColor, day: Bool) -> Pr unreadBadgeActiveTextColor: .white, unreadBadgeInactiveBackgroundColor: UIColor(rgb: 0xb6b6bb), unreadBadgeInactiveTextColor: .white, - pinnedBadgeColor: UIColor(rgb: 0x939399), + pinnedBadgeColor: UIColor(rgb: 0xb6b6bb), pinnedSearchBarColor: UIColor(rgb: 0xe5e5e5), regularSearchBarColor: UIColor(rgb: 0xe9e9e9), sectionHeaderFillColor: UIColor(rgb: 0xf7f7f7), diff --git a/TelegramUI/OngoingCallThreadLocalContext.mm b/TelegramUI/OngoingCallThreadLocalContext.mm index 10e4851baa..a670fba6d5 100644 --- a/TelegramUI/OngoingCallThreadLocalContext.mm +++ b/TelegramUI/OngoingCallThreadLocalContext.mm @@ -251,8 +251,6 @@ static int callControllerNetworkTypeForType(OngoingCallNetworkType type) { unsigned char peerTag[16]; [connection.peerTag getBytes:peerTag length:16]; endpoints.push_back(tgvoip::Endpoint(connection.connectionId, (uint16_t)connection.port, address, addressv6, tgvoip::Endpoint::TYPE_UDP_RELAY, peerTag)); - /*releasable*/ - //endpoints.push_back(tgvoip::Endpoint(connection.connectionId, (uint16_t)connection.port, address, addressv6, EP_TYPE_UDP_RELAY, peerTag)); } tgvoip::VoIPController::Config config(_callConnectTimeout, _callPacketTimeout, _dataSavingMode, false, true, true); @@ -270,9 +268,9 @@ static int callControllerNetworkTypeForType(OngoingCallNetworkType type) { } - (void)stop { - if (_controller) { + if (_controller != nil) { char *buffer = (char *)malloc(_controller->GetDebugLogLength()); - /*releasable*/ + _controller->Stop(); _controller->GetDebugLog(buffer); NSString *debugLog = [[NSString alloc] initWithUTF8String:buffer]; @@ -296,7 +294,6 @@ static int callControllerNetworkTypeForType(OngoingCallNetworkType type) { - (void)controllerStateChanged:(int)state { OngoingCallState callState = OngoingCallStateInitializing; - /*releasable*/ switch (state) { case tgvoip::STATE_ESTABLISHED: callState = OngoingCallStateConnected; @@ -307,16 +304,6 @@ static int callControllerNetworkTypeForType(OngoingCallNetworkType type) { default: break; } - /*switch (state) { - case STATE_ESTABLISHED: - callState = OngoingCallStateConnected; - break; - case STATE_FAILED: - callState = OngoingCallStateFailed; - break; - default: - break; - }*/ if (callState != _state) { _state = callState; @@ -328,13 +315,17 @@ static int callControllerNetworkTypeForType(OngoingCallNetworkType type) { } - (void)setIsMuted:(bool)isMuted { - _controller->SetMicMute(isMuted); + if (_controller != nil) { + _controller->SetMicMute(isMuted); + } } - (void)setNetworkType:(OngoingCallNetworkType)networkType { if (_networkType != networkType) { _networkType = networkType; - _controller->SetNetworkType(callControllerNetworkTypeForType(networkType)); + if (_controller != nil) { + _controller->SetNetworkType(callControllerNetworkTypeForType(networkType)); + } } } diff --git a/TelegramUI/SecretMediaPreviewController.swift b/TelegramUI/SecretMediaPreviewController.swift index 6aec559048..89386999fd 100644 --- a/TelegramUI/SecretMediaPreviewController.swift +++ b/TelegramUI/SecretMediaPreviewController.swift @@ -168,7 +168,7 @@ public final class SecretMediaPreviewController: ViewController { self.screenCaptureEventsDisposable = (screenCaptureEvents() |> deliverOnMainQueue).start(next: { [weak self] _ in - if let _ = self { + if let strongSelf = self, strongSelf.traceVisibility() { let _ = addSecretChatMessageScreenshot(account: account, peerId: messageId.peerId).start() } }) diff --git a/TelegramUI/StickerResources.swift b/TelegramUI/StickerResources.swift index a5d2da4c79..2170617863 100644 --- a/TelegramUI/StickerResources.swift +++ b/TelegramUI/StickerResources.swift @@ -35,15 +35,18 @@ private func imageFromAJpeg(data: Data) -> (UIImage, UIImage)? { } private func chatMessageStickerDatas(account: Account, file: TelegramMediaFile, small: Bool, fetched: Bool, onlyFullSize: Bool) -> Signal<(Data?, Data?, Bool), NoError> { - let maybeFetched = account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedStickerAJpegRepresentation(size: small ? CGSize(width: 160.0, height: 160.0) : nil), complete: onlyFullSize) + let maybeFetched = account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedStickerAJpegRepresentation(size: small ? CGSize(width: 160.0, height: 160.0) : nil), complete: false) - return maybeFetched |> take(1) |> mapToSignal { maybeData in + return maybeFetched + |> take(1) + |> mapToSignal { maybeData in if maybeData.complete { let loadedData: Data? = try? Data(contentsOf: URL(fileURLWithPath: maybeData.path), options: []) return .single((nil, loadedData, true)) } else { - let fullSizeData = account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedStickerAJpegRepresentation(size: small ? CGSize(width: 160.0, height: 160.0) : nil), complete: false) |> map { next in + let fullSizeData = account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedStickerAJpegRepresentation(size: small ? CGSize(width: 160.0, height: 160.0) : nil), complete: onlyFullSize) + |> map { next in return (next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: .mappedIfSafe), next.complete) } @@ -66,7 +69,8 @@ private func chatMessageStickerDatas(account: Account, file: TelegramMediaFile, } } } else { - return fullSizeData |> map { (data, complete) -> (Data?, Data?, Bool) in + return fullSizeData + |> map { (data, complete) -> (Data?, Data?, Bool) in return (nil, data, complete) } } diff --git a/TelegramUI/TransformOutgoingMessageMedia.swift b/TelegramUI/TransformOutgoingMessageMedia.swift index fa624be5e7..2a04df07a1 100644 --- a/TelegramUI/TransformOutgoingMessageMedia.swift +++ b/TelegramUI/TransformOutgoingMessageMedia.swift @@ -117,7 +117,7 @@ public func transformOutgoingMessageMedia(postbox: Postbox, network: Network, me case let image as TelegramMediaImage: if let representation = largestImageRepresentation(image.representations) { let signal = Signal { subscriber in - let fetch = postbox.mediaBox.fetchedResource(representation.resource, parameters: nil).start() + let fetch = fetchedMediaResource(postbox: postbox, reference: media.resourceReference(representation.resource)).start() let data = postbox.mediaBox.resourceData(representation.resource, option: .complete(waitUntilFetchStatus: true)).start(next: { next in subscriber.putNext(next) if next.complete { diff --git a/TelegramUI/UserInfoController.swift b/TelegramUI/UserInfoController.swift index 71473057b1..a777244adf 100644 --- a/TelegramUI/UserInfoController.swift +++ b/TelegramUI/UserInfoController.swift @@ -683,7 +683,9 @@ public func userInfoController(account: Account, peerId: PeerId) -> ViewControll peerView.set(account.viewTracker.peerView(peerId)) let requestCallImpl: () -> Void = { - let _ = (peerView.get() |> deliverOnMainQueue).start(next: { view in + let _ = (peerView.get() + |> take(1) + |> deliverOnMainQueue).start(next: { view in guard let peer = peerViewMainPeer(view) else { return }