Skip to content

Commit b484d03

Browse files
author
Isaac
committed
Merge branch 'beta'
2 parents ebdd7b3 + caeef02 commit b484d03

File tree

7 files changed

+134
-58
lines changed

7 files changed

+134
-58
lines changed

submodules/CallListUI/Sources/CallListCallItem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ class CallListCallItemNode: ItemListRevealOptionsItemNode {
412412
} else if case let .conferenceCall(conferenceCall) = action.action {
413413
isConference = true
414414

415-
if let peer = message.author, !conferenceAvatars.contains(where: { $0.id == peer.id }) {
416-
conferenceAvatars.append(peer)
415+
if let peer = message.peers[message.id.peerId], !conferenceAvatars.contains(where: { $0.id == peer.id }) {
416+
conferenceAvatars.append(EnginePeer(peer))
417417
}
418418

419419
for id in conferenceCall.otherParticipants {

submodules/CounterControllerTitleView/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ swift_library(
1313
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
1414
"//submodules/Display:Display",
1515
"//submodules/TelegramPresentationData:TelegramPresentationData",
16+
"//submodules/ComponentFlow",
1617
],
1718
visibility = [
1819
"//visibility:public",

submodules/CounterControllerTitleView/Sources/CounterControllerTitleView.swift

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import UIKit
33
import Display
44
import AsyncDisplayKit
55
import TelegramPresentationData
6+
import ComponentFlow
67

78
public struct CounterControllerTitle: Equatable {
89
public var title: String
@@ -16,24 +17,28 @@ public struct CounterControllerTitle: Equatable {
1617

1718
public final class CounterControllerTitleView: UIView {
1819
private let titleNode: ImmediateTextNode
19-
private let subtitleNode: ImmediateTextNode
20+
21+
private var subtitleNode: ImmediateTextNode
22+
private var disappearingSubtitleNode: ImmediateTextNode?
2023

2124
public var title: CounterControllerTitle = CounterControllerTitle(title: "", counter: nil) {
2225
didSet {
2326
if self.title != oldValue {
24-
self.update()
27+
self.update(animated: oldValue.title.isEmpty == self.title.title.isEmpty)
2528
}
2629
}
2730
}
2831

2932
public var theme: PresentationTheme {
3033
didSet {
31-
self.update()
34+
self.update(animated: false)
3235
}
3336
}
3437

3538
private var primaryTextColor: UIColor?
3639
private var secondaryTextColor: UIColor?
40+
41+
private var nextLayoutTransition: ContainedViewLayoutTransition?
3742

3843
public func updateTextColors(primary: UIColor?, secondary: UIColor?, transition: ContainedViewLayoutTransition) {
3944
self.primaryTextColor = primary
@@ -52,18 +57,40 @@ public final class CounterControllerTitleView: UIView {
5257
}
5358
}
5459

55-
self.update()
60+
self.update(animated: false)
5661
}
5762

58-
private func update() {
63+
private func update(animated: Bool) {
5964
let primaryTextColor = self.primaryTextColor ?? self.theme.rootController.navigationBar.primaryTextColor
6065
let secondaryTextColor = self.secondaryTextColor ?? self.theme.rootController.navigationBar.secondaryTextColor
6166
self.titleNode.attributedText = NSAttributedString(string: self.title.title, font: Font.semibold(17.0), textColor: primaryTextColor)
62-
self.subtitleNode.attributedText = NSAttributedString(string: self.title.counter ?? "", font: Font.with(size: 13.0, traits: .monospacedNumbers), textColor: secondaryTextColor)
67+
68+
let subtitleText = NSAttributedString(string: self.title.counter ?? "", font: Font.with(size: 13.0, traits: .monospacedNumbers), textColor: secondaryTextColor)
69+
if let previousSubtitleText = self.subtitleNode.attributedText, previousSubtitleText.string.isEmpty != subtitleText.string.isEmpty && subtitleText.string.isEmpty {
70+
if let disappearingSubtitleNode = self.disappearingSubtitleNode {
71+
self.disappearingSubtitleNode = nil
72+
disappearingSubtitleNode.removeFromSupernode()
73+
}
74+
75+
self.disappearingSubtitleNode = self.subtitleNode
76+
77+
self.subtitleNode = ImmediateTextNode()
78+
self.subtitleNode.displaysAsynchronously = false
79+
self.subtitleNode.maximumNumberOfLines = 1
80+
self.subtitleNode.truncationType = .end
81+
self.subtitleNode.isOpaque = false
82+
self.subtitleNode.attributedText = subtitleText
83+
self.addSubnode(self.subtitleNode)
84+
} else {
85+
self.subtitleNode.attributedText = subtitleText
86+
}
6387

6488
self.accessibilityLabel = self.title.title
6589
self.accessibilityValue = self.title.counter
6690

91+
if animated {
92+
self.nextLayoutTransition = .animated(duration: 0.4, curve: .spring)
93+
}
6794
self.setNeedsLayout()
6895
}
6996

@@ -110,11 +137,31 @@ public final class CounterControllerTitleView: UIView {
110137
} else {
111138
combinedHeight = titleSize.height
112139
}
140+
141+
var transition: ContainedViewLayoutTransition = .immediate
142+
if let nextLayoutTransition = self.nextLayoutTransition {
143+
if !self.titleNode.bounds.isEmpty {
144+
transition = nextLayoutTransition
145+
}
146+
self.nextLayoutTransition = nil
147+
}
113148

114149
let titleFrame = CGRect(origin: CGPoint(x: floor((size.width - titleSize.width) / 2.0), y: floor((size.height - combinedHeight) / 2.0)), size: titleSize)
115-
self.titleNode.frame = titleFrame
150+
self.titleNode.bounds = CGRect(origin: CGPoint(), size: titleFrame.size)
151+
transition.updatePosition(node: self.titleNode, position: titleFrame.center)
116152

117153
let subtitleFrame = CGRect(origin: CGPoint(x: floor((size.width - subtitleSize.width) / 2.0), y: floor((size.height - combinedHeight) / 2.0) + titleSize.height + spacing), size: subtitleSize)
118-
self.subtitleNode.frame = subtitleFrame
154+
self.subtitleNode.bounds = CGRect(origin: CGPoint(), size: subtitleFrame.size)
155+
transition.updatePosition(node: self.subtitleNode, position: subtitleFrame.center)
156+
transition.updateTransformScale(node: self.subtitleNode, scale: self.title.counter != nil ? 1.0 : 0.001)
157+
transition.updateAlpha(node: self.subtitleNode, alpha: self.title.counter != nil ? 1.0 : 0.0)
158+
159+
if let disappearingSubtitleNode = self.disappearingSubtitleNode {
160+
transition.updatePosition(node: disappearingSubtitleNode, position: subtitleFrame.center)
161+
transition.updateTransformScale(node: disappearingSubtitleNode, scale: self.title.counter != nil ? 1.0 : 0.001)
162+
transition.updateAlpha(node: disappearingSubtitleNode, alpha: self.title.counter != nil ? 1.0 : 0.0, completion: { [weak disappearingSubtitleNode] _ in
163+
disappearingSubtitleNode?.removeFromSupernode()
164+
})
165+
}
119166
}
120167
}

submodules/PeerInfoUI/Sources/ItemListCallListItem.swift

Lines changed: 61 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -65,58 +65,75 @@ private func stringForCallType(message: Message, strings: PresentationStrings) -
6565
var string = ""
6666
for media in message.media {
6767
switch media {
68-
case let action as TelegramMediaAction:
69-
switch action.action {
70-
case let .phoneCall(_, discardReason, _, isVideo):
71-
let incoming = message.flags.contains(.Incoming)
72-
if let discardReason = discardReason {
73-
switch discardReason {
74-
case .disconnect:
75-
if isVideo {
76-
string = strings.Notification_VideoCallCanceled
77-
} else {
78-
string = strings.Notification_CallCanceled
79-
}
80-
case .missed, .busy:
81-
if incoming {
82-
if isVideo {
83-
string = strings.Notification_VideoCallMissed
84-
} else {
85-
string = strings.Notification_CallMissed
86-
}
87-
} else {
88-
if isVideo {
89-
string = strings.Notification_VideoCallCanceled
90-
} else {
91-
string = strings.Notification_CallCanceled
92-
}
93-
}
94-
case .hangup:
95-
break
96-
}
68+
case let action as TelegramMediaAction:
69+
switch action.action {
70+
case let .phoneCall(_, discardReason, _, isVideo):
71+
let incoming = message.flags.contains(.Incoming)
72+
if let discardReason = discardReason {
73+
switch discardReason {
74+
case .disconnect:
75+
if isVideo {
76+
string = strings.Notification_VideoCallCanceled
77+
} else {
78+
string = strings.Notification_CallCanceled
9779
}
98-
99-
if string.isEmpty {
100-
if incoming {
101-
if isVideo {
102-
string = strings.Notification_VideoCallIncoming
103-
} else {
104-
string = strings.Notification_CallIncoming
105-
}
80+
case .missed, .busy:
81+
if incoming {
82+
if isVideo {
83+
string = strings.Notification_VideoCallMissed
84+
} else {
85+
string = strings.Notification_CallMissed
86+
}
87+
} else {
88+
if isVideo {
89+
string = strings.Notification_VideoCallCanceled
10690
} else {
107-
if isVideo {
108-
string = strings.Notification_VideoCallOutgoing
109-
} else {
110-
string = strings.Notification_CallOutgoing
111-
}
91+
string = strings.Notification_CallCanceled
11292
}
11393
}
114-
default:
94+
case .hangup:
11595
break
96+
}
97+
}
98+
99+
if string.isEmpty {
100+
if incoming {
101+
if isVideo {
102+
string = strings.Notification_VideoCallIncoming
103+
} else {
104+
string = strings.Notification_CallIncoming
105+
}
106+
} else {
107+
if isVideo {
108+
string = strings.Notification_VideoCallOutgoing
109+
} else {
110+
string = strings.Notification_CallOutgoing
111+
}
112+
}
113+
}
114+
case let .conferenceCall(conferenceCall):
115+
let incoming = message.flags.contains(.Incoming)
116+
117+
let missedTimeout: Int32 = 30
118+
let currentTime = Int32(Date().timeIntervalSince1970)
119+
120+
if conferenceCall.flags.contains(.isMissed) {
121+
string = strings.Chat_CallMessage_DeclinedGroupCall
122+
} else if conferenceCall.duration == nil && message.timestamp < currentTime - missedTimeout {
123+
string = strings.Chat_CallMessage_MissedGroupCall
124+
} else {
125+
if incoming {
126+
string = strings.Chat_CallMessage_IncomingGroupCall
127+
} else {
128+
string = strings.Chat_CallMessage_OutgoingGroupCall
129+
}
116130
}
117-
118131
default:
119132
break
133+
}
134+
135+
default:
136+
break
120137
}
121138
}
122139
return string

submodules/TelegramCore/Sources/State/AccountViewTracker.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,9 +2373,6 @@ public final class AccountViewTracker {
23732373
}()
23742374

23752375
let groupingPredicate: (Message, Message) -> Bool = { lhs, rhs in
2376-
if lhs.id.peerId != rhs.id.peerId {
2377-
return false
2378-
}
23792376
let lhsTimestamp = ((lhs.timestamp + timezoneOffset) / (granularity)) * (granularity)
23802377
let rhsTimestamp = ((rhs.timestamp + timezoneOffset) / (granularity)) * (granularity)
23812378
if lhsTimestamp != rhsTimestamp {
@@ -2400,6 +2397,7 @@ public final class AccountViewTracker {
24002397
}
24012398
}
24022399
}
2400+
24032401
var rhsVideo = false
24042402
var rhsMissed = false
24052403
var rhsOther = false
@@ -2422,6 +2420,14 @@ public final class AccountViewTracker {
24222420
if lhsMissed != rhsMissed || lhsOther != rhsOther || lhsVideo != rhsVideo || lhsConferenceId != rhsConferenceId {
24232421
return false
24242422
}
2423+
2424+
if lhsConferenceId != nil && rhsConferenceId != nil {
2425+
} else {
2426+
if lhs.id.peerId != rhs.id.peerId {
2427+
return false
2428+
}
2429+
}
2430+
24252431
return true
24262432
}
24272433

submodules/TelegramCore/Sources/TelegramEngine/Peers/CreateGroup.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func _internal_createGroup(account: Account, title: String, peerIds: [PeerId], t
3737
}
3838
}
3939

40+
var ttlPeriod = ttlPeriod
41+
if ttlPeriod == nil {
42+
ttlPeriod = 0
43+
}
44+
4045
var flags: Int32 = 0
4146
if let _ = ttlPeriod {
4247
flags |= 1 << 0

0 commit comments

Comments
 (0)