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
6e3cc4a6e9
commit
7a24eb2462
@ -197,7 +197,7 @@ private func filtersWithAppliedOrder(filters: [(ChatListFilter, Int)], order: [I
|
||||
return sortedFilters
|
||||
}
|
||||
|
||||
private func chatListFilterPresetListControllerEntries(presentationData: PresentationData, state: ChatListFilterPresetListControllerState, filters: [(ChatListFilter, Int)], updatedFilterOrder: [Int32]?, suggestedFilters: [ChatListFeaturedFilter], settings: ChatListFilterSettings, isPremium: Bool, limits: EngineConfiguration.UserLimits, premiumLimits: EngineConfiguration.UserLimits) -> [ChatListFilterPresetListEntry] {
|
||||
private func chatListFilterPresetListControllerEntries(presentationData: PresentationData, state: ChatListFilterPresetListControllerState, filters: [(ChatListFilter, Int)], updatedFilterOrder: [Int32]?, suggestedFilters: [ChatListFeaturedFilter], isPremium: Bool, limits: EngineConfiguration.UserLimits, premiumLimits: EngineConfiguration.UserLimits) -> [ChatListFilterPresetListEntry] {
|
||||
var entries: [ChatListFilterPresetListEntry] = []
|
||||
|
||||
entries.append(.screenHeader(presentationData.strings.ChatListFolderSettings_Info))
|
||||
@ -522,7 +522,6 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
let limits = allLimits.0
|
||||
let premiumLimits = allLimits.1
|
||||
|
||||
let filterSettings = preferences.values[ApplicationSpecificPreferencesKeys.chatListFilterSettings]?.get(ChatListFilterSettings.self) ?? ChatListFilterSettings.default
|
||||
let leftNavigationButton: ItemListNavigationButton?
|
||||
switch mode {
|
||||
case .default:
|
||||
@ -590,7 +589,7 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
||||
}
|
||||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.ChatListFolderSettings_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: chatListFilterPresetListControllerEntries(presentationData: presentationData, state: state, filters: filtersWithCountsValue, updatedFilterOrder: updatedFilterOrderValue, suggestedFilters: suggestedFilters, settings: filterSettings, isPremium: isPremium, limits: limits, premiumLimits: premiumLimits), style: .blocks, animateChanges: true)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: chatListFilterPresetListControllerEntries(presentationData: presentationData, state: state, filters: filtersWithCountsValue, updatedFilterOrder: updatedFilterOrderValue, suggestedFilters: suggestedFilters, isPremium: isPremium, limits: limits, premiumLimits: premiumLimits), style: .blocks, animateChanges: true)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [])
|
||||
let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer, text: "", attributes: [], media: [map], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil)
|
||||
|
||||
let controller = LocationViewController(context: self.context, subject: message, params: controllerParams)
|
||||
let controller = LocationViewController(context: self.context, subject: EngineMessage(message), params: controllerParams)
|
||||
self.pushController(controller)
|
||||
return
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
@ -305,7 +304,7 @@ private struct FolderInviteLinkListControllerState: Equatable {
|
||||
var isSaving: Bool = false
|
||||
}
|
||||
|
||||
public func folderInviteLinkListController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, filterId: Int32, title filterTitle: String, allPeerIds: [PeerId], currentInvitation: ExportedChatFolderLink?, linkUpdated: @escaping (ExportedChatFolderLink?) -> Void, presentController parentPresentController: ((ViewController) -> Void)?) -> ViewController {
|
||||
public func folderInviteLinkListController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, filterId: Int32, title filterTitle: String, allPeerIds: [EnginePeer.Id], currentInvitation: ExportedChatFolderLink?, linkUpdated: @escaping (ExportedChatFolderLink?) -> Void, presentController parentPresentController: ((ViewController) -> Void)?) -> ViewController {
|
||||
var pushControllerImpl: ((ViewController) -> Void)?
|
||||
let _ = pushControllerImpl
|
||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
||||
|
@ -4,7 +4,6 @@ import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import AppBundle
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import Display
|
||||
import AccountContext
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
@ -4,7 +4,6 @@ import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import AppBundle
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import Display
|
||||
import AccountContext
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import ItemListUI
|
||||
@ -97,7 +96,7 @@ final class SearchNavigationContentNode: NavigationBarContentNode, ItemListContr
|
||||
|
||||
final class InviteRequestsSearchItem: ItemListControllerSearch {
|
||||
let context: AccountContext
|
||||
let peerId: PeerId
|
||||
let peerId: EnginePeer.Id
|
||||
let cancel: () -> Void
|
||||
let openPeer: (EnginePeer) -> Void
|
||||
let approveRequest: (EnginePeer) -> Void
|
||||
@ -111,7 +110,7 @@ final class InviteRequestsSearchItem: ItemListControllerSearch {
|
||||
private var activity: ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
|
||||
private let activityDisposable = MetaDisposable()
|
||||
|
||||
init(context: AccountContext, peerId: PeerId, cancel: @escaping () -> Void, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, pushController: @escaping (ViewController) -> Void, dismissInput: @escaping () -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
init(context: AccountContext, peerId: EnginePeer.Id, cancel: @escaping () -> Void, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, pushController: @escaping (ViewController) -> Void, dismissInput: @escaping () -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.cancel = cancel
|
||||
@ -175,7 +174,7 @@ final class InviteRequestsSearchItem: ItemListControllerSearch {
|
||||
private final class InviteRequestsSearchItemNode: ItemListControllerSearchNode {
|
||||
private let containerNode: InviteRequestsSearchContainerNode
|
||||
|
||||
init(context: AccountContext, peerId: PeerId, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, cancel: @escaping () -> Void, updateActivity: @escaping(Bool) -> Void, pushController: @escaping (ViewController) -> Void, dismissInput: @escaping () -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
init(context: AccountContext, peerId: EnginePeer.Id, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, cancel: @escaping () -> Void, updateActivity: @escaping(Bool) -> Void, pushController: @escaping (ViewController) -> Void, dismissInput: @escaping () -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
self.containerNode = InviteRequestsSearchContainerNode(context: context, forceTheme: nil, peerId: peerId, openPeer: { peer in
|
||||
openPeer(peer)
|
||||
}, approveRequest: { peer in
|
||||
@ -340,14 +339,14 @@ public final class InviteRequestsSearchContainerNode: SearchDisplayControllerCon
|
||||
return _hasDim
|
||||
}
|
||||
|
||||
private var processedPeerIdsPromise = ValuePromise<Set<PeerId>>(Set())
|
||||
private var processedPeerIds = Set<PeerId>() {
|
||||
private var processedPeerIdsPromise = ValuePromise<Set<EnginePeer.Id>>(Set())
|
||||
private var processedPeerIds = Set<EnginePeer.Id>() {
|
||||
didSet {
|
||||
self.processedPeerIdsPromise.set(self.processedPeerIds)
|
||||
}
|
||||
}
|
||||
|
||||
public init(context: AccountContext, forceTheme: PresentationTheme?, peerId: PeerId, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, updateActivity: @escaping (Bool) -> Void, pushController: @escaping (ViewController) -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
public init(context: AccountContext, forceTheme: PresentationTheme?, peerId: EnginePeer.Id, openPeer: @escaping (EnginePeer) -> Void, approveRequest: @escaping (EnginePeer) -> Void, denyRequest: @escaping (EnginePeer) -> Void, navigateToChat: @escaping (EnginePeer) -> Void, updateActivity: @escaping (Bool) -> Void, pushController: @escaping (ViewController) -> Void, presentInGlobalOverlay: @escaping (ViewController) -> Void) {
|
||||
self.context = context
|
||||
self.openPeer = openPeer
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramUIPreferences
|
||||
import PersistentStringHash
|
||||
@ -33,7 +32,7 @@ public final class CachedGeocode: Codable {
|
||||
}
|
||||
|
||||
private func cachedGeocode(engine: TelegramEngine, address: DeviceContactAddressData) -> Signal<CachedGeocode?, NoError> {
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = EngineDataBuffer(length: 8)
|
||||
key.setInt64(0, value: Int64(bitPattern: address.string.persistentHashValue))
|
||||
|
||||
return engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: ApplicationSpecificItemCacheCollectionId.cachedGeocodes, id: key))
|
||||
@ -43,7 +42,7 @@ private func cachedGeocode(engine: TelegramEngine, address: DeviceContactAddress
|
||||
}
|
||||
|
||||
private func updateCachedGeocode(engine: TelegramEngine, address: DeviceContactAddressData, latitude: Double, longitude: Double) -> Signal<(Double, Double), NoError> {
|
||||
let key = ValueBoxKey(length: 8)
|
||||
let key = EngineDataBuffer(length: 8)
|
||||
key.setInt64(0, value: Int64(bitPattern: address.string.persistentHashValue))
|
||||
|
||||
return engine.itemCache.put(collectionId: ApplicationSpecificItemCacheCollectionId.cachedGeocodes, id: key, item: CachedGeocode(latitude: latitude, longitude: longitude))
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import MapKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AvatarNode
|
||||
import AppBundle
|
||||
@ -39,8 +38,8 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
||||
}
|
||||
}
|
||||
let location: TelegramMediaMap?
|
||||
let peer: Peer?
|
||||
let message: Message?
|
||||
let peer: EnginePeer?
|
||||
let message: EngineMessage?
|
||||
let forcedSelection: Bool
|
||||
@objc dynamic var heading: NSNumber? {
|
||||
willSet {
|
||||
@ -52,11 +51,11 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
||||
}
|
||||
|
||||
var isSelf = false
|
||||
var selfPeer: Peer?
|
||||
var selfPeer: EnginePeer?
|
||||
var title: String? = ""
|
||||
var subtitle: String? = ""
|
||||
|
||||
init(context: AccountContext, theme: PresentationTheme, peer: Peer) {
|
||||
init(context: AccountContext, theme: PresentationTheme, peer: EnginePeer) {
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
self.location = nil
|
||||
@ -78,7 +77,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
||||
super.init()
|
||||
}
|
||||
|
||||
init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, isSelf: Bool, heading: Int32?) {
|
||||
init(context: AccountContext, theme: PresentationTheme, message: EngineMessage, selfPeer: EnginePeer?, isSelf: Bool, heading: Int32?) {
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
self.location = nil
|
||||
@ -538,8 +537,8 @@ class LocationPinAnnotationView: MKAnnotationView {
|
||||
}
|
||||
}
|
||||
|
||||
var previousPeerId: PeerId?
|
||||
func setPeer(context: AccountContext, theme: PresentationTheme, peer: Peer) {
|
||||
var previousPeerId: EnginePeer.Id?
|
||||
func setPeer(context: AccountContext, theme: PresentationTheme, peer: EnginePeer) {
|
||||
let avatarNode: AvatarNode
|
||||
if let currentAvatarNode = self.avatarNode {
|
||||
avatarNode = currentAvatarNode
|
||||
@ -554,7 +553,7 @@ class LocationPinAnnotationView: MKAnnotationView {
|
||||
|
||||
if self.previousPeerId != peer.id {
|
||||
self.previousPeerId = peer.id
|
||||
avatarNode.setPeer(context: context, theme: theme, peer: EnginePeer(peer))
|
||||
avatarNode.setPeer(context: context, theme: theme, peer: peer)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import AccountContext
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
@ -21,7 +20,7 @@ final class LocationLiveListItem: ListViewItem {
|
||||
let dateTimeFormat: PresentationDateTimeFormat
|
||||
let nameDisplayOrder: PresentationPersonNameOrder
|
||||
let context: AccountContext
|
||||
let message: Message
|
||||
let message: EngineMessage
|
||||
let distance: Double?
|
||||
|
||||
let drivingTime: ExpectedTravelTime
|
||||
@ -35,7 +34,7 @@ final class LocationLiveListItem: ListViewItem {
|
||||
let transitAction: () -> Void
|
||||
let walkingAction: () -> Void
|
||||
|
||||
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, message: Message, distance: Double?, drivingTime: ExpectedTravelTime, transitTime: ExpectedTravelTime, walkingTime: ExpectedTravelTime, action: @escaping () -> Void, longTapAction: @escaping () -> Void = { }, drivingAction: @escaping () -> Void, transitAction: @escaping () -> Void, walkingAction: @escaping () -> Void) {
|
||||
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, message: EngineMessage, distance: Double?, drivingTime: ExpectedTravelTime, transitTime: ExpectedTravelTime, walkingTime: ExpectedTravelTime, action: @escaping () -> Void, longTapAction: @escaping () -> Void = { }, drivingAction: @escaping () -> Void, transitAction: @escaping () -> Void, walkingAction: @escaping () -> Void) {
|
||||
self.presentationData = presentationData
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
self.nameDisplayOrder = nameDisplayOrder
|
||||
@ -179,7 +178,7 @@ final class LocationLiveListItemNode: ListViewItemNode {
|
||||
|
||||
var title: String = ""
|
||||
if let author = item.message.author {
|
||||
title = EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.nameDisplayOrder)
|
||||
title = author.displayTitle(strings: item.presentationData.strings, displayOrder: item.nameDisplayOrder)
|
||||
}
|
||||
let titleAttributedString = NSAttributedString(string: title, font: titleFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset - 54.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
@ -306,7 +305,7 @@ final class LocationLiveListItemNode: ListViewItemNode {
|
||||
let avatarSize: CGFloat = 40.0
|
||||
|
||||
if let peer = item.message.author {
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: nil, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: false)
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: nil, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: false)
|
||||
}
|
||||
|
||||
strongSelf.avatarNode.frame = CGRect(origin: CGPoint(x: params.leftInset + 15.0, y: 8.0), size: CGSize(width: avatarSize, height: avatarSize))
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import SegmentedControlNode
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import Display
|
||||
import LegacyComponents
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
@ -14,7 +13,7 @@ import DeviceAccess
|
||||
import AttachmentUI
|
||||
|
||||
public enum LocationPickerMode {
|
||||
case share(peer: Peer?, selfPeer: Peer?, hasLiveLocation: Bool)
|
||||
case share(peer: EnginePeer?, selfPeer: EnginePeer?, hasLiveLocation: Bool)
|
||||
case pick
|
||||
}
|
||||
|
||||
@ -133,8 +132,8 @@ public final class LocationPickerController: ViewController, AttachmentContainab
|
||||
}
|
||||
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
|
||||
if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer as? TelegramUser {
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(EnginePeer(receiver).compactDisplayTitle).string
|
||||
if case let .share(peer, _, _) = strongSelf.mode, let peer = peer, case .user = peer {
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(peer.compactDisplayTitle).string
|
||||
}
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: [
|
||||
|
@ -4,7 +4,6 @@ import AsyncDisplayKit
|
||||
import Display
|
||||
import LegacyComponents
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import MergeLists
|
||||
import ItemListUI
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramStringFormatting
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import SearchBarNode
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import Display
|
||||
import LegacyComponents
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import TelegramStringFormatting
|
||||
@ -19,12 +18,12 @@ import MapKit
|
||||
|
||||
public class LocationViewParams {
|
||||
let sendLiveLocation: (TelegramMediaMap) -> Void
|
||||
let stopLiveLocation: (MessageId?) -> Void
|
||||
let stopLiveLocation: (EngineMessage.Id?) -> Void
|
||||
let openUrl: (String) -> Void
|
||||
let openPeer: (Peer) -> Void
|
||||
let openPeer: (EnginePeer) -> Void
|
||||
let showAll: Bool
|
||||
|
||||
public init(sendLiveLocation: @escaping (TelegramMediaMap) -> Void, stopLiveLocation: @escaping (MessageId?) -> Void, openUrl: @escaping (String) -> Void, openPeer: @escaping (Peer) -> Void, showAll: Bool = false) {
|
||||
public init(sendLiveLocation: @escaping (TelegramMediaMap) -> Void, stopLiveLocation: @escaping (EngineMessage.Id?) -> Void, openUrl: @escaping (String) -> Void, openPeer: @escaping (EnginePeer) -> Void, showAll: Bool = false) {
|
||||
self.sendLiveLocation = sendLiveLocation
|
||||
self.stopLiveLocation = stopLiveLocation
|
||||
self.openUrl = openUrl
|
||||
@ -46,14 +45,14 @@ class LocationViewInteraction {
|
||||
let goToCoordinate: (CLLocationCoordinate2D) -> Void
|
||||
let requestDirections: (TelegramMediaMap, String?, OpenInLocationDirections) -> Void
|
||||
let share: () -> Void
|
||||
let setupProximityNotification: (Bool, MessageId?) -> Void
|
||||
let setupProximityNotification: (Bool, EngineMessage.Id?) -> Void
|
||||
let updateSendActionHighlight: (Bool) -> Void
|
||||
let sendLiveLocation: (Int32?) -> Void
|
||||
let stopLiveLocation: () -> Void
|
||||
let updateRightBarButton: (LocationViewRightBarButton) -> Void
|
||||
let present: (ViewController) -> Void
|
||||
|
||||
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, toggleTrackingMode: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping (TelegramMediaMap, String?, OpenInLocationDirections) -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (Bool, MessageId?) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (Int32?) -> Void, stopLiveLocation: @escaping () -> Void, updateRightBarButton: @escaping (LocationViewRightBarButton) -> Void, present: @escaping (ViewController) -> Void) {
|
||||
init(toggleMapModeSelection: @escaping () -> Void, updateMapMode: @escaping (LocationMapMode) -> Void, toggleTrackingMode: @escaping () -> Void, goToCoordinate: @escaping (CLLocationCoordinate2D) -> Void, requestDirections: @escaping (TelegramMediaMap, String?, OpenInLocationDirections) -> Void, share: @escaping () -> Void, setupProximityNotification: @escaping (Bool, EngineMessage.Id?) -> Void, updateSendActionHighlight: @escaping (Bool) -> Void, sendLiveLocation: @escaping (Int32?) -> Void, stopLiveLocation: @escaping () -> Void, updateRightBarButton: @escaping (LocationViewRightBarButton) -> Void, present: @escaping (ViewController) -> Void) {
|
||||
self.toggleMapModeSelection = toggleMapModeSelection
|
||||
self.updateMapMode = updateMapMode
|
||||
self.toggleTrackingMode = toggleTrackingMode
|
||||
@ -74,7 +73,7 @@ public final class LocationViewController: ViewController {
|
||||
return self.displayNode as! LocationViewControllerNode
|
||||
}
|
||||
private let context: AccountContext
|
||||
public var subject: Message
|
||||
public var subject: EngineMessage
|
||||
private var presentationData: PresentationData
|
||||
private var presentationDataDisposable: Disposable?
|
||||
private var showAll: Bool
|
||||
@ -86,7 +85,7 @@ public final class LocationViewController: ViewController {
|
||||
|
||||
private var rightBarButtonAction: LocationViewRightBarButton = .none
|
||||
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, subject: Message, params: LocationViewParams) {
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, subject: EngineMessage, params: LocationViewParams) {
|
||||
self.context = context
|
||||
self.subject = subject
|
||||
self.showAll = params.showAll
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import Display
|
||||
import LegacyComponents
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import MergeLists
|
||||
import ItemListUI
|
||||
@ -19,11 +18,11 @@ import Geocoding
|
||||
import DeviceAccess
|
||||
import TooltipUI
|
||||
|
||||
func getLocation(from message: Message) -> TelegramMediaMap? {
|
||||
func getLocation(from message: EngineMessage) -> TelegramMediaMap? {
|
||||
return message.media.first(where: { $0 is TelegramMediaMap } ) as? TelegramMediaMap
|
||||
}
|
||||
|
||||
private func areMessagesEqual(_ lhsMessage: Message, _ rhsMessage: Message) -> Bool {
|
||||
private func areMessagesEqual(_ lhsMessage: EngineMessage, _ rhsMessage: EngineMessage) -> Bool {
|
||||
if lhsMessage.stableVersion != rhsMessage.stableVersion {
|
||||
return false
|
||||
}
|
||||
@ -50,7 +49,7 @@ private enum LocationViewEntryId: Hashable {
|
||||
private enum LocationViewEntry: Comparable, Identifiable {
|
||||
case info(PresentationTheme, TelegramMediaMap, String?, Double?, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime)
|
||||
case toggleLiveLocation(PresentationTheme, String, String, Double?, Double?)
|
||||
case liveLocation(PresentationTheme, PresentationDateTimeFormat, PresentationPersonNameOrder, Message, Double?, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime, Int)
|
||||
case liveLocation(PresentationTheme, PresentationDateTimeFormat, PresentationPersonNameOrder, EngineMessage, Double?, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime, Int)
|
||||
|
||||
var stableId: LocationViewEntryId {
|
||||
switch self {
|
||||
@ -155,7 +154,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
|
||||
case let .liveLocation(_, dateTimeFormat, nameDisplayOrder, message, distance, drivingTime, transitTime, walkingTime, _):
|
||||
var title: String?
|
||||
if let author = message.author {
|
||||
title = EnginePeer(author).displayTitle(strings: presentationData.strings, displayOrder: nameDisplayOrder)
|
||||
title = author.displayTitle(strings: presentationData.strings, displayOrder: nameDisplayOrder)
|
||||
}
|
||||
return LocationLiveListItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: context, message: message, distance: distance, drivingTime: drivingTime, transitTime: transitTime, walkingTime: walkingTime, action: {
|
||||
if let location = getLocation(from: message) {
|
||||
@ -217,7 +216,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
private let context: AccountContext
|
||||
private var presentationData: PresentationData
|
||||
private let presentationDataPromise: Promise<PresentationData>
|
||||
private var subject: Message
|
||||
private var subject: EngineMessage
|
||||
private let interaction: LocationViewInteraction
|
||||
private let locationManager: LocationManager
|
||||
|
||||
@ -247,7 +246,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
}
|
||||
private let travelTimesPromise = Promise<[EngineMessage.Id: (Double, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime)]>([:])
|
||||
|
||||
init(context: AccountContext, presentationData: PresentationData, subject: Message, interaction: LocationViewInteraction, locationManager: LocationManager) {
|
||||
init(context: AccountContext, presentationData: PresentationData, subject: EngineMessage, interaction: LocationViewInteraction, locationManager: LocationManager) {
|
||||
self.context = context
|
||||
self.presentationData = presentationData
|
||||
self.presentationDataPromise = Promise(presentationData)
|
||||
@ -321,15 +320,15 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
}
|
||||
|
||||
let liveLocations = context.engine.messages.topPeerActiveLiveLocationMessages(peerId: subject.id.peerId)
|
||||
|> map { _, messages -> [Message] in
|
||||
return messages
|
||||
|> map { _, messages -> [EngineMessage] in
|
||||
return messages.map(EngineMessage.init)
|
||||
}
|
||||
|
||||
setupProximityNotificationImpl = { reset in
|
||||
let _ = (liveLocations
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { messages in
|
||||
var ownMessageId: MessageId?
|
||||
var ownMessageId: EngineMessage.Id?
|
||||
for message in messages {
|
||||
if message.localTags.contains(.OutgoingLiveLocation) {
|
||||
ownMessageId = message.id
|
||||
@ -356,7 +355,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
var entries: [LocationViewEntry] = []
|
||||
var annotations: [LocationPinAnnotation] = []
|
||||
var userAnnotation: LocationPinAnnotation? = nil
|
||||
var effectiveLiveLocations: [Message] = liveLocations
|
||||
var effectiveLiveLocations: [EngineMessage] = liveLocations
|
||||
|
||||
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
|
||||
@ -375,7 +374,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
|
||||
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, location: location, forcedSelection: true))
|
||||
} else {
|
||||
var activeOwnLiveLocation: Message?
|
||||
var activeOwnLiveLocation: EngineMessage?
|
||||
for message in effectiveLiveLocations {
|
||||
if message.localTags.contains(.OutgoingLiveLocation) {
|
||||
activeOwnLiveLocation = message
|
||||
@ -417,14 +416,14 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
timeout = nil
|
||||
}
|
||||
|
||||
if let channel = subject.author as? TelegramChannel, case .broadcast = channel.info, activeOwnLiveLocation == nil {
|
||||
if case let .channel(channel) = subject.author, case .broadcast = channel.info, activeOwnLiveLocation == nil {
|
||||
} else {
|
||||
entries.append(.toggleLiveLocation(presentationData.theme, title, subtitle, beginTime, timeout))
|
||||
}
|
||||
|
||||
var sortedLiveLocations: [Message] = []
|
||||
var sortedLiveLocations: [EngineMessage] = []
|
||||
|
||||
var effectiveSubject: Message?
|
||||
var effectiveSubject: EngineMessage?
|
||||
for message in effectiveLiveLocations {
|
||||
if message.id == subject.id {
|
||||
effectiveSubject = message
|
||||
@ -460,7 +459,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
|
||||
let timestamp = CACurrentMediaTime()
|
||||
if message.localTags.contains(.OutgoingLiveLocation), let selfPeer = selfPeer {
|
||||
userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer._asPeer(), isSelf: true, heading: location.heading)
|
||||
userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: true, heading: location.heading)
|
||||
} else {
|
||||
var drivingTime: ExpectedTravelTime = .unknown
|
||||
var transitTime: ExpectedTravelTime = .unknown
|
||||
@ -515,7 +514,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
}
|
||||
}
|
||||
|
||||
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer?._asPeer(), isSelf: message.author?.id == context.account.peerId, heading: location.heading))
|
||||
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: message.author?.id == context.account.peerId, heading: location.heading))
|
||||
entries.append(.liveLocation(presentationData.theme, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, message, distance, drivingTime, transitTime, walkingTime, index))
|
||||
}
|
||||
index += 1
|
||||
@ -533,7 +532,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
if subject.id.peerId.namespace != Namespaces.Peer.CloudUser, proximityNotification == nil {
|
||||
proximityNotification = false
|
||||
}
|
||||
if let channel = subject.author as? TelegramChannel, case .broadcast = channel.info {
|
||||
if case let .channel(channel) = subject.author, case .broadcast = channel.info {
|
||||
proximityNotification = nil
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ItemListUI
|
||||
@ -106,7 +105,7 @@ private struct PeerAutoremoveSetupState: Equatable {
|
||||
var applyingSetting: Bool = false
|
||||
}
|
||||
|
||||
private func peerAutoremoveSetupEntries(peer: Peer?, presentationData: PresentationData, isDebug: Bool, defaultValue: Int32, state: PeerAutoremoveSetupState) -> [PeerAutoremoveSetupEntry] {
|
||||
private func peerAutoremoveSetupEntries(peer: EnginePeer?, presentationData: PresentationData, isDebug: Bool, defaultValue: Int32, state: PeerAutoremoveSetupState) -> [PeerAutoremoveSetupEntry] {
|
||||
var entries: [PeerAutoremoveSetupEntry] = []
|
||||
|
||||
let resolvedValue: Int32
|
||||
@ -127,7 +126,7 @@ private func peerAutoremoveSetupEntries(peer: Peer?, presentationData: Presentat
|
||||
availableValues[2] = 5 * 60
|
||||
}
|
||||
entries.append(.timeValue(resolvedValue, availableValues))
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
if case let .channel(channel) = peer, case .broadcast = channel.info {
|
||||
entries.append(.timeComment(presentationData.strings.AutoremoveSetup_TimerInfoChannel))
|
||||
} else {
|
||||
entries.append(.timeComment(presentationData.strings.AutoremoveSetup_TimerInfoChat))
|
||||
@ -145,7 +144,7 @@ public enum PeerAutoremoveSetupScreenResult {
|
||||
case updated(Updated)
|
||||
}
|
||||
|
||||
public func peerAutoremoveSetupScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: PeerId, completion: @escaping (PeerAutoremoveSetupScreenResult) -> Void = { _ in }) -> ViewController {
|
||||
public func peerAutoremoveSetupScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id, completion: @escaping (PeerAutoremoveSetupScreenResult) -> Void = { _ in }) -> ViewController {
|
||||
let statePromise = ValuePromise(PeerAutoremoveSetupState(), ignoreRepeated: true)
|
||||
let stateValue = Atomic(value: PeerAutoremoveSetupState())
|
||||
let updateState: ((PeerAutoremoveSetupState) -> PeerAutoremoveSetupState) -> Void = { f in
|
||||
@ -240,7 +239,7 @@ public func peerAutoremoveSetupScreen(context: AccountContext, updatedPresentati
|
||||
let isDebug = context.account.testingEnvironment
|
||||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(presentationData.strings.AutoremoveSetup_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: peerAutoremoveSetupEntries(peer: peer, presentationData: presentationData, isDebug: isDebug, defaultValue: defaultValue, state: state), style: .blocks)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: peerAutoremoveSetupEntries(peer: peer.flatMap(EnginePeer.init), presentationData: presentationData, isDebug: isDebug, defaultValue: defaultValue, state: state), style: .blocks)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ItemListUI
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
@ -6,6 +6,8 @@ public protocol AccountManagerTypes {
|
||||
associatedtype Attribute: AccountRecordAttribute
|
||||
}
|
||||
|
||||
public typealias SharedPreferencesEntry = PreferencesEntry
|
||||
|
||||
public struct AccountManagerModifier<Types: AccountManagerTypes> {
|
||||
public let getRecords: () -> [AccountRecord<Types.Attribute>]
|
||||
public let updateRecord: (AccountRecordId, (AccountRecord<Types.Attribute>?) -> (AccountRecord<Types.Attribute>?)) -> Void
|
||||
|
@ -13249,7 +13249,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return
|
||||
}
|
||||
let hasLiveLocation = peer.id.namespace != Namespaces.Peer.SecretChat && peer.id != strongSelf.context.account.peerId && strongSelf.presentationInterfaceState.subject != .scheduledMessages
|
||||
let controller = LocationPickerController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, mode: .share(peer: peer, selfPeer: selfPeer._asPeer(), hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in
|
||||
let controller = LocationPickerController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, mode: .share(peer: EnginePeer(peer), selfPeer: selfPeer, hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -14239,7 +14239,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return
|
||||
}
|
||||
let hasLiveLocation = peer.id.namespace != Namespaces.Peer.SecretChat && peer.id != strongSelf.context.account.peerId && strongSelf.presentationInterfaceState.subject != .scheduledMessages
|
||||
let controller = LocationPickerController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, mode: .share(peer: peer, selfPeer: selfPeer._asPeer(), hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in
|
||||
let controller = LocationPickerController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, mode: .share(peer: EnginePeer(peer), selfPeer: selfPeer, hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
||||
}, stopLiveLocation: { messageId in
|
||||
params.context.liveLocationManager?.cancelLiveLocation(peerId: messageId?.peerId ?? params.message.id.peerId)
|
||||
}, openUrl: params.openUrl, openPeer: { peer in
|
||||
params.openPeer(peer, .info)
|
||||
params.openPeer(peer._asPeer(), .info)
|
||||
}, showAll: params.modal)
|
||||
let controller = LocationViewController(context: params.context, updatedPresentationData: params.updatedPresentationData, subject: params.message, params: controllerParams)
|
||||
let controller = LocationViewController(context: params.context, updatedPresentationData: params.updatedPresentationData, subject: EngineMessage(params.message), params: controllerParams)
|
||||
controller.navigationPresentation = .modal
|
||||
params.navigationController?.pushViewController(controller)
|
||||
return true
|
||||
|
@ -6784,7 +6784,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
|
||||
let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer, text: "", attributes: [], media: [map], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil)
|
||||
|
||||
let controller = LocationViewController(context: context, updatedPresentationData: self.controller?.updatedPresentationData, subject: message, params: controllerParams)
|
||||
let controller = LocationViewController(context: context, updatedPresentationData: self.controller?.updatedPresentationData, subject: EngineMessage(message), params: controllerParams)
|
||||
self.controller?.push(controller)
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
guard let message = message else {
|
||||
return
|
||||
}
|
||||
let controller = LocationViewController(context: context, subject: message._asMessage(), params: controllerParams)
|
||||
let controller = LocationViewController(context: context, subject: message, params: controllerParams)
|
||||
controller.navigationPresentation = .modal
|
||||
navigationController.pushViewController(controller)
|
||||
})
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
|
||||
public struct CallListSettings: Codable, Equatable {
|
||||
public var _showTab: Bool?
|
||||
@ -78,7 +77,7 @@ public func updateCallListSettingsInteractively(accountManager: AccountManager<T
|
||||
} else {
|
||||
currentSettings = CallListSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
|
||||
public struct ChatArchiveSettings: Equatable, Codable {
|
||||
public var isHiddenByDefault: Bool
|
||||
@ -43,6 +42,6 @@ public func updateChatArchiveSettings(engine: TelegramEngine, _ f: @escaping (Ch
|
||||
} else {
|
||||
currentSettings = .default
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
|
||||
public struct ChatListFilterSettings: Equatable, Codable {
|
||||
public static var `default`: ChatListFilterSettings {
|
||||
return ChatListFilterSettings()
|
||||
}
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
}
|
||||
}
|
||||
|
||||
public func updateChatListFilterSettings(transaction: Transaction, _ f: @escaping (ChatListFilterSettings) -> ChatListFilterSettings) {
|
||||
transaction.updatePreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatListFilterSettings, { entry in
|
||||
let currentSettings: ChatListFilterSettings
|
||||
if let entry = entry?.get(ChatListFilterSettings.self) {
|
||||
currentSettings = entry
|
||||
} else {
|
||||
currentSettings = .default
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -31,7 +30,7 @@ public func updateExperimentalSettingsInteractively(accountManager: AccountManag
|
||||
} else {
|
||||
currentSettings = ExperimentalSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -7,10 +6,10 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
||||
public struct AccountReactionOverrides: Equatable, Codable {
|
||||
public struct Item: Equatable, Codable {
|
||||
public var key: MessageReaction.Reaction
|
||||
public var messageId: MessageId
|
||||
public var mediaId: MediaId
|
||||
public var messageId: EngineMessage.Id
|
||||
public var mediaId: EngineMedia.Id
|
||||
|
||||
public init(key: MessageReaction.Reaction, messageId: MessageId, mediaId: MediaId) {
|
||||
public init(key: MessageReaction.Reaction, messageId: EngineMessage.Id, mediaId: EngineMedia.Id) {
|
||||
self.key = key
|
||||
self.messageId = messageId
|
||||
self.mediaId = mediaId
|
||||
@ -206,7 +205,7 @@ public func updateExperimentalUISettingsInteractively(accountManager: AccountMan
|
||||
} else {
|
||||
currentSettings = .defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -48,7 +47,7 @@ public func updateGeneratedMediaStoreSettingsInteractively(accountManager: Accou
|
||||
} else {
|
||||
currentSettings = GeneratedMediaStoreSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
public struct IntentsSettings: Codable, Equatable {
|
||||
public let initiallyReset: Bool
|
||||
|
||||
public let account: PeerId?
|
||||
public let account: EnginePeer.Id?
|
||||
public let contacts: Bool
|
||||
public let privateChats: Bool
|
||||
public let savedMessages: Bool
|
||||
@ -17,7 +16,7 @@ public struct IntentsSettings: Codable, Equatable {
|
||||
return IntentsSettings(initiallyReset: false, account: nil, contacts: true, privateChats: false, savedMessages: true, groups: false, onlyShared: false)
|
||||
}
|
||||
|
||||
public init(initiallyReset: Bool, account: PeerId?, contacts: Bool, privateChats: Bool, savedMessages: Bool, groups: Bool, onlyShared: Bool) {
|
||||
public init(initiallyReset: Bool, account: EnginePeer.Id?, contacts: Bool, privateChats: Bool, savedMessages: Bool, groups: Bool, onlyShared: Bool) {
|
||||
self.initiallyReset = initiallyReset
|
||||
self.account = account
|
||||
self.contacts = contacts
|
||||
@ -31,7 +30,7 @@ public struct IntentsSettings: Codable, Equatable {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
self.initiallyReset = try container.decodeIfPresent(Bool.self, forKey: "initiallyReset_v2") ?? false
|
||||
self.account = (try container.decodeIfPresent(Int64.self, forKey: "account")).flatMap { PeerId($0) }
|
||||
self.account = (try container.decodeIfPresent(Int64.self, forKey: "account")).flatMap { EnginePeer.Id($0) }
|
||||
self.contacts = try container.decodeIfPresent(Bool.self, forKey: "contacts") ?? true
|
||||
self.privateChats = try container.decodeIfPresent(Bool.self, forKey: "privateChats") ?? false
|
||||
self.savedMessages = try container.decodeIfPresent(Bool.self, forKey: "savedMessages") ?? true
|
||||
@ -55,7 +54,7 @@ public struct IntentsSettings: Codable, Equatable {
|
||||
return lhs.initiallyReset == rhs.initiallyReset && lhs.account == rhs.account && lhs.contacts == rhs.contacts && lhs.privateChats == rhs.privateChats && lhs.savedMessages == rhs.savedMessages && lhs.groups == rhs.groups && lhs.onlyShared == rhs.onlyShared
|
||||
}
|
||||
|
||||
public func withUpdatedAccount(_ account: PeerId?) -> IntentsSettings {
|
||||
public func withUpdatedAccount(_ account: EnginePeer.Id?) -> IntentsSettings {
|
||||
return IntentsSettings(initiallyReset: self.initiallyReset, account: account, contacts: self.contacts, privateChats: self.privateChats, savedMessages: self.savedMessages, groups: self.groups, onlyShared: self.onlyShared)
|
||||
}
|
||||
|
||||
@ -94,7 +93,7 @@ public func updateIntentsSettingsInteractively(accountManager: AccountManager<Te
|
||||
}
|
||||
previousSettings = currentSettings
|
||||
updatedSettings = f(currentSettings)
|
||||
return PreferencesEntry(updatedSettings)
|
||||
return SharedPreferencesEntry(updatedSettings)
|
||||
})
|
||||
return (previousSettings, updatedSettings)
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -44,7 +43,7 @@ public func updateMediaDisplaySettingsInteractively(accountManager: AccountManag
|
||||
} else {
|
||||
currentSettings = MediaDisplaySettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -52,7 +51,7 @@ public func updateMediaInputSettingsInteractively(accountManager: AccountManager
|
||||
} else {
|
||||
currentSettings = MediaInputSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -150,7 +149,7 @@ public func updateMusicPlaybackSettingsInteractively(accountManager: AccountMana
|
||||
} else {
|
||||
currentSettings = MusicPlaybackSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -73,6 +72,6 @@ public func updatePresentationPasscodeSettingsInternal(transaction: AccountManag
|
||||
} else {
|
||||
currentSettings = PresentationPasscodeSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -70,7 +69,7 @@ public func updateStickerSettingsInteractively(accountManager: AccountManager<Te
|
||||
} else {
|
||||
currentSettings = StickerSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -60,7 +59,7 @@ public func updateTranslationSettingsInteractively(accountManager: AccountManage
|
||||
} else {
|
||||
currentSettings = TranslationSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
|
||||
@ -76,7 +75,7 @@ public func updateVoiceCallSettingsSettingsInteractively(accountManager: Account
|
||||
} else {
|
||||
currentSettings = VoiceCallSettings.defaultSettings
|
||||
}
|
||||
return PreferencesEntry(f(currentSettings))
|
||||
return SharedPreferencesEntry(f(currentSettings))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user