Skip to content

Commit 0a5c043

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 2a35678 + 5390369 commit 0a5c043

File tree

41 files changed

+919
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+919
-521
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15208,6 +15208,7 @@ Error: %8$@";
1520815208
"Gift.Auction.Stars_any" = "%@ Stars";
1520915209

1521015210
"Gift.AuctionBid.Title" = "Place a Bid";
15211+
"Gift.AuctionBid.Subtitle" = "Top %@ bidders will win";
1521115212
"Gift.AuctionBid.MinimumBid" = "minimum bid";
1521215213
"Gift.AuctionBid.UntilNext" = "until next round";
1521315214
"Gift.AuctionBid.Left" = "left";
@@ -15423,3 +15424,9 @@ Error: %8$@";
1542315424
"ChatList.AlertResumeLiveStreamTitle" = "Resume Live Stream";
1542415425
"ChatList.AlertResumeLiveStreamText" = "Do you want to resume an existing Live Stream?";
1542515426
"ChatList.AlertResumeLiveStreamAction" = "Resume";
15427+
15428+
"Gift.Options.Gift.JoinAuction" = "Join";
15429+
"Gift.Options.Gift.ViewAuction" = "View";
15430+
15431+
"LiveStream.ErrorMaxAllowedEmoji.Text_1" = "You can send up to %d emoji.";
15432+
"LiveStream.ErrorMaxAllowedEmoji.Text_any" = "You can send up to %d emoji.";

build_number_offset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2600
1+
2620

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,8 @@ public protocol SharedAccountContext: AnyObject {
14231423
func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: ((StarGift.UniqueGift) -> Void)?, openChatTheme: (() -> Void)?, dismissed: (() -> Void)?) -> ViewController
14241424
func makeGiftWearPreviewScreen(context: AccountContext, gift: StarGift.UniqueGift) -> ViewController
14251425
func makeGiftAuctionInfoScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: (() -> Void)?) -> ViewController
1426-
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext) -> ViewController
1427-
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping () -> Void) -> ViewController
1426+
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext, acquiredGifts: [GiftAuctionAcquiredGift]?) -> ViewController
1427+
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping ([GiftAuctionAcquiredGift]?) -> Void) -> ViewController
14281428
func makeGiftAuctionActiveBidsScreen(context: AccountContext) -> ViewController
14291429

14301430
func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController

submodules/Components/SheetComponent/Sources/SheetComponent.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
400400
self.component = component
401401
self.currentHasInputHeight = sheetEnvironment.hasInputHeight
402402

403+
if self.isAnimatingOut {
404+
return availableSize
405+
}
406+
403407
var glassInset: CGFloat = 0.0
404408
var topCornerRadius: CGFloat
405409
var bottomCornerRadius: CGFloat

submodules/TelegramBaseController/Sources/GiftAuctionAccessoryPanel.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ final class GiftAuctionAccessoryPanel: ASDisplayNode {
106106
let titleText: String = self.strings.ChatList_Auctions_ActiveAuction(Int32(self.states.count))
107107
titleItems.append(AnyComponentWithIdentity(id: "label", component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: titleText, font: titleFont, textColor: self.theme.rootController.navigationBar.primaryTextColor))))))
108108

109-
let titleSize = self.title.update(
110-
transition: .immediate,
111-
component: AnyComponent(
112-
HStack(titleItems, spacing: 3.0, alignment: .left)
113-
),
114-
environment: {},
115-
containerSize: size
116-
)
117-
let titleFrame = CGRect(origin: CGPoint(x: 16.0, y: 9.0), size: titleSize)
118-
if let titleView = self.title.view {
119-
if titleView.superview == nil {
120-
self.contentNode.view.addSubview(titleView)
121-
}
122-
titleView.frame = titleFrame
123-
}
124-
125109
let subtitleText: String
126110
var subtitleTextColor = self.theme.rootController.navigationBar.secondaryTextColor
127111
var isOutbid = false
@@ -195,20 +179,6 @@ final class GiftAuctionAccessoryPanel: ASDisplayNode {
195179
buttonAnimatedTitleItems.append(AnimatedTextComponent.Item(id: "view", content: .text(self.strings.ChatList_Auctions_View)))
196180
}
197181

