mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +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
|
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] = []
|
var entries: [ChatListFilterPresetListEntry] = []
|
||||||
|
|
||||||
entries.append(.screenHeader(presentationData.strings.ChatListFolderSettings_Info))
|
entries.append(.screenHeader(presentationData.strings.ChatListFolderSettings_Info))
|
||||||
@ -522,7 +522,6 @@ public func chatListFilterPresetListController(context: AccountContext, mode: Ch
|
|||||||
let limits = allLimits.0
|
let limits = allLimits.0
|
||||||
let premiumLimits = allLimits.1
|
let premiumLimits = allLimits.1
|
||||||
|
|
||||||
let filterSettings = preferences.values[ApplicationSpecificPreferencesKeys.chatListFilterSettings]?.get(ChatListFilterSettings.self) ?? ChatListFilterSettings.default
|
|
||||||
let leftNavigationButton: ItemListNavigationButton?
|
let leftNavigationButton: ItemListNavigationButton?
|
||||||
switch mode {
|
switch mode {
|
||||||
case .default:
|
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 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))
|
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 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 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)
|
self.pushController(controller)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
@ -305,7 +304,7 @@ private struct FolderInviteLinkListControllerState: Equatable {
|
|||||||
var isSaving: Bool = false
|
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)?
|
var pushControllerImpl: ((ViewController) -> Void)?
|
||||||
let _ = pushControllerImpl
|
let _ = pushControllerImpl
|
||||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
|
||||||
|
@ -4,7 +4,6 @@ import SwiftSignalKit
|
|||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import AppBundle
|
import AppBundle
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Display
|
import Display
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
@ -4,7 +4,6 @@ import SwiftSignalKit
|
|||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import AppBundle
|
import AppBundle
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Display
|
import Display
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import ItemListUI
|
import ItemListUI
|
||||||
@ -97,7 +96,7 @@ final class SearchNavigationContentNode: NavigationBarContentNode, ItemListContr
|
|||||||
|
|
||||||
final class InviteRequestsSearchItem: ItemListControllerSearch {
|
final class InviteRequestsSearchItem: ItemListControllerSearch {
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let peerId: PeerId
|
let peerId: EnginePeer.Id
|
||||||
let cancel: () -> Void
|
let cancel: () -> Void
|
||||||
let openPeer: (EnginePeer) -> Void
|
let openPeer: (EnginePeer) -> Void
|
||||||
let approveRequest: (EnginePeer) -> Void
|
let approveRequest: (EnginePeer) -> Void
|
||||||
@ -111,7 +110,7 @@ final class InviteRequestsSearchItem: ItemListControllerSearch {
|
|||||||
private var activity: ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
|
private var activity: ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
|
||||||
private let activityDisposable = MetaDisposable()
|
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.context = context
|
||||||
self.peerId = peerId
|
self.peerId = peerId
|
||||||
self.cancel = cancel
|
self.cancel = cancel
|
||||||
@ -175,7 +174,7 @@ final class InviteRequestsSearchItem: ItemListControllerSearch {
|
|||||||
private final class InviteRequestsSearchItemNode: ItemListControllerSearchNode {
|
private final class InviteRequestsSearchItemNode: ItemListControllerSearchNode {
|
||||||
private let containerNode: InviteRequestsSearchContainerNode
|
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
|
self.containerNode = InviteRequestsSearchContainerNode(context: context, forceTheme: nil, peerId: peerId, openPeer: { peer in
|
||||||
openPeer(peer)
|
openPeer(peer)
|
||||||
}, approveRequest: { peer in
|
}, approveRequest: { peer in
|
||||||
@ -340,14 +339,14 @@ public final class InviteRequestsSearchContainerNode: SearchDisplayControllerCon
|
|||||||
return _hasDim
|
return _hasDim
|
||||||
}
|
}
|
||||||
|
|
||||||
private var processedPeerIdsPromise = ValuePromise<Set<PeerId>>(Set())
|
private var processedPeerIdsPromise = ValuePromise<Set<EnginePeer.Id>>(Set())
|
||||||
private var processedPeerIds = Set<PeerId>() {
|
private var processedPeerIds = Set<EnginePeer.Id>() {
|
||||||
didSet {
|
didSet {
|
||||||
self.processedPeerIdsPromise.set(self.processedPeerIds)
|
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.context = context
|
||||||
self.openPeer = openPeer
|
self.openPeer = openPeer
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
import PersistentStringHash
|
import PersistentStringHash
|
||||||
@ -33,7 +32,7 @@ public final class CachedGeocode: Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func cachedGeocode(engine: TelegramEngine, address: DeviceContactAddressData) -> Signal<CachedGeocode?, NoError> {
|
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))
|
key.setInt64(0, value: Int64(bitPattern: address.string.persistentHashValue))
|
||||||
|
|
||||||
return engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: ApplicationSpecificItemCacheCollectionId.cachedGeocodes, id: key))
|
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> {
|
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))
|
key.setInt64(0, value: Int64(bitPattern: address.string.persistentHashValue))
|
||||||
|
|
||||||
return engine.itemCache.put(collectionId: ApplicationSpecificItemCacheCollectionId.cachedGeocodes, id: key, item: CachedGeocode(latitude: latitude, longitude: longitude))
|
return engine.itemCache.put(collectionId: ApplicationSpecificItemCacheCollectionId.cachedGeocodes, id: key, item: CachedGeocode(latitude: latitude, longitude: longitude))
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import MapKit
|
import MapKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import AvatarNode
|
import AvatarNode
|
||||||
import AppBundle
|
import AppBundle
|
||||||
@ -39,8 +38,8 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let location: TelegramMediaMap?
|
let location: TelegramMediaMap?
|
||||||
let peer: Peer?
|
let peer: EnginePeer?
|
||||||
let message: Message?
|
let message: EngineMessage?
|
||||||
let forcedSelection: Bool
|
let forcedSelection: Bool
|
||||||
@objc dynamic var heading: NSNumber? {
|
@objc dynamic var heading: NSNumber? {
|
||||||
willSet {
|
willSet {
|
||||||
@ -52,11 +51,11 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isSelf = false
|
var isSelf = false
|
||||||
var selfPeer: Peer?
|
var selfPeer: EnginePeer?
|
||||||
var title: String? = ""
|
var title: String? = ""
|
||||||
var subtitle: String? = ""
|
var subtitle: String? = ""
|
||||||
|
|
||||||
init(context: AccountContext, theme: PresentationTheme, peer: Peer) {
|
init(context: AccountContext, theme: PresentationTheme, peer: EnginePeer) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.location = nil
|
self.location = nil
|
||||||
@ -78,7 +77,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
|||||||
super.init()
|
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.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.location = nil
|
self.location = nil
|
||||||
@ -538,8 +537,8 @@ class LocationPinAnnotationView: MKAnnotationView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousPeerId: PeerId?
|
var previousPeerId: EnginePeer.Id?
|
||||||
func setPeer(context: AccountContext, theme: PresentationTheme, peer: Peer) {
|
func setPeer(context: AccountContext, theme: PresentationTheme, peer: EnginePeer) {
|
||||||
let avatarNode: AvatarNode
|
let avatarNode: AvatarNode
|
||||||
if let currentAvatarNode = self.avatarNode {
|
if let currentAvatarNode = self.avatarNode {
|
||||||
avatarNode = currentAvatarNode
|
avatarNode = currentAvatarNode
|
||||||
@ -554,7 +553,7 @@ class LocationPinAnnotationView: MKAnnotationView {
|
|||||||
|
|
||||||
if self.previousPeerId != peer.id {
|
if self.previousPeerId != peer.id {
|
||||||
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 Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Postbox
|
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
@ -21,7 +20,7 @@ final class LocationLiveListItem: ListViewItem {
|
|||||||
let dateTimeFormat: PresentationDateTimeFormat
|
let dateTimeFormat: PresentationDateTimeFormat
|
||||||
let nameDisplayOrder: PresentationPersonNameOrder
|
let nameDisplayOrder: PresentationPersonNameOrder
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let message: Message
|
let message: EngineMessage
|
||||||
let distance: Double?
|
let distance: Double?
|
||||||
|
|
||||||
let drivingTime: ExpectedTravelTime
|
let drivingTime: ExpectedTravelTime
|
||||||
@ -35,7 +34,7 @@ final class LocationLiveListItem: ListViewItem {
|
|||||||
let transitAction: () -> Void
|
let transitAction: () -> Void
|
||||||
let walkingAction: () -> 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.presentationData = presentationData
|
||||||
self.dateTimeFormat = dateTimeFormat
|
self.dateTimeFormat = dateTimeFormat
|
||||||
self.nameDisplayOrder = nameDisplayOrder
|
self.nameDisplayOrder = nameDisplayOrder
|
||||||
@ -179,7 +178,7 @@ final class LocationLiveListItemNode: ListViewItemNode {
|
|||||||
|
|
||||||
var title: String = ""
|
var title: String = ""
|
||||||
if let author = item.message.author {
|
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 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()))
|
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
|
let avatarSize: CGFloat = 40.0
|
||||||
|
|
||||||
if let peer = item.message.author {
|
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))
|
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 UIKit
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import SegmentedControlNode
|
import SegmentedControlNode
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import AccountContext
|
import AccountContext
|
||||||
@ -14,7 +13,7 @@ import DeviceAccess
|
|||||||
import AttachmentUI
|
import AttachmentUI
|
||||||
|
|
||||||
public enum LocationPickerMode {
|
public enum LocationPickerMode {
|
||||||
case share(peer: Peer?, selfPeer: Peer?, hasLiveLocation: Bool)
|
case share(peer: EnginePeer?, selfPeer: EnginePeer?, hasLiveLocation: Bool)
|
||||||
case pick
|
case pick
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +132,8 @@ public final class LocationPickerController: ViewController, AttachmentContainab
|
|||||||
}
|
}
|
||||||
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
|
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||||
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
|
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
|
||||||
if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer as? TelegramUser {
|
if case let .share(peer, _, _) = strongSelf.mode, let peer = peer, case .user = peer {
|
||||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(EnginePeer(receiver).compactDisplayTitle).string
|
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(peer.compactDisplayTitle).string
|
||||||
}
|
}
|
||||||
controller.setItemGroups([
|
controller.setItemGroups([
|
||||||
ActionSheetItemGroup(items: [
|
ActionSheetItemGroup(items: [
|
||||||
|
@ -4,7 +4,6 @@ import AsyncDisplayKit
|
|||||||
import Display
|
import Display
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import ItemListUI
|
import ItemListUI
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
|
@ -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 SearchBarNode
|
import SearchBarNode
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
@ -19,12 +18,12 @@ import MapKit
|
|||||||
|
|
||||||
public class LocationViewParams {
|
public class LocationViewParams {
|
||||||
let sendLiveLocation: (TelegramMediaMap) -> Void
|
let sendLiveLocation: (TelegramMediaMap) -> Void
|
||||||
let stopLiveLocation: (MessageId?) -> Void
|
let stopLiveLocation: (EngineMessage.Id?) -> Void
|
||||||
let openUrl: (String) -> Void
|
let openUrl: (String) -> Void
|
||||||
let openPeer: (Peer) -> Void
|
let openPeer: (EnginePeer) -> Void
|
||||||
let showAll: Bool
|
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.sendLiveLocation = sendLiveLocation
|
||||||
self.stopLiveLocation = stopLiveLocation
|
self.stopLiveLocation = stopLiveLocation
|
||||||
self.openUrl = openUrl
|
self.openUrl = openUrl
|
||||||
@ -46,14 +45,14 @@ class LocationViewInteraction {
|
|||||||
let goToCoordinate: (CLLocationCoordinate2D) -> Void
|
let goToCoordinate: (CLLocationCoordinate2D) -> Void
|
||||||
let requestDirections: (TelegramMediaMap, String?, OpenInLocationDirections) -> Void
|
let requestDirections: (TelegramMediaMap, String?, OpenInLocationDirections) -> Void
|
||||||
let share: () -> Void
|
let share: () -> Void
|
||||||
let setupProximityNotification: (Bool, MessageId?) -> Void
|
let setupProximityNotification: (Bool, EngineMessage.Id?) -> Void
|
||||||
let updateSendActionHighlight: (Bool) -> Void
|
let updateSendActionHighlight: (Bool) -> Void
|
||||||
let sendLiveLocation: (Int32?) -> Void
|
let sendLiveLocation: (Int32?) -> Void
|
||||||
let stopLiveLocation: () -> Void
|
let stopLiveLocation: () -> Void
|
||||||
let updateRightBarButton: (LocationViewRightBarButton) -> Void
|
let updateRightBarButton: (LocationViewRightBarButton) -> Void
|
||||||
let present: (ViewController) -> 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.toggleMapModeSelection = toggleMapModeSelection
|
||||||
self.updateMapMode = updateMapMode
|
self.updateMapMode = updateMapMode
|
||||||
self.toggleTrackingMode = toggleTrackingMode
|
self.toggleTrackingMode = toggleTrackingMode
|
||||||
@ -74,7 +73,7 @@ public final class LocationViewController: ViewController {
|
|||||||
return self.displayNode as! LocationViewControllerNode
|
return self.displayNode as! LocationViewControllerNode
|
||||||
}
|
}
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
public var subject: Message
|
public var subject: EngineMessage
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
private var showAll: Bool
|
private var showAll: Bool
|
||||||
@ -86,7 +85,7 @@ public final class LocationViewController: ViewController {
|
|||||||
|
|
||||||
private var rightBarButtonAction: LocationViewRightBarButton = .none
|
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.context = context
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
self.showAll = params.showAll
|
self.showAll = params.showAll
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import ItemListUI
|
import ItemListUI
|
||||||
@ -19,11 +18,11 @@ import Geocoding
|
|||||||
import DeviceAccess
|
import DeviceAccess
|
||||||
import TooltipUI
|
import TooltipUI
|
||||||
|
|
||||||
func getLocation(from message: Message) -> TelegramMediaMap? {
|
func getLocation(from message: EngineMessage) -> TelegramMediaMap? {
|
||||||
return message.media.first(where: { $0 is TelegramMediaMap } ) as? 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 {
|
if lhsMessage.stableVersion != rhsMessage.stableVersion {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ private enum LocationViewEntryId: Hashable {
|
|||||||
private enum LocationViewEntry: Comparable, Identifiable {
|
private enum LocationViewEntry: Comparable, Identifiable {
|
||||||
case info(PresentationTheme, TelegramMediaMap, String?, Double?, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime)
|
case info(PresentationTheme, TelegramMediaMap, String?, Double?, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime)
|
||||||
case toggleLiveLocation(PresentationTheme, String, String, Double?, Double?)
|
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 {
|
var stableId: LocationViewEntryId {
|
||||||
switch self {
|
switch self {
|
||||||
@ -155,7 +154,7 @@ private enum LocationViewEntry: Comparable, Identifiable {
|
|||||||
case let .liveLocation(_, dateTimeFormat, nameDisplayOrder, message, distance, drivingTime, transitTime, walkingTime, _):
|
case let .liveLocation(_, dateTimeFormat, nameDisplayOrder, message, distance, drivingTime, transitTime, walkingTime, _):
|
||||||
var title: String?
|
var title: String?
|
||||||
if let author = message.author {
|
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: {
|
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) {
|
if let location = getLocation(from: message) {
|
||||||
@ -217,7 +216,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
private let presentationDataPromise: Promise<PresentationData>
|
private let presentationDataPromise: Promise<PresentationData>
|
||||||
private var subject: Message
|
private var subject: EngineMessage
|
||||||
private let interaction: LocationViewInteraction
|
private let interaction: LocationViewInteraction
|
||||||
private let locationManager: LocationManager
|
private let locationManager: LocationManager
|
||||||
|
|
||||||
@ -247,7 +246,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
}
|
}
|
||||||
private let travelTimesPromise = Promise<[EngineMessage.Id: (Double, ExpectedTravelTime, ExpectedTravelTime, ExpectedTravelTime)]>([:])
|
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.context = context
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
self.presentationDataPromise = Promise(presentationData)
|
self.presentationDataPromise = Promise(presentationData)
|
||||||
@ -321,15 +320,15 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
}
|
}
|
||||||
|
|
||||||
let liveLocations = context.engine.messages.topPeerActiveLiveLocationMessages(peerId: subject.id.peerId)
|
let liveLocations = context.engine.messages.topPeerActiveLiveLocationMessages(peerId: subject.id.peerId)
|
||||||
|> map { _, messages -> [Message] in
|
|> map { _, messages -> [EngineMessage] in
|
||||||
return messages
|
return messages.map(EngineMessage.init)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupProximityNotificationImpl = { reset in
|
setupProximityNotificationImpl = { reset in
|
||||||
let _ = (liveLocations
|
let _ = (liveLocations
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { messages in
|
|> deliverOnMainQueue).start(next: { messages in
|
||||||
var ownMessageId: MessageId?
|
var ownMessageId: EngineMessage.Id?
|
||||||
for message in messages {
|
for message in messages {
|
||||||
if message.localTags.contains(.OutgoingLiveLocation) {
|
if message.localTags.contains(.OutgoingLiveLocation) {
|
||||||
ownMessageId = message.id
|
ownMessageId = message.id
|
||||||
@ -356,7 +355,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
var entries: [LocationViewEntry] = []
|
var entries: [LocationViewEntry] = []
|
||||||
var annotations: [LocationPinAnnotation] = []
|
var annotations: [LocationPinAnnotation] = []
|
||||||
var userAnnotation: LocationPinAnnotation? = nil
|
var userAnnotation: LocationPinAnnotation? = nil
|
||||||
var effectiveLiveLocations: [Message] = liveLocations
|
var effectiveLiveLocations: [EngineMessage] = liveLocations
|
||||||
|
|
||||||
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
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))
|
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, location: location, forcedSelection: true))
|
||||||
} else {
|
} else {
|
||||||
var activeOwnLiveLocation: Message?
|
var activeOwnLiveLocation: EngineMessage?
|
||||||
for message in effectiveLiveLocations {
|
for message in effectiveLiveLocations {
|
||||||
if message.localTags.contains(.OutgoingLiveLocation) {
|
if message.localTags.contains(.OutgoingLiveLocation) {
|
||||||
activeOwnLiveLocation = message
|
activeOwnLiveLocation = message
|
||||||
@ -417,14 +416,14 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
timeout = nil
|
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 {
|
} else {
|
||||||
entries.append(.toggleLiveLocation(presentationData.theme, title, subtitle, beginTime, timeout))
|
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 {
|
for message in effectiveLiveLocations {
|
||||||
if message.id == subject.id {
|
if message.id == subject.id {
|
||||||
effectiveSubject = message
|
effectiveSubject = message
|
||||||
@ -460,7 +459,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
|
|
||||||
let timestamp = CACurrentMediaTime()
|
let timestamp = CACurrentMediaTime()
|
||||||
if message.localTags.contains(.OutgoingLiveLocation), let selfPeer = selfPeer {
|
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 {
|
} else {
|
||||||
var drivingTime: ExpectedTravelTime = .unknown
|
var drivingTime: ExpectedTravelTime = .unknown
|
||||||
var transitTime: 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))
|
entries.append(.liveLocation(presentationData.theme, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, message, distance, drivingTime, transitTime, walkingTime, index))
|
||||||
}
|
}
|
||||||
index += 1
|
index += 1
|
||||||
@ -533,7 +532,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
if subject.id.peerId.namespace != Namespaces.Peer.CloudUser, proximityNotification == nil {
|
if subject.id.peerId.namespace != Namespaces.Peer.CloudUser, proximityNotification == nil {
|
||||||
proximityNotification = false
|
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
|
proximityNotification = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import UIKit
|
|||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
@ -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 ItemListUI
|
import ItemListUI
|
||||||
@ -106,7 +105,7 @@ private struct PeerAutoremoveSetupState: Equatable {
|
|||||||
var applyingSetting: Bool = false
|
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] = []
|
var entries: [PeerAutoremoveSetupEntry] = []
|
||||||
|
|
||||||
let resolvedValue: Int32
|
let resolvedValue: Int32
|
||||||
@ -127,7 +126,7 @@ private func peerAutoremoveSetupEntries(peer: Peer?, presentationData: Presentat
|
|||||||
availableValues[2] = 5 * 60
|
availableValues[2] = 5 * 60
|
||||||
}
|
}
|
||||||
entries.append(.timeValue(resolvedValue, availableValues))
|
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))
|
entries.append(.timeComment(presentationData.strings.AutoremoveSetup_TimerInfoChannel))
|
||||||
} else {
|
} else {
|
||||||
entries.append(.timeComment(presentationData.strings.AutoremoveSetup_TimerInfoChat))
|
entries.append(.timeComment(presentationData.strings.AutoremoveSetup_TimerInfoChat))
|
||||||
@ -145,7 +144,7 @@ public enum PeerAutoremoveSetupScreenResult {
|
|||||||
case updated(Updated)
|
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 statePromise = ValuePromise(PeerAutoremoveSetupState(), ignoreRepeated: true)
|
||||||
let stateValue = Atomic(value: PeerAutoremoveSetupState())
|
let stateValue = Atomic(value: PeerAutoremoveSetupState())
|
||||||
let updateState: ((PeerAutoremoveSetupState) -> PeerAutoremoveSetupState) -> Void = { f in
|
let updateState: ((PeerAutoremoveSetupState) -> PeerAutoremoveSetupState) -> Void = { f in
|
||||||
@ -240,7 +239,7 @@ public func peerAutoremoveSetupScreen(context: AccountContext, updatedPresentati
|
|||||||
let isDebug = context.account.testingEnvironment
|
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 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))
|
return (controllerState, (listState, arguments))
|
||||||
}
|
}
|
||||||
|
@ -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 ItemListUI
|
import ItemListUI
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import Display
|
import Display
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
@ -6,6 +6,8 @@ public protocol AccountManagerTypes {
|
|||||||
associatedtype Attribute: AccountRecordAttribute
|
associatedtype Attribute: AccountRecordAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public typealias SharedPreferencesEntry = PreferencesEntry
|
||||||
|
|
||||||
public struct AccountManagerModifier<Types: AccountManagerTypes> {
|
public struct AccountManagerModifier<Types: AccountManagerTypes> {
|
||||||
public let getRecords: () -> [AccountRecord<Types.Attribute>]
|
public let getRecords: () -> [AccountRecord<Types.Attribute>]
|
||||||
public let updateRecord: (AccountRecordId, (AccountRecord<Types.Attribute>?) -> (AccountRecord<Types.Attribute>?)) -> Void
|
public let updateRecord: (AccountRecordId, (AccountRecord<Types.Attribute>?) -> (AccountRecord<Types.Attribute>?)) -> Void
|
||||||
|
@ -13249,7 +13249,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let hasLiveLocation = peer.id.namespace != Namespaces.Peer.SecretChat && peer.id != strongSelf.context.account.peerId && strongSelf.presentationInterfaceState.subject != .scheduledMessages
|
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 {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -14239,7 +14239,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let hasLiveLocation = peer.id.namespace != Namespaces.Peer.SecretChat && peer.id != strongSelf.context.account.peerId && strongSelf.presentationInterfaceState.subject != .scheduledMessages
|
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 {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -71,9 +71,9 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
|||||||
}, stopLiveLocation: { messageId in
|
}, stopLiveLocation: { messageId in
|
||||||
params.context.liveLocationManager?.cancelLiveLocation(peerId: messageId?.peerId ?? params.message.id.peerId)
|
params.context.liveLocationManager?.cancelLiveLocation(peerId: messageId?.peerId ?? params.message.id.peerId)
|
||||||
}, openUrl: params.openUrl, openPeer: { peer in
|
}, openUrl: params.openUrl, openPeer: { peer in
|
||||||
params.openPeer(peer, .info)
|
params.openPeer(peer._asPeer(), .info)
|
||||||
}, showAll: params.modal)
|
}, 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
|
controller.navigationPresentation = .modal
|
||||||
params.navigationController?.pushViewController(controller)
|
params.navigationController?.pushViewController(controller)
|
||||||
return true
|
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 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)
|
self.controller?.push(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,7 +1360,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
guard let message = message else {
|
guard let message = message else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let controller = LocationViewController(context: context, subject: message._asMessage(), params: controllerParams)
|
let controller = LocationViewController(context: context, subject: message, params: controllerParams)
|
||||||
controller.navigationPresentation = .modal
|
controller.navigationPresentation = .modal
|
||||||
navigationController.pushViewController(controller)
|
navigationController.pushViewController(controller)
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
|
||||||
|
|
||||||
public struct CallListSettings: Codable, Equatable {
|
public struct CallListSettings: Codable, Equatable {
|
||||||
public var _showTab: Bool?
|
public var _showTab: Bool?
|
||||||
@ -78,7 +77,7 @@ public func updateCallListSettingsInteractively(accountManager: AccountManager<T
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = CallListSettings.defaultSettings
|
currentSettings = CallListSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import Postbox
|
|
||||||
|
|
||||||
public struct ChatArchiveSettings: Equatable, Codable {
|
public struct ChatArchiveSettings: Equatable, Codable {
|
||||||
public var isHiddenByDefault: Bool
|
public var isHiddenByDefault: Bool
|
||||||
@ -43,6 +42,6 @@ public func updateChatArchiveSettings(engine: TelegramEngine, _ f: @escaping (Ch
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = .default
|
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 Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ public func updateExperimentalSettingsInteractively(accountManager: AccountManag
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = ExperimentalSettings.defaultSettings
|
currentSettings = ExperimentalSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -7,10 +6,10 @@ public struct ExperimentalUISettings: Codable, Equatable {
|
|||||||
public struct AccountReactionOverrides: Equatable, Codable {
|
public struct AccountReactionOverrides: Equatable, Codable {
|
||||||
public struct Item: Equatable, Codable {
|
public struct Item: Equatable, Codable {
|
||||||
public var key: MessageReaction.Reaction
|
public var key: MessageReaction.Reaction
|
||||||
public var messageId: MessageId
|
public var messageId: EngineMessage.Id
|
||||||
public var mediaId: MediaId
|
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.key = key
|
||||||
self.messageId = messageId
|
self.messageId = messageId
|
||||||
self.mediaId = mediaId
|
self.mediaId = mediaId
|
||||||
@ -206,7 +205,7 @@ public func updateExperimentalUISettingsInteractively(accountManager: AccountMan
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = .defaultSettings
|
currentSettings = .defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ public func updateGeneratedMediaStoreSettingsInteractively(accountManager: Accou
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = GeneratedMediaStoreSettings.defaultSettings
|
currentSettings = GeneratedMediaStoreSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
public struct IntentsSettings: Codable, Equatable {
|
public struct IntentsSettings: Codable, Equatable {
|
||||||
public let initiallyReset: Bool
|
public let initiallyReset: Bool
|
||||||
|
|
||||||
public let account: PeerId?
|
public let account: EnginePeer.Id?
|
||||||
public let contacts: Bool
|
public let contacts: Bool
|
||||||
public let privateChats: Bool
|
public let privateChats: Bool
|
||||||
public let savedMessages: 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)
|
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.initiallyReset = initiallyReset
|
||||||
self.account = account
|
self.account = account
|
||||||
self.contacts = contacts
|
self.contacts = contacts
|
||||||
@ -31,7 +30,7 @@ public struct IntentsSettings: Codable, Equatable {
|
|||||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||||
|
|
||||||
self.initiallyReset = try container.decodeIfPresent(Bool.self, forKey: "initiallyReset_v2") ?? false
|
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.contacts = try container.decodeIfPresent(Bool.self, forKey: "contacts") ?? true
|
||||||
self.privateChats = try container.decodeIfPresent(Bool.self, forKey: "privateChats") ?? false
|
self.privateChats = try container.decodeIfPresent(Bool.self, forKey: "privateChats") ?? false
|
||||||
self.savedMessages = try container.decodeIfPresent(Bool.self, forKey: "savedMessages") ?? true
|
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
|
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)
|
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
|
previousSettings = currentSettings
|
||||||
updatedSettings = f(currentSettings)
|
updatedSettings = f(currentSettings)
|
||||||
return PreferencesEntry(updatedSettings)
|
return SharedPreferencesEntry(updatedSettings)
|
||||||
})
|
})
|
||||||
return (previousSettings, updatedSettings)
|
return (previousSettings, updatedSettings)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ public func updateMediaDisplaySettingsInteractively(accountManager: AccountManag
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = MediaDisplaySettings.defaultSettings
|
currentSettings = MediaDisplaySettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -52,7 +51,7 @@ public func updateMediaInputSettingsInteractively(accountManager: AccountManager
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = MediaInputSettings.defaultSettings
|
currentSettings = MediaInputSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -150,7 +149,7 @@ public func updateMusicPlaybackSettingsInteractively(accountManager: AccountMana
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = MusicPlaybackSettings.defaultSettings
|
currentSettings = MusicPlaybackSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -73,6 +72,6 @@ public func updatePresentationPasscodeSettingsInternal(transaction: AccountManag
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = PresentationPasscodeSettings.defaultSettings
|
currentSettings = PresentationPasscodeSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ public func updateStickerSettingsInteractively(accountManager: AccountManager<Te
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = StickerSettings.defaultSettings
|
currentSettings = StickerSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ public func updateTranslationSettingsInteractively(accountManager: AccountManage
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = TranslationSettings.defaultSettings
|
currentSettings = TranslationSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Postbox
|
|
||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ public func updateVoiceCallSettingsSettingsInteractively(accountManager: Account
|
|||||||
} else {
|
} else {
|
||||||
currentSettings = VoiceCallSettings.defaultSettings
|
currentSettings = VoiceCallSettings.defaultSettings
|
||||||
}
|
}
|
||||||
return PreferencesEntry(f(currentSettings))
|
return SharedPreferencesEntry(f(currentSettings))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user