Various fixes

This commit is contained in:
Ilya Laktyushin 2023-10-25 15:54:27 +04:00
parent 014e3d8b76
commit 9e8bf48a96
7 changed files with 80 additions and 34 deletions

View File

@ -10119,6 +10119,7 @@ Sorry for the inconvenience.";
"Channel.AdminLog.MessageChangedNameColorSet" = "%1$@ set name color to %2$@";
"Channel.AdminLog.MessageChangedBackgroundEmojiSet" = "%1$@ set background emoji to %2$@";
"Channel.AdminLog.MessageChangedBackgroundEmojiRemoved" = "%1$@ removed background emoji";
"Appearance.NameColor" = "Your Name Color";
@ -10277,7 +10278,8 @@ Sorry for the inconvenience.";
"BoostGift.Channels.Save" = "Save Channels";
"Stats.Boosts.PrepaidGiveawaysTitle" = "PREPAID GIVEAWAYS";
"Stats.Boosts.PrepaidGiveawayCount_any" = "%@ Telegram Premium";
"Stats.Boosts.PrepaidGiveawayCount_1" = "%@ Telegram Premium";
"Stats.Boosts.PrepaidGiveawayCount_any" = "%@ Telegram Premiums";
"Stats.Boosts.PrepaidGiveawayMonths" = "%@-month subscriptions";
"Stats.Boosts.PrepaidGiveawaysInfo" = "Select a giveaway you already paid for to set it up.";
"Stats.Boosts.ShortMonth" = "%@m";
@ -10361,9 +10363,9 @@ Sorry for the inconvenience.";
"Chat.Giveaway.Message.PrizeTitle" = "Giveaway Prizes";
"Chat.Giveaway.Message.PrizeText" = "%1$@ for %2$@.";
"Chat.Giveaway.Message.Subscriptions_1" = "**%@** Telegram Premium Subscription";
"Chat.Giveaway.Message.Subscriptions_many" = "**%@** Telegram Premium Subscriptions";
"Chat.Giveaway.Message.Subscriptions_any" = "**%@** Telegram Premium Subscriptions";
"Chat.Giveaway.Message.Months_1" = "**%@** month";
"Chat.Giveaway.Message.Months_many" = "**%@** months";
"Chat.Giveaway.Message.Months_any" = "**%@** months";
"Chat.Giveaway.Message.ParticipantsTitle" = "Participants";
"Chat.Giveaway.Message.ParticipantsNewMany" = "All users who join the channels below after this date:";
"Chat.Giveaway.Message.ParticipantsNew" = "All users who join this channel after this date:";

View File

