mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge branch 'beta'
This commit is contained in:
commit
fdef697932
@ -90,8 +90,8 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
|
||||
let buttonText: String
|
||||
|
||||
let badgeFont = Font.with(size: 14.0, design: .round, traits: [.bold])
|
||||
let textFont = Font.regular(18.0)
|
||||
let badgeFont = Font.with(size: 13.0, design: .round, traits: [.bold])
|
||||
let textFont = Font.regular(16.0)
|
||||
let textColor = self.presentationData.theme.list.itemPrimaryTextColor
|
||||
|
||||
var badgeBackgroundNodes: [ASImageNode] = []
|
||||
@ -147,7 +147,7 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
self.titleNode.displaysAsynchronously = false
|
||||
self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_AddDeviceIntro_Title, font: Font.bold(28.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
self.titleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_AddDeviceIntro_Title, font: Font.bold(24.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||
self.titleNode.maximumNumberOfLines = 0
|
||||
self.titleNode.textAlignment = .center
|
||||
|
||||
@ -198,14 +198,14 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
|
||||
let sideInset: CGFloat = 22.0
|
||||
let textSideInset: CGFloat = 54.0
|
||||
let buttonSideInset: CGFloat = 48.0
|
||||
let titleSpacing: CGFloat = 30.0
|
||||
let buttonSideInset: CGFloat = 16.0
|
||||
let titleSpacing: CGFloat = 25.0
|
||||
let buttonHeight: CGFloat = 50.0
|
||||
let buttonSpacing: CGFloat = 10.0
|
||||
let textSpacing: CGFloat = 26.0
|
||||
let buttonSpacing: CGFloat = 16.0
|
||||
let textSpacing: CGFloat = 25.0
|
||||
let badgeSize: CGFloat = 20.0
|
||||
|
||||
let animationFitSize = CGSize(width: min(500.0, layout.size.width - sideInset), height: 500.0)
|
||||
let animationFitSize = CGSize(width: min(500.0, layout.size.width - sideInset + 20.0), height: 500.0)
|
||||
let animationSize = self.animationNode.preferredSize()?.fitted(animationFitSize) ?? animationFitSize
|
||||
let iconSize: CGSize = animationSize
|
||||
var iconOffset = CGPoint()
|
||||
@ -233,7 +233,7 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
let contentTopInset = navigationHeight
|
||||
let contentBottomInset = bottomInset + buttonHeight + buttonSpacing
|
||||
|
||||
let iconSpacing: CGFloat = max(20.0, min(64.0, layout.size.height - contentTopInset - contentBottomInset - contentHeight - 40.0))
|
||||
let iconSpacing: CGFloat = max(20.0, min(61.0, layout.size.height - contentTopInset - contentBottomInset - contentHeight - 40.0))
|
||||
|
||||
contentHeight += iconSpacing
|
||||
|
||||
@ -269,10 +269,17 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
|
||||
let textFrame = CGRect(origin: CGPoint(x: textSideInset, y: contentY), size: textSize)
|
||||
transition.updateFrameAdditive(node: self.textNodes[i], frame: textFrame)
|
||||
|
||||
let badgeFrame = CGRect(origin: CGPoint(x: sideInset, y: textFrame.minY + floor((textFrame.height - badgeSize) / 2.0)), size: CGSize(width: badgeSize, height: badgeSize))
|
||||
let badgeFrame = CGRect(origin: CGPoint(x: sideInset, y: textFrame.minY), size: CGSize(width: badgeSize, height: badgeSize))
|
||||
transition.updateFrameAdditive(node: self.badgeBackgroundNodes[i], frame: badgeFrame)
|
||||
|
||||
transition.updateFrameAdditive(node: self.badgeTextNodes[i], frame: CGRect(origin: CGPoint(x: badgeFrame.minX + floor((badgeFrame.width - badgeTextSize.width) / 2.0) + 0.5, y: badgeFrame.minY + floor((badgeFrame.height - badgeTextSize.height) / 2.0) + 0.5), size: badgeTextSize))
|
||||
let badgeTextOffsetX: CGFloat
|
||||
if i == 0 {
|
||||
badgeTextOffsetX = 0.5
|
||||
} else {
|
||||
badgeTextOffsetX = 1.0
|
||||
}
|
||||
|
||||
transition.updateFrameAdditive(node: self.badgeTextNodes[i], frame: CGRect(origin: CGPoint(x: badgeFrame.minX + floor((badgeFrame.width - badgeTextSize.width) / 2.0) + badgeTextOffsetX, y: badgeFrame.minY + floor((badgeFrame.height - badgeTextSize.height) / 2.0) + 0.5), size: badgeTextSize))
|
||||
|
||||
contentY += textSize.height
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ private final class AuthTransferScanScreenNode: ViewControllerTracingNode, UIScr
|
||||
self.errorTextNode.attributedText = NSAttributedString(string: presentationData.strings.AuthSessions_AddDevice_InvalidQRCode, font: Font.medium(16.0), textColor: .white)
|
||||
self.errorTextNode.maximumNumberOfLines = 0
|
||||
self.errorTextNode.textAlignment = .center
|
||||
//self.errorTextNode.isHidden = true
|
||||
self.errorTextNode.isHidden = true
|
||||
|
||||
self.camera = Camera(configuration: .init(preset: .hd1920x1080, position: .back, audio: false))
|
||||
|
||||
@ -409,19 +409,28 @@ private final class AuthTransferScanScreenNode: ViewControllerTracingNode, UIScr
|
||||
transition.updateFrame(node: self.centerDimNode, frame: dimRect)
|
||||
|
||||
let buttonSize = CGSize(width: 72.0, height: 72.0)
|
||||
transition.updateFrame(node: self.torchButtonNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - buttonSize.width) / 2.0), y: dimHeight + frameSide + 98.0), size: buttonSize))
|
||||
var torchFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - buttonSize.width) / 2.0), y: dimHeight + frameSide + 98.0), size: buttonSize)
|
||||
let updatedTorchY = min(torchFrame.minY, layout.size.height - torchFrame.height - 10.0)
|
||||
let additionalTorchOffset: CGFloat = updatedTorchY - torchFrame.minY
|
||||
torchFrame.origin.y = updatedTorchY
|
||||
transition.updateFrame(node: self.torchButtonNode, frame: torchFrame)
|
||||
|
||||
transition.updateAlpha(node: self.titleNode, alpha: controlsAlpha)
|
||||
transition.updateAlpha(node: self.textNode, alpha: controlsAlpha)
|
||||
transition.updateAlpha(node: self.errorTextNode, alpha: controlsAlpha)
|
||||
transition.updateAlpha(node: self.torchButtonNode, alpha: controlsAlpha)
|
||||
|
||||
let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width - sideInset * 2.0, height: layout.size.height))
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: layout.size.width - sideInset * 2.0, height: layout.size.height))
|
||||
let errorTextSize = self.errorTextNode.updateLayout(CGSize(width: layout.size.width - sideInset * 2.0, height: layout.size.height))
|
||||
let titleSize = self.titleNode.updateLayout(CGSize(width: layout.size.width - 16.0, height: layout.size.height))
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: layout.size.width - 16.0, height: layout.size.height))
|
||||
let errorTextSize = self.errorTextNode.updateLayout(CGSize(width: layout.size.width - 16.0, height: layout.size.height))
|
||||
let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: dimHeight - textSize.height - titleSpacing), size: textSize)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - titleSize.width) / 2.0), y: textFrame.minY - 18.0 - titleSize.height), size: titleSize)
|
||||
let errorTextFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - errorTextSize.width) / 2.0), y: dimHeight + frameSide + 48.0), size: errorTextSize)
|
||||
var errorTextFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - errorTextSize.width) / 2.0), y: dimHeight + frameSide + 48.0), size: errorTextSize)
|
||||
errorTextFrame.origin.y += floor(additionalTorchOffset / 2.0)
|
||||
if titleFrame.minY < navigationHeight {
|
||||
transition.updateAlpha(node: self.titleNode, alpha: 0.0)
|
||||
} else {
|
||||
transition.updateAlpha(node: self.titleNode, alpha: controlsAlpha)
|
||||
}
|
||||
transition.updateFrameAdditive(node: self.titleNode, frame: titleFrame)
|
||||
transition.updateFrameAdditive(node: self.textNode, frame: textFrame)
|
||||
transition.updateFrameAdditive(node: self.errorTextNode, frame: errorTextFrame)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,13 @@ public struct HolesViewMedia: Comparable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct MessageOfInterestHole: Hashable, Equatable {
|
||||
public struct MessageOfInterestHole: Hashable, Equatable, CustomStringConvertible {
|
||||
public let hole: MessageHistoryViewHole
|
||||
public let direction: MessageHistoryViewRelativeHoleDirection
|
||||
|
||||
public var description: String {
|
||||
return "hole: \(self.hole), direction: \(self.direction)"
|
||||
}
|
||||
}
|
||||
|
||||
public enum MessageOfInterestViewLocation: Hashable {
|
||||
@ -29,6 +33,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
|
||||
private let count: Int
|
||||
private var anchor: HistoryViewInputAnchor
|
||||
private var wrappedView: MutableMessageHistoryView
|
||||
private var peerIds: MessageHistoryViewPeerIds
|
||||
|
||||
fileprivate var closestHole: MessageOfInterestHole?
|
||||
fileprivate var closestLaterMedia: [HolesViewMedia] = []
|
||||
@ -44,6 +49,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
|
||||
mainPeerId = id
|
||||
peerIds = postbox.peerIdsForLocation(.peer(id), tagMask: nil)
|
||||
}
|
||||
self.peerIds = peerIds
|
||||
var anchor: HistoryViewInputAnchor = .upperBound
|
||||
if let combinedState = postbox.readStateTable.getCombinedState(mainPeerId), let state = combinedState.states.first, state.1.count != 0 {
|
||||
switch state.1 {
|
||||
@ -107,7 +113,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
|
||||
}
|
||||
var anchor: HistoryViewInputAnchor = self.anchor
|
||||
if transaction.alteredInitialPeerCombinedReadStates[peerId] != nil {
|
||||
var anchor: HistoryViewInputAnchor = .upperBound
|
||||
var updatedAnchor: HistoryViewInputAnchor = .upperBound
|
||||
if let combinedState = postbox.readStateTable.getCombinedState(peerId), let state = combinedState.states.first, state.1.count != 0 {
|
||||
switch state.1 {
|
||||
case let .idBased(maxIncomingReadId, _, _, _, _):
|
||||
@ -116,6 +122,7 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
|
||||
anchor = .index(maxIncomingReadIndex)
|
||||
}
|
||||
}
|
||||
anchor = updatedAnchor
|
||||
}
|
||||
|
||||
if self.anchor != anchor {
|
||||
@ -128,6 +135,34 @@ final class MutableMessageOfInterestHolesView: MutablePostboxView {
|
||||
self.wrappedView = MutableMessageHistoryView(postbox: postbox, orderStatistics: [], peerIds: peerIds, anchor: self.anchor, combinedReadStates: nil, transientReadStates: nil, tag: nil, namespaces: .all, count: self.count, topTaggedMessages: [:], additionalDatas: [], getMessageCountInRange: { _, _ in return 0})
|
||||
return self.updateFromView()
|
||||
} else if self.wrappedView.replay(postbox: postbox, transaction: transaction) {
|
||||
var reloadView = false
|
||||
if !transaction.currentPeerHoleOperations.isEmpty {
|
||||
var allPeerIds: [PeerId]
|
||||
switch peerIds {
|
||||
case let .single(peerId):
|
||||
allPeerIds = [peerId]
|
||||
case let .associated(peerId, attachedMessageId):
|
||||
allPeerIds = [peerId]
|
||||
if let attachedMessageId = attachedMessageId {
|
||||
allPeerIds.append(attachedMessageId.peerId)
|
||||
}
|
||||
}
|
||||
for (key, _) in transaction.currentPeerHoleOperations {
|
||||
if allPeerIds.contains(key.peerId) {
|
||||
reloadView = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if reloadView {
|
||||
let peerIds: MessageHistoryViewPeerIds
|
||||
switch self.location {
|
||||
case let .peer(id):
|
||||
peerIds = postbox.peerIdsForLocation(.peer(id), tagMask: nil)
|
||||
}
|
||||
self.wrappedView = MutableMessageHistoryView(postbox: postbox, orderStatistics: [], peerIds: peerIds, anchor: self.anchor, combinedReadStates: nil, transientReadStates: nil, tag: nil, namespaces: .all, count: self.count, topTaggedMessages: [:], additionalDatas: [], getMessageCountInRange: { _, _ in return 0})
|
||||
}
|
||||
|
||||
return self.updateFromView()
|
||||
} else {
|
||||
return false
|
||||
|
@ -671,7 +671,7 @@ private func settingsEntries(account: Account, presentationData: PresentationDat
|
||||
entries.append(.savedMessages(presentationData.theme, PresentationResourcesSettings.savedMessages, presentationData.strings.Settings_SavedMessages))
|
||||
entries.append(.recentCalls(presentationData.theme, PresentationResourcesSettings.recentCalls, presentationData.strings.CallSettings_RecentCalls))
|
||||
if enableQRLogin {
|
||||
entries.append(.devices(presentationData.theme, UIImage(bundleImageName: "Settings/MenuIcons/Sessions")?.precomposed(), presentationData.strings.Settings_Devices, otherSessionCount == 0 ? presentationData.strings.Settings_AddDevice : "\(otherSessionCount)"))
|
||||
entries.append(.devices(presentationData.theme, UIImage(bundleImageName: "Settings/MenuIcons/Sessions")?.precomposed(), presentationData.strings.Settings_Devices, otherSessionCount == 0 ? presentationData.strings.Settings_AddDevice : "\(otherSessionCount + 1)"))
|
||||
} else {
|
||||
entries.append(.stickers(presentationData.theme, PresentationResourcesSettings.stickers, presentationData.strings.ChatSettings_Stickers, unreadTrendingStickerPacks == 0 ? "" : "\(unreadTrendingStickerPacks)", archivedPacks))
|
||||
}
|
||||
|
@ -1761,7 +1761,13 @@ private func resetChannels(network: Network, peers: [Peer], state: AccountMutabl
|
||||
|
||||
private func pollChannel(network: Network, peer: Peer, state: AccountMutableState) -> Signal<(AccountMutableState, Bool, Int32?), NoError> {
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
let limit: Int32 = 20
|
||||
let limit: Int32
|
||||
#if DEBUG
|
||||
limit = 1
|
||||
#else
|
||||
limit = 20
|
||||
#endif
|
||||
|
||||
let pollPts: Int32
|
||||
if let channelState = state.chatStates[peer.id] as? ChannelState {
|
||||
pollPts = channelState.pts
|
||||
|
@ -4,7 +4,7 @@ import SwiftSignalKit
|
||||
|
||||
import SyncCore
|
||||
|
||||
public struct HistoryPreloadIndex: Comparable {
|
||||
public struct HistoryPreloadIndex: Comparable, CustomStringConvertible {
|
||||
public let index: ChatListIndex?
|
||||
public let hasUnread: Bool
|
||||
public let isMuted: Bool
|
||||
@ -49,9 +49,13 @@ public struct HistoryPreloadIndex: Comparable {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return "index: \(String(describing: self.index)), hasUnread: \(self.hasUnread), isMuted: \(self.isMuted), isPriority: \(self.isPriority)"
|
||||
}
|
||||
}
|
||||
|
||||
private struct HistoryPreloadHole: Hashable, Comparable {
|
||||
private struct HistoryPreloadHole: Hashable, Comparable, CustomStringConvertible {
|
||||
let preloadIndex: HistoryPreloadIndex
|
||||
let hole: MessageOfInterestHole
|
||||
|
||||
@ -66,6 +70,10 @@ private struct HistoryPreloadHole: Hashable, Comparable {
|
||||
var hashValue: Int {
|
||||
return self.preloadIndex.index.hashValue &* 31 &+ self.hole.hashValue
|
||||
}
|
||||
|
||||
var description: String {
|
||||
return "(preloadIndex: \(self.preloadIndex), hole: \(self.hole))"
|
||||
}
|
||||
}
|
||||
|
||||
private final class HistoryPreloadEntry: Comparable {
|
||||
@ -90,6 +98,9 @@ private final class HistoryPreloadEntry: Comparable {
|
||||
self.isStarted = true
|
||||
|
||||
let hole = self.hole.hole
|
||||
|
||||
Logger.shared.log("HistoryPreload", "start hole \(hole)")
|
||||
|
||||
let signal: Signal<Never, NoError> = .complete()
|
||||
|> delay(0.3, queue: queue)
|
||||
|> then(
|
||||
@ -98,8 +109,8 @@ private final class HistoryPreloadEntry: Comparable {
|
||||
|> deliverOn(queue)
|
||||
|> mapToSignal { download -> Signal<Never, NoError> in
|
||||
switch hole.hole {
|
||||
case let .peer(peerHole):
|
||||
return fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .download(download), postbox: postbox, peerId: peerHole.peerId, namespace: peerHole.namespace, direction: hole.direction, space: .everywhere, count: 60)
|
||||
case let .peer(peerHole):
|
||||
return fetchMessageHistoryHole(accountPeerId: accountPeerId, source: .download(download), postbox: postbox, peerId: peerHole.peerId, namespace: peerHole.namespace, direction: hole.direction, space: .everywhere, count: 60)
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -421,6 +432,14 @@ final class ChatHistoryPreloadManager {
|
||||
}
|
||||
|
||||
let updatedHole = view.currentHole
|
||||
|
||||
let holeIsUpdated = previousHole != updatedHole
|
||||
|
||||
switch index.entity {
|
||||
case let .peer(peerId):
|
||||
Logger.shared.log("HistoryPreload", "view \(peerId) hole \(updatedHole) isUpdated: \(holeIsUpdated)")
|
||||
}
|
||||
|
||||
if previousHole != updatedHole {
|
||||
strongSelf.update(from: previousHole, to: updatedHole)
|
||||
}
|
||||
@ -448,7 +467,11 @@ final class ChatHistoryPreloadManager {
|
||||
|
||||
private func update(from previousHole: HistoryPreloadHole?, to updatedHole: HistoryPreloadHole?) {
|
||||
assert(self.queue.isCurrent())
|
||||
if previousHole == updatedHole {
|
||||
let isHoleUpdated = previousHole != updatedHole
|
||||
|
||||
Logger.shared.log("HistoryPreload", "update from \(String(describing: previousHole)) to \(String(describing: updatedHole)), isUpdated: \(isHoleUpdated)")
|
||||
|
||||
if !isHoleUpdated {
|
||||
return
|
||||
}
|
||||
|
||||
@ -482,9 +505,12 @@ final class ChatHistoryPreloadManager {
|
||||
}
|
||||
|
||||
if self.canPreloadHistoryValue {
|
||||
Logger.shared.log("HistoryPreload", "will start")
|
||||
for i in 0 ..< min(3, self.entries.count) {
|
||||
self.entries[i].startIfNeeded(postbox: self.postbox, accountPeerId: self.accountPeerId, download: self.download.get() |> take(1), queue: self.queue)
|
||||
}
|
||||
} else {
|
||||
Logger.shared.log("HistoryPreload", "will not start, canPreloadHistoryValue = false")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user