mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Refactoring [skip ci]
This commit is contained in:
parent
95947fdb99
commit
1640a8c76f
@ -1,6 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
@ -49,8 +48,8 @@ public final class LegacyLiveUploadInterface: VideoConversionWatcher, TGLiveUplo
|
|||||||
private var path: String?
|
private var path: String?
|
||||||
private var size: Int?
|
private var size: Int?
|
||||||
|
|
||||||
private let data = Promise<MediaResourceData>()
|
private let data = Promise<EngineMediaResource.ResourceData>()
|
||||||
private let dataValue = Atomic<MediaResourceData?>(value: nil)
|
private let dataValue = Atomic<EngineMediaResource.ResourceData?>(value: nil)
|
||||||
|
|
||||||
public init(context: AccountContext) {
|
public init(context: AccountContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -70,14 +69,13 @@ public final class LegacyLiveUploadInterface: VideoConversionWatcher, TGLiveUplo
|
|||||||
strongSelf.size = size
|
strongSelf.size = size
|
||||||
|
|
||||||
let result = strongSelf.dataValue.modify { dataValue in
|
let result = strongSelf.dataValue.modify { dataValue in
|
||||||
if let dataValue = dataValue, dataValue.complete {
|
if let dataValue = dataValue, dataValue.isComplete {
|
||||||
return MediaResourceData(path: path, offset: 0, size: Int64(size), complete: true)
|
return EngineMediaResource.ResourceData(path: path, availableSize: Int64(size), isComplete: true)
|
||||||
} else {
|
} else {
|
||||||
return MediaResourceData(path: path, offset: 0, size: Int64(size), complete: false)
|
return EngineMediaResource.ResourceData(path: path, availableSize: Int64(size), isComplete: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let result = result {
|
if let result = result {
|
||||||
print("**set1 \(result) \(result.complete)")
|
|
||||||
strongSelf.data.set(.single(result))
|
strongSelf.data.set(.single(result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,17 +87,15 @@ public final class LegacyLiveUploadInterface: VideoConversionWatcher, TGLiveUplo
|
|||||||
|
|
||||||
override public func fileUpdated(_ completed: Bool) -> Any! {
|
override public func fileUpdated(_ completed: Bool) -> Any! {
|
||||||
let _ = super.fileUpdated(completed)
|
let _ = super.fileUpdated(completed)
|
||||||
print("**fileUpdated \(completed)")
|
|
||||||
if completed {
|
if completed {
|
||||||
let result = self.dataValue.modify { dataValue in
|
let result = self.dataValue.modify { dataValue in
|
||||||
if let dataValue = dataValue {
|
if let dataValue = dataValue {
|
||||||
return MediaResourceData(path: dataValue.path, offset: dataValue.offset, size: dataValue.size, complete: true)
|
return EngineMediaResource.ResourceData(path: dataValue.path, availableSize: dataValue.availableSize, isComplete: true)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let result = result {
|
if let result = result {
|
||||||
print("**set2 \(result) \(completed)")
|
|
||||||
self.data.set(.single(result))
|
self.data.set(.single(result))
|
||||||
return LegacyLiveUploadInterfaceResult(id: self.id)
|
return LegacyLiveUploadInterfaceResult(id: self.id)
|
||||||
} else {
|
} else {
|
||||||
|
@ -303,7 +303,7 @@ final class SecureIdAuthControllerNode: ViewControllerTracingNode {
|
|||||||
current.updateValues(formData.values)
|
current.updateValues(formData.values)
|
||||||
contentNode = current
|
contentNode = current
|
||||||
} else {
|
} else {
|
||||||
let current = SecureIdAuthFormContentNode(theme: self.presentationData.theme, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder, peer: encryptedFormData.servicePeer, privacyPolicyUrl: encryptedFormData.form.termsUrl, form: formData, primaryLanguageByCountry: encryptedFormData.primaryLanguageByCountry, openField: { [weak self] field in
|
let current = SecureIdAuthFormContentNode(theme: self.presentationData.theme, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder, peer: EnginePeer(encryptedFormData.servicePeer), privacyPolicyUrl: encryptedFormData.form.termsUrl, form: formData, primaryLanguageByCountry: encryptedFormData.primaryLanguageByCountry, openField: { [weak self] field in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
switch field {
|
switch field {
|
||||||
case .identity, .address:
|
case .identity, .address:
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
@ -24,7 +23,7 @@ final class SecureIdAuthFormContentNode: ASDisplayNode, SecureIdAuthContentNode,
|
|||||||
private let requestLayout: () -> Void
|
private let requestLayout: () -> Void
|
||||||
private var validLayout: CGFloat?
|
private var validLayout: CGFloat?
|
||||||
|
|
||||||
init(theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, peer: Peer, privacyPolicyUrl: String?, form: SecureIdForm, primaryLanguageByCountry: [String: String], openField: @escaping (SecureIdParsedRequestedFormField) -> Void, openURL: @escaping (String) -> Void, openMention: @escaping (TelegramPeerMention) -> Void, requestLayout: @escaping () -> Void) {
|
init(theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, peer: EnginePeer, privacyPolicyUrl: String?, form: SecureIdForm, primaryLanguageByCountry: [String: String], openField: @escaping (SecureIdParsedRequestedFormField) -> Void, openURL: @escaping (String) -> Void, openMention: @escaping (TelegramPeerMention) -> Void, requestLayout: @escaping () -> Void) {
|
||||||
self.requestLayout = requestLayout
|
self.requestLayout = requestLayout
|
||||||
|
|
||||||
self.primaryLanguageByCountry = primaryLanguageByCountry
|
self.primaryLanguageByCountry = primaryLanguageByCountry
|
||||||
@ -57,13 +56,13 @@ final class SecureIdAuthFormContentNode: ASDisplayNode, SecureIdAuthContentNode,
|
|||||||
let privacyPolicyAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.freeTextColor)
|
let privacyPolicyAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.freeTextColor)
|
||||||
let privacyPolicyLinkAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.itemAccentColor, additionalAttributes: [NSAttributedString.Key.underlineStyle.rawValue: NSUnderlineStyle.single.rawValue as NSNumber, TelegramTextAttributes.URL: privacyPolicyUrl])
|
let privacyPolicyLinkAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.itemAccentColor, additionalAttributes: [NSAttributedString.Key.underlineStyle.rawValue: NSUnderlineStyle.single.rawValue as NSNumber, TelegramTextAttributes.URL: privacyPolicyUrl])
|
||||||
|
|
||||||
text = parseMarkdownIntoAttributedString(strings.Passport_PrivacyPolicy(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), (EnginePeer(peer).addressName ?? "")).string.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: privacyPolicyAttributes, bold: privacyPolicyAttributes, link: privacyPolicyLinkAttributes, linkAttribute: { _ in
|
text = parseMarkdownIntoAttributedString(strings.Passport_PrivacyPolicy(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: privacyPolicyAttributes, bold: privacyPolicyAttributes, link: privacyPolicyLinkAttributes, linkAttribute: { _ in
|
||||||
return nil
|
return nil
|
||||||
}), textAlignment: .center)
|
}), textAlignment: .center)
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
text = NSAttributedString(string: strings.Passport_AcceptHelp(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string, font: infoFont, textColor: theme.list.freeTextColor, paragraphAlignment: .left)
|
text = NSAttributedString(string: strings.Passport_AcceptHelp(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string, font: infoFont, textColor: theme.list.freeTextColor, paragraphAlignment: .left)
|
||||||
}
|
}
|
||||||
self.textNode.attributedText = text
|
self.textNode.attributedText = text
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
@ -17,12 +16,12 @@ import ItemListPeerItem
|
|||||||
private final class ChannelBlacklistControllerArguments {
|
private final class ChannelBlacklistControllerArguments {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
|
|
||||||
let setPeerIdWithRevealedOptions: (PeerId?, PeerId?) -> Void
|
let setPeerIdWithRevealedOptions: (EnginePeer.Id?, EnginePeer.Id?) -> Void
|
||||||
let addPeer: () -> Void
|
let addPeer: () -> Void
|
||||||
let removePeer: (PeerId) -> Void
|
let removePeer: (EnginePeer.Id) -> Void
|
||||||
let openPeer: (RenderedChannelParticipant) -> Void
|
let openPeer: (RenderedChannelParticipant) -> Void
|
||||||
|
|
||||||
init(context: AccountContext, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, addPeer: @escaping () -> Void, removePeer: @escaping (PeerId) -> Void, openPeer: @escaping (RenderedChannelParticipant) -> Void) {
|
init(context: AccountContext, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, addPeer: @escaping () -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, openPeer: @escaping (RenderedChannelParticipant) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.addPeer = addPeer
|
self.addPeer = addPeer
|
||||||
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
|
||||||
@ -38,7 +37,7 @@ private enum ChannelBlacklistSection: Int32 {
|
|||||||
|
|
||||||
private enum ChannelBlacklistEntryStableId: Hashable {
|
private enum ChannelBlacklistEntryStableId: Hashable {
|
||||||
case index(Int)
|
case index(Int)
|
||||||
case peer(PeerId)
|
case peer(EnginePeer.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ChannelBlacklistEntry: ItemListNodeEntry {
|
private enum ChannelBlacklistEntry: ItemListNodeEntry {
|
||||||
@ -182,8 +181,8 @@ private enum ChannelBlacklistEntry: ItemListNodeEntry {
|
|||||||
private struct ChannelBlacklistControllerState: Equatable {
|
private struct ChannelBlacklistControllerState: Equatable {
|
||||||
let referenceTimestamp: Int32
|
let referenceTimestamp: Int32
|
||||||
let editing: Bool
|
let editing: Bool
|
||||||
let peerIdWithRevealedOptions: PeerId?
|
let peerIdWithRevealedOptions: EnginePeer.Id?
|
||||||
let removingPeerId: PeerId?
|
let removingPeerId: EnginePeer.Id?
|
||||||
let searchingMembers: Bool
|
let searchingMembers: Bool
|
||||||
|
|
||||||
init(referenceTimestamp: Int32) {
|
init(referenceTimestamp: Int32) {
|
||||||
@ -194,7 +193,7 @@ private struct ChannelBlacklistControllerState: Equatable {
|
|||||||
self.searchingMembers = false
|
self.searchingMembers = false
|
||||||
}
|
}
|
||||||
|
|
||||||
init(referenceTimestamp: Int32, editing: Bool, peerIdWithRevealedOptions: PeerId?, removingPeerId: PeerId?, searchingMembers: Bool) {
|
init(referenceTimestamp: Int32, editing: Bool, peerIdWithRevealedOptions: EnginePeer.Id?, removingPeerId: EnginePeer.Id?, searchingMembers: Bool) {
|
||||||
self.referenceTimestamp = referenceTimestamp
|
self.referenceTimestamp = referenceTimestamp
|
||||||
self.editing = editing
|
self.editing = editing
|
||||||
self.peerIdWithRevealedOptions = peerIdWithRevealedOptions
|
self.peerIdWithRevealedOptions = peerIdWithRevealedOptions
|
||||||
@ -231,19 +230,19 @@ private struct ChannelBlacklistControllerState: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func withUpdatedPeerIdWithRevealedOptions(_ peerIdWithRevealedOptions: PeerId?) -> ChannelBlacklistControllerState {
|
func withUpdatedPeerIdWithRevealedOptions(_ peerIdWithRevealedOptions: EnginePeer.Id?) -> ChannelBlacklistControllerState {
|
||||||
return ChannelBlacklistControllerState(referenceTimestamp: self.referenceTimestamp, editing: self.editing, peerIdWithRevealedOptions: peerIdWithRevealedOptions, removingPeerId: self.removingPeerId, searchingMembers: self.searchingMembers)
|
return ChannelBlacklistControllerState(referenceTimestamp: self.referenceTimestamp, editing: self.editing, peerIdWithRevealedOptions: peerIdWithRevealedOptions, removingPeerId: self.removingPeerId, searchingMembers: self.searchingMembers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedRemovingPeerId(_ removingPeerId: PeerId?) -> ChannelBlacklistControllerState {
|
func withUpdatedRemovingPeerId(_ removingPeerId: EnginePeer.Id?) -> ChannelBlacklistControllerState {
|
||||||
return ChannelBlacklistControllerState(referenceTimestamp: self.referenceTimestamp, editing: self.editing, peerIdWithRevealedOptions: self.peerIdWithRevealedOptions, removingPeerId: removingPeerId, searchingMembers: self.searchingMembers)
|
return ChannelBlacklistControllerState(referenceTimestamp: self.referenceTimestamp, editing: self.editing, peerIdWithRevealedOptions: self.peerIdWithRevealedOptions, removingPeerId: removingPeerId, searchingMembers: self.searchingMembers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func channelBlacklistControllerEntries(presentationData: PresentationData, view: PeerView, state: ChannelBlacklistControllerState, participants: [RenderedChannelParticipant]?) -> [ChannelBlacklistEntry] {
|
private func channelBlacklistControllerEntries(presentationData: PresentationData, peer: EnginePeer?, state: ChannelBlacklistControllerState, participants: [RenderedChannelParticipant]?) -> [ChannelBlacklistEntry] {
|
||||||
var entries: [ChannelBlacklistEntry] = []
|
var entries: [ChannelBlacklistEntry] = []
|
||||||
|
|
||||||
if let channel = view.peers[view.peerId] as? TelegramChannel, let participants = participants {
|
if case let .channel(channel) = peer, let participants = participants {
|
||||||
entries.append(.add(presentationData.theme, presentationData.strings.GroupRemoved_Remove))
|
entries.append(.add(presentationData.theme, presentationData.strings.GroupRemoved_Remove))
|
||||||
|
|
||||||
let isGroup: Bool
|
let isGroup: Bool
|
||||||
@ -267,7 +266,7 @@ private func channelBlacklistControllerEntries(presentationData: PresentationDat
|
|||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
public func channelBlacklistController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: PeerId) -> ViewController {
|
public func channelBlacklistController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id) -> ViewController {
|
||||||
let statePromise = ValuePromise(ChannelBlacklistControllerState(referenceTimestamp: Int32(Date().timeIntervalSince1970)), ignoreRepeated: true)
|
let statePromise = ValuePromise(ChannelBlacklistControllerState(referenceTimestamp: Int32(Date().timeIntervalSince1970)), ignoreRepeated: true)
|
||||||
let stateValue = Atomic(value: ChannelBlacklistControllerState(referenceTimestamp: Int32(Date().timeIntervalSince1970)))
|
let stateValue = Atomic(value: ChannelBlacklistControllerState(referenceTimestamp: Int32(Date().timeIntervalSince1970)))
|
||||||
let updateState: ((ChannelBlacklistControllerState) -> ChannelBlacklistControllerState) -> Void = { f in
|
let updateState: ((ChannelBlacklistControllerState) -> ChannelBlacklistControllerState) -> Void = { f in
|
||||||
@ -287,8 +286,8 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||||||
let removePeerDisposable = MetaDisposable()
|
let removePeerDisposable = MetaDisposable()
|
||||||
actionsDisposable.add(removePeerDisposable)
|
actionsDisposable.add(removePeerDisposable)
|
||||||
|
|
||||||
let peerView = Promise<PeerView>()
|
actionsDisposable.add(context.engine.peers.keepPeerUpdated(id: peerId, forceUpdate: false).start())
|
||||||
peerView.set(context.account.viewTracker.peerView(peerId))
|
|
||||||
let blacklistPromise = Promise<[RenderedChannelParticipant]?>(nil)
|
let blacklistPromise = Promise<[RenderedChannelParticipant]?>(nil)
|
||||||
|
|
||||||
let arguments = ChannelBlacklistControllerArguments(context: context, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
let arguments = ChannelBlacklistControllerArguments(context: context, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||||
@ -347,10 +346,11 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}, openPeer: { participant in
|
}, openPeer: { participant in
|
||||||
let _ = (peerView.get()
|
let _ = (context.engine.data.get(
|
||||||
|> take(1)
|
TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)
|
||||||
|> deliverOnMainQueue).start(next: { peerView in
|
)
|
||||||
guard let channel = peerView.peers[peerId] as? TelegramChannel else {
|
|> deliverOnMainQueue).start(next: { peer in
|
||||||
|
guard case let .channel(channel) = peer else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
@ -435,10 +435,14 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||||||
|
|
||||||
let previousParticipantsValue = Atomic<[RenderedChannelParticipant]?>(value: nil)
|
let previousParticipantsValue = Atomic<[RenderedChannelParticipant]?>(value: nil)
|
||||||
|
|
||||||
|
let peer = context.engine.data.get(
|
||||||
|
TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)
|
||||||
|
)
|
||||||
|
|
||||||
let presentationData = updatedPresentationData?.signal ?? context.sharedContext.presentationData
|
let presentationData = updatedPresentationData?.signal ?? context.sharedContext.presentationData
|
||||||
let signal = combineLatest(queue: .mainQueue(), presentationData, statePromise.get(), peerView.get(), blacklistPromise.get())
|
let signal = combineLatest(queue: .mainQueue(), presentationData, statePromise.get(), peer, blacklistPromise.get())
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> map { presentationData, state, view, participants -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
|> map { presentationData, state, peer, participants -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||||
var rightNavigationButton: ItemListNavigationButton?
|
var rightNavigationButton: ItemListNavigationButton?
|
||||||
var secondaryRightNavigationButton: ItemListNavigationButton?
|
var secondaryRightNavigationButton: ItemListNavigationButton?
|
||||||
if let participants = participants, !participants.isEmpty {
|
if let participants = participants, !participants.isEmpty {
|
||||||
@ -498,7 +502,7 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||||||
}
|
}
|
||||||
|
|
||||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.GroupRemoved_Title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, secondaryRightNavigationButton: secondaryRightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
|
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.GroupRemoved_Title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, secondaryRightNavigationButton: secondaryRightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
|
||||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: channelBlacklistControllerEntries(presentationData: presentationData, view: view, state: state, participants: participants), style: .blocks, emptyStateItem: emptyStateItem, searchItem: searchItem, animateChanges: previous != nil && participants != nil && previous!.count >= participants!.count)
|
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: channelBlacklistControllerEntries(presentationData: presentationData, peer: peer, state: state, participants: participants), style: .blocks, emptyStateItem: emptyStateItem, searchItem: searchItem, animateChanges: previous != nil && participants != nil && previous!.count >= participants!.count)
|
||||||
|
|
||||||
return (controllerState, (listState, arguments))
|
return (controllerState, (listState, arguments))
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ public func proxySettingsController(accountManager: AccountManager<TelegramAccou
|
|||||||
return current
|
return current
|
||||||
}).start()
|
}).start()
|
||||||
}, addNewServer: {
|
}, addNewServer: {
|
||||||
pushControllerImpl?(proxyServerSettingsController(presentationData: presentationData, updatedPresentationData: updatedPresentationData, accountManager: accountManager, postbox: postbox, network: network, currentSettings: nil))
|
pushControllerImpl?(proxyServerSettingsController(presentationData: presentationData, updatedPresentationData: updatedPresentationData, accountManager: accountManager, network: network, currentSettings: nil))
|
||||||
}, activateServer: { server in
|
}, activateServer: { server in
|
||||||
let _ = updateProxySettingsInteractively(accountManager: accountManager, { current in
|
let _ = updateProxySettingsInteractively(accountManager: accountManager, { current in
|
||||||
var current = current
|
var current = current
|
||||||
@ -354,7 +354,7 @@ public func proxySettingsController(accountManager: AccountManager<TelegramAccou
|
|||||||
return current
|
return current
|
||||||
}).start()
|
}).start()
|
||||||
}, editServer: { server in
|
}, editServer: { server in
|
||||||
pushControllerImpl?(proxyServerSettingsController(presentationData: presentationData, updatedPresentationData: updatedPresentationData, accountManager: accountManager, postbox: postbox, network: network, currentSettings: server))
|
pushControllerImpl?(proxyServerSettingsController(presentationData: presentationData, updatedPresentationData: updatedPresentationData, accountManager: accountManager, network: network, currentSettings: server))
|
||||||
}, removeServer: { server in
|
}, removeServer: { server in
|
||||||
let _ = updateProxySettingsInteractively(accountManager: accountManager, { current in
|
let _ = updateProxySettingsInteractively(accountManager: accountManager, { current in
|
||||||
var current = current
|
var current = current
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import MtProtoKit
|
import MtProtoKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
@ -266,10 +265,10 @@ private func proxyServerSettings(with state: ProxyServerSettingsControllerState)
|
|||||||
|
|
||||||
public func proxyServerSettingsController(context: AccountContext, currentSettings: ProxyServerSettings? = nil) -> ViewController {
|
public func proxyServerSettingsController(context: AccountContext, currentSettings: ProxyServerSettings? = nil) -> ViewController {
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
return proxyServerSettingsController(context: context, presentationData: presentationData, updatedPresentationData: context.sharedContext.presentationData, accountManager: context.sharedContext.accountManager, postbox: context.account.postbox, network: context.account.network, currentSettings: currentSettings)
|
return proxyServerSettingsController(context: context, presentationData: presentationData, updatedPresentationData: context.sharedContext.presentationData, accountManager: context.sharedContext.accountManager, network: context.account.network, currentSettings: currentSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
func proxyServerSettingsController(context: AccountContext? = nil, presentationData: PresentationData, updatedPresentationData: Signal<PresentationData, NoError>, accountManager: AccountManager<TelegramAccountManagerTypes>, postbox: Postbox, network: Network, currentSettings: ProxyServerSettings?) -> ViewController {
|
func proxyServerSettingsController(context: AccountContext? = nil, presentationData: PresentationData, updatedPresentationData: Signal<PresentationData, NoError>, accountManager: AccountManager<TelegramAccountManagerTypes>, network: Network, currentSettings: ProxyServerSettings?) -> ViewController {
|
||||||
var currentMode: ProxyServerSettingsControllerMode = .socks5
|
var currentMode: ProxyServerSettingsControllerMode = .socks5
|
||||||
var currentUsername: String?
|
var currentUsername: String?
|
||||||
var currentPassword: String?
|
var currentPassword: String?
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import ItemListUI
|
import ItemListUI
|
||||||
|
@ -717,7 +717,7 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
|
|||||||
expandedText = .text(about, textIcon, .generic)
|
expandedText = .text(about, textIcon, .generic)
|
||||||
}
|
}
|
||||||
|
|
||||||
return VoiceChatParticipantItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: context, peer: peer, text: text, expandedText: expandedText, icon: icon, getAudioLevel: { return interaction.getAudioLevel(peer.id) }, action: { node in
|
return VoiceChatParticipantItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: context, peer: EnginePeer(peer), text: text, expandedText: expandedText, icon: icon, getAudioLevel: { return interaction.getAudioLevel(peer.id) }, action: { node in
|
||||||
if let node = node {
|
if let node = node {
|
||||||
interaction.peerContextAction(peerEntry, node, nil, false)
|
interaction.peerContextAction(peerEntry, node, nil, false)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
@ -59,7 +58,7 @@ final class VoiceChatParticipantItem: ListViewItem {
|
|||||||
let dateTimeFormat: PresentationDateTimeFormat
|
let dateTimeFormat: PresentationDateTimeFormat
|
||||||
let nameDisplayOrder: PresentationPersonNameOrder
|
let nameDisplayOrder: PresentationPersonNameOrder
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let peer: Peer
|
let peer: EnginePeer
|
||||||
let text: ParticipantText
|
let text: ParticipantText
|
||||||
let expandedText: ParticipantText?
|
let expandedText: ParticipantText?
|
||||||
let icon: Icon
|
let icon: Icon
|
||||||
@ -71,7 +70,7 @@ final class VoiceChatParticipantItem: ListViewItem {
|
|||||||
|
|
||||||
public let selectable: Bool = true
|
public let selectable: Bool = true
|
||||||
|
|
||||||
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: Peer, text: ParticipantText, expandedText: ParticipantText?, icon: Icon, getAudioLevel: (() -> Signal<Float, NoError>)?, action: ((ASDisplayNode?) -> Void)?, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, getIsExpanded: @escaping () -> Bool, getUpdatingAvatar: @escaping () -> Signal<(TelegramMediaImageRepresentation, Float)?, NoError>) {
|
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: EnginePeer, text: ParticipantText, expandedText: ParticipantText?, icon: Icon, getAudioLevel: (() -> Signal<Float, NoError>)?, action: ((ASDisplayNode?) -> Void)?, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, getIsExpanded: @escaping () -> Bool, getUpdatingAvatar: @escaping () -> Signal<(TelegramMediaImageRepresentation, Float)?, NoError>) {
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
self.dateTimeFormat = dateTimeFormat
|
self.dateTimeFormat = dateTimeFormat
|
||||||
self.nameDisplayOrder = nameDisplayOrder
|
self.nameDisplayOrder = nameDisplayOrder
|
||||||
@ -512,7 +511,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
let avatarListNode = PeerInfoAvatarListContainerNode(context: item.context)
|
let avatarListNode = PeerInfoAvatarListContainerNode(context: item.context)
|
||||||
avatarListWrapperNode.contentNode.clipsToBounds = true
|
avatarListWrapperNode.contentNode.clipsToBounds = true
|
||||||
avatarListNode.backgroundColor = .clear
|
avatarListNode.backgroundColor = .clear
|
||||||
avatarListNode.peer = EnginePeer(item.peer)
|
avatarListNode.peer = item.peer
|
||||||
avatarListNode.firstFullSizeOnly = true
|
avatarListNode.firstFullSizeOnly = true
|
||||||
avatarListNode.offsetLocation = true
|
avatarListNode.offsetLocation = true
|
||||||
avatarListNode.customCenterTapAction = { [weak self] in
|
avatarListNode.customCenterTapAction = { [weak self] in
|
||||||
@ -528,7 +527,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
avatarListContainerNode.addSubnode(avatarListNode.controlsClippingOffsetNode)
|
avatarListContainerNode.addSubnode(avatarListNode.controlsClippingOffsetNode)
|
||||||
avatarListWrapperNode.contentNode.addSubnode(avatarListContainerNode)
|
avatarListWrapperNode.contentNode.addSubnode(avatarListContainerNode)
|
||||||
|
|
||||||
avatarListNode.update(size: targetRect.size, peer: EnginePeer(item.peer), customNode: nil, additionalEntry: item.getUpdatingAvatar(), isExpanded: true, transition: .immediate)
|
avatarListNode.update(size: targetRect.size, peer: item.peer, customNode: nil, additionalEntry: item.getUpdatingAvatar(), isExpanded: true, transition: .immediate)
|
||||||
strongSelf.offsetContainerNode.supernode?.addSubnode(avatarListWrapperNode)
|
strongSelf.offsetContainerNode.supernode?.addSubnode(avatarListWrapperNode)
|
||||||
|
|
||||||
strongSelf.audioLevelView?.alpha = 0.0
|
strongSelf.audioLevelView?.alpha = 0.0
|
||||||
@ -785,7 +784,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
let rightInset: CGFloat = params.rightInset
|
let rightInset: CGFloat = params.rightInset
|
||||||
|
|
||||||
var updatedTitle = false
|
var updatedTitle = false
|
||||||
if let user = item.peer as? TelegramUser {
|
if case let .user(user) = item.peer {
|
||||||
if let firstName = user.firstName, let lastName = user.lastName, !firstName.isEmpty, !lastName.isEmpty {
|
if let firstName = user.firstName, let lastName = user.lastName, !firstName.isEmpty, !lastName.isEmpty {
|
||||||
let string = NSMutableAttributedString()
|
let string = NSMutableAttributedString()
|
||||||
switch item.nameDisplayOrder {
|
switch item.nameDisplayOrder {
|
||||||
@ -806,9 +805,9 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else {
|
} else {
|
||||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.User_DeletedAccount, font: titleFont, textColor: titleColor)
|
titleAttributedString = NSAttributedString(string: item.presentationData.strings.User_DeletedAccount, font: titleFont, textColor: titleColor)
|
||||||
}
|
}
|
||||||
} else if let group = item.peer as? TelegramGroup {
|
} else if case let .legacyGroup(group) = item.peer {
|
||||||
titleAttributedString = NSAttributedString(string: group.title, font: titleFont, textColor: titleColor)
|
titleAttributedString = NSAttributedString(string: group.title, font: titleFont, textColor: titleColor)
|
||||||
} else if let channel = item.peer as? TelegramChannel {
|
} else if case let .channel(channel) = item.peer {
|
||||||
titleAttributedString = NSAttributedString(string: channel.title, font: titleFont, textColor: titleColor)
|
titleAttributedString = NSAttributedString(string: channel.title, font: titleFont, textColor: titleColor)
|
||||||
}
|
}
|
||||||
if let currentTitle = currentTitle, currentTitle != titleAttributedString?.string {
|
if let currentTitle = currentTitle, currentTitle != titleAttributedString?.string {
|
||||||
@ -840,7 +839,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
credibilityIcon = .text(color: item.presentationData.theme.chat.message.incoming.scamColor, string: item.presentationData.strings.Message_ScamAccount.uppercased())
|
credibilityIcon = .text(color: item.presentationData.theme.chat.message.incoming.scamColor, string: item.presentationData.strings.Message_ScamAccount.uppercased())
|
||||||
} else if item.peer.isFake {
|
} else if item.peer.isFake {
|
||||||
credibilityIcon = .text(color: item.presentationData.theme.chat.message.incoming.scamColor, string: item.presentationData.strings.Message_FakeAccount.uppercased())
|
credibilityIcon = .text(color: item.presentationData.theme.chat.message.incoming.scamColor, string: item.presentationData.strings.Message_FakeAccount.uppercased())
|
||||||
} else if let user = item.peer as? TelegramUser, let emojiStatus = user.emojiStatus, !premiumConfiguration.isPremiumDisabled {
|
} else if case let .user(user) = item.peer, let emojiStatus = user.emojiStatus, !premiumConfiguration.isPremiumDisabled {
|
||||||
credibilityIcon = .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 20.0, height: 20.0), placeholderColor: item.presentationData.theme.list.mediaPlaceholderColor, themeColor: item.presentationData.theme.list.itemAccentColor, loopMode: .count(2))
|
credibilityIcon = .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 20.0, height: 20.0), placeholderColor: item.presentationData.theme.list.mediaPlaceholderColor, themeColor: item.presentationData.theme.list.itemAccentColor, loopMode: .count(2))
|
||||||
} else if item.peer.isVerified {
|
} else if item.peer.isVerified {
|
||||||
credibilityIcon = .verified(fillColor: item.presentationData.theme.list.itemCheckColors.fillColor, foregroundColor: item.presentationData.theme.list.itemCheckColors.foregroundColor, sizeType: .compact)
|
credibilityIcon = .verified(fillColor: item.presentationData.theme.list.itemCheckColors.fillColor, foregroundColor: item.presentationData.theme.list.itemCheckColors.foregroundColor, sizeType: .compact)
|
||||||
@ -1133,7 +1132,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
|||||||
if item.peer.isDeleted {
|
if item.peer.isDeleted {
|
||||||
overrideImage = .deletedIcon
|
overrideImage = .deletedIcon
|
||||||
}
|
}
|
||||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true)
|
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad, storeUnrounded: true)
|
||||||
|
|
||||||
strongSelf.highlightContainerNode.frame = CGRect(origin: CGPoint(x: params.leftInset, y: -UIScreenPixel), size: CGSize(width: params.width - params.leftInset - params.rightInset, height: layout.contentSize.height + UIScreenPixel + UIScreenPixel + 11.0))
|
strongSelf.highlightContainerNode.frame = CGRect(origin: CGPoint(x: params.leftInset, y: -UIScreenPixel), size: CGSize(width: params.width - params.leftInset - params.rightInset, height: layout.contentSize.height + UIScreenPixel + UIScreenPixel + 11.0))
|
||||||
|
|
||||||
|
@ -32,11 +32,18 @@ private final class MessageMediaPreuploadManagerContext {
|
|||||||
assert(self.queue.isCurrent())
|
assert(self.queue.isCurrent())
|
||||||
}
|
}
|
||||||
|
|
||||||
func add(network: Network, postbox: Postbox, id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<MediaResourceData, NoError>, onComplete: (()->Void)? = nil) {
|
func add(network: Network, postbox: Postbox, id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<EngineMediaResource.ResourceData, NoError>, onComplete: (()->Void)? = nil) {
|
||||||
let context = MessageMediaPreuploadManagerUploadContext()
|
let context = MessageMediaPreuploadManagerUploadContext()
|
||||||
self.uploadContexts[id] = context
|
self.uploadContexts[id] = context
|
||||||
let queue = self.queue
|
let queue = self.queue
|
||||||
context.disposable.set(multipartUpload(network: network, postbox: postbox, source: .custom(source), encrypt: encrypt, tag: tag, hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false).start(next: { [weak self] next in
|
context.disposable.set(multipartUpload(network: network, postbox: postbox, source: .custom(source |> map { data in
|
||||||
|
return MediaResourceData(
|
||||||
|
path: data.path,
|
||||||
|
offset: 0,
|
||||||
|
size: data.availableSize,
|
||||||
|
complete: data.isComplete
|
||||||
|
)
|
||||||
|
}), encrypt: encrypt, tag: tag, hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false).start(next: { [weak self] next in
|
||||||
queue.async {
|
queue.async {
|
||||||
if let strongSelf = self, let context = strongSelf.uploadContexts[id] {
|
if let strongSelf = self, let context = strongSelf.uploadContexts[id] {
|
||||||
switch next {
|
switch next {
|
||||||
@ -112,7 +119,7 @@ final class MessageMediaPreuploadManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func add(network: Network, postbox: Postbox, id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<MediaResourceData, NoError>, onComplete:(()->Void)? = nil) {
|
func add(network: Network, postbox: Postbox, id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<EngineMediaResource.ResourceData, NoError>, onComplete:(()->Void)? = nil) {
|
||||||
self.impl.with { context in
|
self.impl.with { context in
|
||||||
context.add(network: network, postbox: postbox, id: id, encrypt: encrypt, tag: tag, source: source, onComplete: onComplete)
|
context.add(network: network, postbox: postbox, id: id, encrypt: encrypt, tag: tag, source: source, onComplete: onComplete)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,48 @@ import SwiftSignalKit
|
|||||||
import Postbox
|
import Postbox
|
||||||
|
|
||||||
public extension TelegramEngine.EngineData.Item {
|
public extension TelegramEngine.EngineData.Item {
|
||||||
|
enum Collections {
|
||||||
|
public struct FeaturedStickerPacks: TelegramEngineDataItem, PostboxViewDataItem {
|
||||||
|
public typealias Result = [FeaturedStickerPackItem]
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var key: PostboxViewKey {
|
||||||
|
return .orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedStickerPacks)
|
||||||
|
}
|
||||||
|
|
||||||
|
func extract(view: PostboxView) -> Result {
|
||||||
|
guard let view = view as? OrderedItemListView else {
|
||||||
|
preconditionFailure()
|
||||||
|
}
|
||||||
|
return view.items.compactMap { item in
|
||||||
|
return item.contents.get(FeaturedStickerPackItem.self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct FeaturedEmojiPacks: TelegramEngineDataItem, PostboxViewDataItem {
|
||||||
|
public typealias Result = [FeaturedStickerPackItem]
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
var key: PostboxViewKey {
|
||||||
|
return .orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
||||||
|
}
|
||||||
|
|
||||||
|
func extract(view: PostboxView) -> Result {
|
||||||
|
guard let view = view as? OrderedItemListView else {
|
||||||
|
preconditionFailure()
|
||||||
|
}
|
||||||
|
return view.items.compactMap { item in
|
||||||
|
return item.contents.get(FeaturedStickerPackItem.self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum OrderedLists {
|
enum OrderedLists {
|
||||||
public struct ListItems: TelegramEngineDataItem, PostboxViewDataItem {
|
public struct ListItems: TelegramEngineDataItem, PostboxViewDataItem {
|
||||||
public typealias Result = [OrderedItemListEntry]
|
public typealias Result = [OrderedItemListEntry]
|
||||||
|
@ -231,7 +231,7 @@ public extension TelegramEngine {
|
|||||||
self.account = account
|
self.account = account
|
||||||
}
|
}
|
||||||
|
|
||||||
public func preUpload(id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<MediaResourceData, NoError>, onComplete: (()->Void)? = nil) {
|
public func preUpload(id: Int64, encrypt: Bool, tag: MediaResourceFetchTag?, source: Signal<EngineMediaResource.ResourceData, NoError>, onComplete: (()->Void)? = nil) {
|
||||||
return self.account.messageMediaPreuploadManager.add(network: self.account.network, postbox: self.account.postbox, id: id, encrypt: encrypt, tag: tag, source: source, onComplete: onComplete)
|
return self.account.messageMediaPreuploadManager.add(network: self.account.network, postbox: self.account.postbox, id: id, encrypt: encrypt, tag: tag, source: source, onComplete: onComplete)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
import AppBundle
|
import AppBundle
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import ComponentFlow
|
import ComponentFlow
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
@ -11,7 +11,6 @@ import ComponentDisplayAdapters
|
|||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import PagerComponent
|
import PagerComponent
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Lottie
|
import Lottie
|
||||||
import EmojiTextAttachmentView
|
import EmojiTextAttachmentView
|
||||||
@ -19,6 +18,7 @@ import TextFormat
|
|||||||
import AppBundle
|
import AppBundle
|
||||||
import GZip
|
import GZip
|
||||||
import EmojiStatusComponent
|
import EmojiStatusComponent
|
||||||
|
import Postbox
|
||||||
|
|
||||||
private func randomGenericReactionEffect(context: AccountContext) -> Signal<String?, NoError> {
|
private func randomGenericReactionEffect(context: AccountContext) -> Signal<String?, NoError> {
|
||||||
return context.engine.stickers.loadedStickerPack(reference: .emojiGenericAnimations, forceActualized: false)
|
return context.engine.stickers.loadedStickerPack(reference: .emojiGenericAnimations, forceActualized: false)
|
||||||
@ -344,16 +344,16 @@ public final class EmojiStatusSelectionController: ViewController {
|
|||||||
self.layer.addSublayer(self.cloudLayer0)
|
self.layer.addSublayer(self.cloudLayer0)
|
||||||
self.layer.addSublayer(self.cloudLayer1)
|
self.layer.addSublayer(self.cloudLayer1)
|
||||||
|
|
||||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
self.stableEmptyResultEmojiDisposable.set((self.context.engine.data.get(
|
||||||
self.stableEmptyResultEmojiDisposable.set((self.context.account.postbox.combinedView(keys: [viewKey])
|
TelegramEngine.EngineData.Item.Collections.FeaturedEmojiPacks()
|
||||||
|> take(1)
|
)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] views in
|
|> deliverOnMainQueue).start(next: { [weak self] featuredEmojiPacks in
|
||||||
guard let strongSelf = self, let view = views.views[viewKey] as? OrderedItemListView else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var filteredFiles: [TelegramMediaFile] = []
|
var filteredFiles: [TelegramMediaFile] = []
|
||||||
let filterList: [String] = ["😖", "😫", "🫠", "😨", "❓"]
|
let filterList: [String] = ["😖", "😫", "🫠", "😨", "❓"]
|
||||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
for featuredEmojiPack in featuredEmojiPacks {
|
||||||
for item in featuredEmojiPack.topItems {
|
for item in featuredEmojiPack.topItems {
|
||||||
for attribute in item.file.attributes {
|
for attribute in item.file.attributes {
|
||||||
switch attribute {
|
switch attribute {
|
||||||
@ -423,14 +423,14 @@ public final class EmojiStatusSelectionController: ViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let viewKey = PostboxViewKey.orderedItemList(id: Namespaces.OrderedItemList.CloudFeaturedEmojiPacks)
|
let _ = (strongSelf.context.engine.data.get(
|
||||||
let _ = (strongSelf.context.account.postbox.combinedView(keys: [viewKey])
|
TelegramEngine.EngineData.Item.Collections.FeaturedEmojiPacks()
|
||||||
|> take(1)
|
)
|
||||||
|> deliverOnMainQueue).start(next: { views in
|
|> deliverOnMainQueue).start(next: { featuredEmojiPacks in
|
||||||
guard let strongSelf = self, let view = views.views[viewKey] as? OrderedItemListView else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for featuredEmojiPack in view.items.lazy.map({ $0.contents.get(FeaturedStickerPackItem.self)! }) {
|
for featuredEmojiPack in featuredEmojiPacks {
|
||||||
if featuredEmojiPack.info.id == collectionId {
|
if featuredEmojiPack.info.id == collectionId {
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.scheduledEmojiContentAnimationHint = EmojiPagerContentComponent.ContentAnimation(type: .groupInstalled(id: collectionId, scrollToGroup: true))
|
strongSelf.scheduledEmojiContentAnimationHint = EmojiPagerContentComponent.ContentAnimation(type: .groupInstalled(id: collectionId, scrollToGroup: true))
|
||||||
@ -592,7 +592,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
|||||||
|> mapToSignal { files, isFinalResult -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
|> mapToSignal { files, isFinalResult -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in
|
||||||
var items: [EmojiPagerContentComponent.Item] = []
|
var items: [EmojiPagerContentComponent.Item] = []
|
||||||
|
|
||||||
var existingIds = Set<MediaId>()
|
var existingIds = Set<EngineMedia.Id>()
|
||||||
for itemFile in files {
|
for itemFile in files {
|
||||||
if existingIds.contains(itemFile.fileId) {
|
if existingIds.contains(itemFile.fileId) {
|
||||||
continue
|
continue
|
||||||
|
@ -7,7 +7,6 @@ import MultiAnimationRenderer
|
|||||||
import ComponentFlow
|
import ComponentFlow
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import EmojiTextAttachmentView
|
import EmojiTextAttachmentView
|
||||||
import TextFormat
|
import TextFormat
|
||||||
@ -52,7 +51,7 @@ public final class EmojiSuggestionsComponent: Component {
|
|||||||
|
|
||||||
let normalizedQuery = query.basicEmoji.0
|
let normalizedQuery = query.basicEmoji.0
|
||||||
|
|
||||||
var existingIds = Set<MediaId>()
|
var existingIds = Set<EngineMedia.Id>()
|
||||||
for entry in view.entries {
|
for entry in view.entries {
|
||||||
guard let item = entry.item as? StickerPackItem else {
|
guard let item = entry.item as? StickerPackItem else {
|
||||||
continue
|
continue
|
||||||
@ -179,7 +178,7 @@ public final class EmojiSuggestionsComponent: Component {
|
|||||||
private var itemLayout: ItemLayout?
|
private var itemLayout: ItemLayout?
|
||||||
private var ignoreScrolling: Bool = false
|
private var ignoreScrolling: Bool = false
|
||||||
|
|
||||||
private var visibleLayers: [MediaId: InlineStickerItemLayer] = [:]
|
private var visibleLayers: [EngineMedia.Id: InlineStickerItemLayer] = [:]
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
self.blurView = BlurredBackgroundView(color: .clear, enableBlur: true)
|
self.blurView = BlurredBackgroundView(color: .clear, enableBlur: true)
|
||||||
@ -296,7 +295,7 @@ public final class EmojiSuggestionsComponent: Component {
|
|||||||
|
|
||||||
let visibleBounds = self.scrollView.bounds
|
let visibleBounds = self.scrollView.bounds
|
||||||
|
|
||||||
var visibleIds = Set<MediaId>()
|
var visibleIds = Set<EngineMedia.Id>()
|
||||||
for i in 0 ..< component.files.count {
|
for i in 0 ..< component.files.count {
|
||||||
let itemFrame = itemLayout.frame(at: i)
|
let itemFrame = itemLayout.frame(at: i)
|
||||||
if visibleBounds.intersects(itemFrame) {
|
if visibleBounds.intersects(itemFrame) {
|
||||||
@ -330,7 +329,7 @@ public final class EmojiSuggestionsComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var removedIds: [MediaId] = []
|
var removedIds: [EngineMedia.Id] = []
|
||||||
for (id, itemLayer) in self.visibleLayers {
|
for (id, itemLayer) in self.visibleLayers {
|
||||||
if !visibleIds.contains(id) {
|
if !visibleIds.contains(id) {
|
||||||
itemLayer.removeFromSuperlayer()
|
itemLayer.removeFromSuperlayer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user