@ -76,6 +76,8 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
var cachedCloseImage: (UIImage, PresentationTheme)?
var inProgress = false
init(context: AccountContext, subject: PremiumGiftCodeScreen.Subject) {
self.context = context
@ -426,9 +428,14 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
iconName: nil,
animationName: nil,
iconPosition: .left,
action: {
isLoading: state.inProgress,
action: { [weak state] in
if gloss {
component.action()
if let state {
state.inProgress = true
state.updated()
}
} else {
component.cancel(true)
}
@ -559,6 +566,7 @@ private final class PremiumGiftCodeSheetComponent: CombinedComponent {
displayHiddenTooltip: context.component.displayHiddenTooltip
)),
backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor),
followContentSizeChanges: true,
animateOut: animateOut
),
environment: {
@ -685,6 +693,12 @@ public class PremiumGiftCodeScreen: ViewControllerComponentContainer {
self.dismissAllTooltips()
}
public func dismissAnimated() {
if let view = self.node.hostView.findTaggedView(tag: SheetComponent<ViewControllerComponentContainer.Environment>.View.Tag()) as? SheetComponent<ViewControllerComponentContainer.Environment>.View {
view.dismissAnimated()
}
}
fileprivate func dismissAllTooltips() {
self.window?.forEachController({ controller in
if let controller = controller as? UndoOverlayController {

View File

@ -2915,8 +2915,8 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer {
}
completionImpl = { [weak self] in
if let strongSelf = self {
strongSelf.view.addSubview(ConfettiView(frame: strongSelf.view.bounds))
if let self {
self.animateSuccess()
}
}
}
@ -2930,6 +2930,10 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer {
self.wasDismissed?()
}
public func animateSuccess() {
self.view.addSubview(ConfettiView(frame: self.view.bounds))
}
public override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
super.containerLayoutUpdated(layout, transition: transition)

View File

@ -219,7 +219,7 @@ private final class ChannelBoostersContextImpl {
}
func loadMore() {
if self.isLoadingMore {
if self.isLoadingMore || !self.canLoadMore {
return
}
self.isLoadingMore = true
@ -312,11 +312,19 @@ private final class ChannelBoostersContextImpl {
}
strongSelf.isLoadingMore = false
strongSelf.hasLoadedOnce = true
strongSelf.canLoadMore = !boosters.isEmpty
strongSelf.canLoadMore = !boosters.isEmpty && nextOffset != nil
if strongSelf.canLoadMore {
strongSelf.count = max(updatedCount, Int32(strongSelf.results.count))
var resultsCount: Int32 = 0
for result in strongSelf.results {
resultsCount += result.multiplier
}
strongSelf.count = max(updatedCount, resultsCount)
} else {
strongSelf.count = Int32(strongSelf.results.count)
var resultsCount: Int32 = 0
for result in strongSelf.results {
resultsCount += result.multiplier
}
strongSelf.count = resultsCount
}
strongSelf.updateState()
}))

View File

@ -348,12 +348,10 @@ func channelAdminLogEvents(accountPeerId: PeerId, postbox: Postbox, network: Net
action = .toggleForum(isForum: newValue == .boolTrue)
case let .channelAdminLogEventActionToggleAntiSpam(newValue):
action = .toggleAntiSpam(isEnabled: newValue == .boolTrue)
default:
action = .toggleInvites(false)
// case let .channelAdminLogEventActionChangeColor(prevValue, newValue):
// action = .changeNameColor(prev: PeerNameColor(rawValue: prevValue), new: PeerNameColor(rawValue: newValue))
// case let .channelAdminLogEventActionChangeBackgroundEmoji(prevValue, newValue):
// action = .changeBackgroundEmojiId(prev: prevValue, new: newValue)
case let .channelAdminLogEventActionChangeColor(prevValue, newValue):
action = .changeNameColor(prev: PeerNameColor(rawValue: prevValue), new: PeerNameColor(rawValue: newValue))
case let .channelAdminLogEventActionChangeBackgroundEmoji(prevValue, newValue):
action = .changeBackgroundEmojiId(prev: prevValue, new: newValue)
}
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
if let action = action {

View File

@ -1873,7 +1873,9 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
var text: String = ""
var entities: [MessageTextEntity] = []
let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedNameColorSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "\(updatedValue)")
let _ = updatedValue
let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedNameColorSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "")
appendAttributedText(text: rawText, generateEntities: { index in
if index == 0, let author = author {
@ -1899,16 +1901,25 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
var text: String = ""
var entities: [MessageTextEntity] = []
let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "\(updatedValue ?? 0)")
if let updatedValue, updatedValue != 0 {
appendAttributedText(text: self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiSet(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", "."), generateEntities: { index in
if index == 0, let author = author {
return [.TextMention(peerId: author.id)]
} else if index == 1 {
return [.CustomEmoji(stickerPack: nil, fileId: updatedValue)]
}
return []
}, to: &text, entities: &entities)
} else {
let rawText = self.presentationData.strings.Channel_AdminLog_MessageChangedBackgroundEmojiRemoved(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "")
appendAttributedText(text: rawText, generateEntities: { index in
if index == 0, let author = author {
return [.TextMention(peerId: author.id)]
} else if index == 1 {
return [.Bold]
}
return []
}, to: &text, entities: &entities)
}
let action = TelegramMediaActionType.customText(text: text, entities: entities)

View File

@ -891,17 +891,26 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
forceDark = true
}
let _ = (context.engine.payments.checkPremiumGiftCode(slug: slug)
|> deliverOnMainQueue).startStandalone(next: { giftCode in
|> deliverOnMainQueue).startStandalone(next: { [weak navigationController] giftCode in
if let giftCode {
var dismissImpl: (() -> Void)?
let controller = PremiumGiftCodeScreen(
context: context,
subject: .giftCode(giftCode),
forceDark: forceDark,
action: {
action: { [weak navigationController] in
let _ = (context.engine.payments.applyPremiumGiftCode(slug: slug)
|> deliverOnMainQueue).startStandalone(completed: {
dismissImpl?()
let _ = context.engine.payments.applyPremiumGiftCode(slug: slug).startStandalone()
let controller = context.sharedContext.makePremiumIntroController(context: context, source: .settings, forceDark: forceDark, dismissed: nil)
navigationController?.pushViewController(controller)
if let controller = controller as? PremiumIntroScreen {
Queue.mainQueue().after(0.3, {
controller.animateSuccess()
})
}
})
},
openPeer: { peer in
if peer.id != context.account.peerId {
@ -941,7 +950,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
}
)
dismissImpl = { [weak controller] in
controller?.dismiss()
controller?.dismissAnimated()
}
navigationController?.pushViewController(controller)
} else {