198-
let subtitleSize = self.subtitle.update(
199-
transition: .immediate,
200-
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: subtitleText, font: subtitleFont, textColor: subtitleTextColor)))),
201-
environment: {},
202-
containerSize: size
203-
)
204-
let subtitleFrame = CGRect(origin: CGPoint(x: 16.0, y: 29.0), size: subtitleSize)
205-
if let subtitleView = self.subtitle.view {
206-
if subtitleView.superview == nil {
207-
self.contentNode.view.addSubview(subtitleView)
208-
}
209-
subtitleView.frame = subtitleFrame
210-
}
211-
212182
let buttonSize = self.button.update(
213183
transition: .spring(duration: 0.2),
214184
component: AnyComponent(
@@ -254,6 +224,36 @@ final class GiftAuctionAccessoryPanel: ASDisplayNode {
254224
buttonView.frame = buttonFrame
255225
}
256226

227+
let titleSize = self.title.update(
228+
transition: .immediate,
229+
component: AnyComponent(
230+
HStack(titleItems, spacing: 3.0, alignment: .left)
231+
),
232+
environment: {},
233+
containerSize: CGSize(width: size.width - buttonSize.width - 48.0, height: size.height)
234+
)
235+
let titleFrame = CGRect(origin: CGPoint(x: 16.0, y: 9.0), size: titleSize)
236+
if let titleView = self.title.view {
237+
if titleView.superview == nil {
238+
self.contentNode.view.addSubview(titleView)
239+
}
240+
titleView.frame = titleFrame
241+
}
242+
243+
let subtitleSize = self.subtitle.update(
244+
transition: .immediate,
245+
component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: subtitleText, font: subtitleFont, textColor: subtitleTextColor)))),
246+
environment: {},
247+
containerSize: CGSize(width: size.width - buttonSize.width - 40.0, height: size.height)
248+
)
249+
let subtitleFrame = CGRect(origin: CGPoint(x: 16.0, y: 29.0), size: subtitleSize)
250+
if let subtitleView = self.subtitle.view {
251+
if subtitleView.superview == nil {
252+
self.contentNode.view.addSubview(subtitleView)
253+
}
254+
subtitleView.frame = subtitleFrame
255+
}
256+
257257
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: UIScreenPixel)))
258258
}
259259

submodules/TelegramBaseController/Sources/TelegramBaseController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
565565
guard let self, let auction else {
566566
return
567567
}
568-
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction)
568+
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction, acquiredGifts: nil)
569569
self.push(controller)
570570
})
571571
}

submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
27252725
if didUpdateInvitedPeers {
27262726
self.invitedPeersValue = updatedInvitedPeers
27272727
}
2728+
2729+
self.messagesContext?.updateSettings(minMessagePrice: stateValue.sendPaidMessageStars ?? 0)
27282730
}))
27292731

27302732
self.isFailedEventDisposable?.dispose()

submodules/TelegramCore/Sources/TelegramEngine/Calls/GroupCalls.swift

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ public final class GroupCallParticipantsContext {
26542654
if sendPaidMessageStars != nil {
26552655
flags |= 1 << 3
26562656
}
2657-
self.updateMessagesEnabledDisposable.set((self.account.network.request(Api.functions.phone.toggleGroupCallSettings(flags: 1 << 2, call: self.reference.apiInputGroupCall, joinMuted: nil, messagesEnabled: isEnabled ? .boolTrue : .boolFalse, sendPaidMessagesStars: sendPaidMessageStars))
2657+
self.updateMessagesEnabledDisposable.set((self.account.network.request(Api.functions.phone.toggleGroupCallSettings(flags: flags, call: self.reference.apiInputGroupCall, joinMuted: nil, messagesEnabled: isEnabled ? .boolTrue : .boolFalse, sendPaidMessagesStars: sendPaidMessageStars))
26582658
|> deliverOnMainQueue).start(next: { [weak self] updates in
26592659
guard let strongSelf = self else {
26602660
return
@@ -3899,6 +3899,8 @@ public final class GroupCallMessagesContext {
38993899
private var pendingSendStars: (fromPeer: Peer, messageId: Int64, amount: Int64)?
39003900
private var pendingSendStarsTimer: SwiftSignalKit.Timer?
39013901

3902+
private var minMessagePrice: Int64 = 0
3903+
39023904
init(queue: Queue, appConfig: AppConfiguration, account: Account, callId: Int64, reference: InternalGroupCallReference, e2eContext: ConferenceCallE2EContext?, messageLifetime: Int32, isLiveStream: Bool) {
39033905
self.queue = queue
39043906
self.params = LiveChatMessageParams(appConfig: appConfig)
@@ -4039,7 +4041,7 @@ public final class GroupCallMessagesContext {
40394041
existingIds.insert(message.id)
40404042
state.messages.append(message)
40414043
if self.isLiveStream, let paidStars = message.paidStars {
4042-
if message.date + message.lifetime >= currentTime {
4044+
if message.date + message.lifetime >= currentTime && paidStars >= self.minMessagePrice {
40434045
state.pinnedMessages.append(message)
40444046
}
40454047
if let author = message.author {
@@ -4301,7 +4303,7 @@ public final class GroupCallMessagesContext {
43014303
)
43024304
state.messages.append(message)
43034305
if self.isLiveStream {
4304-
if let paidStars {
4306+
if let paidStars, paidStars >= self.minMessagePrice {
43054307
state.pinnedMessages.append(message)
43064308
if let fromPeer {
43074309
Impl.addStateStars(state: &state, peerId: fromPeer.id, isMy: true, amount: paidStars)
@@ -4535,36 +4537,42 @@ public final class GroupCallMessagesContext {
45354537
paidStars: totalAmount
45364538
))
45374539
}
4538-
if let index = state.pinnedMessages.firstIndex(where: { $0.id == Message.Id(space: .local, id: pendingSendStarsValue.messageId) }) {
4539-
let message = state.pinnedMessages[index]
4540-
state.pinnedMessages.remove(at: index)
4541-
state.pinnedMessages.append(Message(
4542-
id: message.id,
4543-
stableId: message.stableId,
4544-
isIncoming: message.isIncoming,
4545-
author: message.author,
4546-
isFromAdmin: isAdmin,
4547-
text: message.text,
4548-
entities: message.entities,
4549-
date: currentTime,
4550-
lifetime: lifetime,
4551-
paidStars: totalAmount
4552-
))
4540+
if totalAmount >= self.minMessagePrice {
4541+
if let index = state.pinnedMessages.firstIndex(where: { $0.id == Message.Id(space: .local, id: pendingSendStarsValue.messageId) }) {
4542+
let message = state.pinnedMessages[index]
4543+
state.pinnedMessages.remove(at: index)
4544+
state.pinnedMessages.append(Message(
4545+
id: message.id,
4546+
stableId: message.stableId,
4547+
isIncoming: message.isIncoming,
4548+
author: message.author,
4549+
isFromAdmin: isAdmin,
4550+
text: message.text,
4551+
entities: message.entities,
4552+
date: currentTime,
4553+
lifetime: lifetime,
4554+
paidStars: totalAmount
4555+
))
4556+
} else {
4557+
let stableId = self.nextStableId
4558+
self.nextStableId += 1
4559+
state.pinnedMessages.append(Message(
4560+
id: Message.Id(space: .local, id: pendingSendStarsValue.messageId),
4561+
stableId: stableId,
4562+
isIncoming: false,
4563+
author: EnginePeer(fromPeer),
4564+
isFromAdmin: isAdmin,
4565+
text: "",
4566+
entities: [],
4567+
date: currentTime,
4568+
lifetime: lifetime,
4569+
paidStars: totalAmount
4570+
))
4571+
}
45534572
} else {
4554-
let stableId = self.nextStableId
4555-
self.nextStableId += 1
4556-
state.pinnedMessages.append(Message(
4557-
id: Message.Id(space: .local, id: pendingSendStarsValue.messageId),
4558-
stableId: stableId,
4559-
isIncoming: false,
4560-
author: EnginePeer(fromPeer),
4561-
isFromAdmin: isAdmin,
4562-
text: "",
4563-
entities: [],
4564-
date: currentTime,
4565-
lifetime: lifetime,
4566-
paidStars: totalAmount
4567-
))
4573+
if let index = state.pinnedMessages.firstIndex(where: { $0.id == Message.Id(space: .local, id: pendingSendStarsValue.messageId) }) {
4574+
state.pinnedMessages.remove(at: index)
4575+
}
45684576
}
45694577
}
45704578

@@ -4647,6 +4655,26 @@ public final class GroupCallMessagesContext {
46474655
}
46484656
})
46494657
}
4658+
4659+
func updateSettings(minMessagePrice: Int64) {
4660+
if self.minMessagePrice != minMessagePrice {
4661+
self.minMessagePrice = minMessagePrice
4662+
4663+
var updatedState: State?
4664+
for i in (0 ..< self.state.pinnedMessages.count).reversed() {
4665+
let message = self.state.pinnedMessages[i]
4666+
if let paidStars = message.paidStars, paidStars < minMessagePrice {
4667+
if updatedState == nil {
4668+
updatedState = self.state
4669+
}
4670+
updatedState?.pinnedMessages.remove(at: i)
4671+
}
4672+
}
4673+
if let updatedState {
4674+
self.state = updatedState
4675+
}
4676+
}
4677+
}
46504678
}
46514679

46524680
private let queue: Queue
@@ -4702,6 +4730,12 @@ public final class GroupCallMessagesContext {
47024730
}
47034731
}
47044732

4733+
public func updateSettings(minMessagePrice: Int64) {
4734+
self.impl.with { impl in
4735+
impl.updateSettings(minMessagePrice: minMessagePrice)
4736+
}
4737+
}
4738+
47054739
public static func getStarAmountParamMapping(params: LiveChatMessageParams, value: Int64) -> (period: Int, maxLength: Int, emojiCount: Int, color: Message.Color?) {
47064740
for item in params.paramSets.reversed() {
47074741
if value >= item.minStars {

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public final class GiftAuctionContext {
6060
}
6161

6262
public struct MyState: Equatable {
63-
public var isOutbid: Bool
63+
public var isReturned: Bool
6464
public var bidAmount: Int64?
6565
public var bidDate: Int32?
6666
public var minBidAmount: Int64?
@@ -106,6 +106,14 @@ public final class GiftAuctionContext {
106106
}
107107
}
108108

109+
public var isFinished: Bool {
110+
if case .finished = self.auctionState {
111+
return true
112+
} else {
113+
return false
114+
}
115+
}
116+
109117
public convenience init(account: Account, gift: StarGift) {
110118
self.init(account: account, gift: gift, initialAuctionState: nil, initialMyState: nil, initialTimeout: nil)
111119
}
@@ -128,7 +136,7 @@ public final class GiftAuctionContext {
128136

129137
private var currentVersion: Int32 {
130138
var currentVersion: Int32 = 0
131-
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = self.auctionState {
139+
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = self.auctionState {
132140
currentVersion = version
133141
}
134142
return currentVersion
@@ -176,7 +184,10 @@ public final class GiftAuctionContext {
176184
}
177185

178186
func updateAuctionState(_ auctionState: GiftAuctionContext.State.AuctionState) {
179-
self.auctionState = auctionState
187+
if case let .ongoing(version, _, _, _, _, _, _, _, _, _) = auctionState, version < self.currentVersion {
188+
} else {
189+
self.auctionState = auctionState
190+
}
180191
self.pushState()
181192
}
182193

@@ -251,7 +262,7 @@ extension GiftAuctionContext.State.MyState {
251262
init(apiAuctionUserState: Api.StarGiftAuctionUserState) {
252263
switch apiAuctionUserState {
253264
case let .starGiftAuctionUserState(flags, bidAmount, bidDate, minBidAmount, bidPeerId, acquiredCount):
254-
self.isOutbid = (flags & (1 << 1)) != 0
265+
self.isReturned = (flags & (1 << 1)) != 0
255266
self.bidAmount = bidAmount
256267
self.bidDate = bidDate
257268
self.minBidAmount = minBidAmount

submodules/TelegramUI/Components/AsyncListComponent/Sources/AsyncListComponent.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,34 @@ public final class AsyncListComponent: Component {
165165
return nil
166166
}
167167
}
168+
169+
public final class VisibleItemViews: Sequence, IteratorProtocol {
170+
private var index: Int = 0
171+
private let itemViews: [UIView]
172+
173+
init(view: AsyncListComponent.View) {
174+
var itemViews: [(Int, UIView)] = []
175+
view.listNode.forEachItemNode { itemNode in
176+
if let itemNode = itemNode as? ListItemNodeImpl, let index = itemNode.index {
177+
if let itemContentView = itemNode.contentsView.view {
178+
itemViews.append((index, itemContentView))
179+
}
180+
}
181+
}
182+
itemViews.sort(by: { $0.0 < $1.0 })
183+
self.itemViews = itemViews.map(\.1)
184+
}
185+
186+
public func next() -> UIView? {
187+
if self.index >= self.itemViews.count {
188+
return nil
189+
}
190+
let index = self.index
191+
self.index += 1
192+
193+
return self.itemViews[index]
194+
}
195+
}
168196

169197
public let externalState: ExternalState
170198
public let externalStateValue: ExternalState.Value
@@ -505,6 +533,10 @@ public final class AsyncListComponent: Component {
505533
return nil
506534
}
507535

536+
public func visibleItemViews() -> VisibleItemViews {
537+
return VisibleItemViews(view: self)
538+
}
539+
508540
func update(component: AsyncListComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
509541
let previousComponent = self.component
510542
self.component = component

0 commit comments

Comments
 (0)