Skip to content

Commit 2adffc2

Browse files
committed
Various fixes
1 parent e351bbf commit 2adffc2

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

submodules/SettingsUI/Sources/Privacy and Security/IncomingMessagePrivacyScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public func incomingMessagePrivacyScreen(context: AccountContext, value: GlobalP
346346
updateState { state in
347347
var updatedState = state
348348
updatedState.disableFor = updatedPeerIds
349-
return state
349+
return updatedState
350350
}
351351
let settings: SelectivePrivacySettings = .enableContacts(enableFor: updatedPeerIds, disableFor: [:], enableForPremium: false, enableForBots: false)
352352
let _ = context.engine.privacy.updateSelectiveAccountPrivacySettings(type: .noPaidMessages, settings: settings).start()

submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
432432
})
433433
case let .messagePrivacy(theme, value, hasPremium):
434434
let label: String
435-
switch value {
435+
var effectiveValue = value
436+
if !hasPremium {
437+
effectiveValue = .everybody
438+
}
439+
switch effectiveValue {
436440
case .everybody:
437441
label = presentationData.strings.Settings_Privacy_Messages_ValueEveryone
438442
case .requirePremium:
@@ -669,7 +673,7 @@ private func privacyAndSecurityControllerEntries(
669673
entries.append(.forwardPrivacy(presentationData.theme, presentationData.strings.Privacy_Forwards, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.forwards)))
670674
entries.append(.voiceCallPrivacy(presentationData.theme, presentationData.strings.Privacy_Calls, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceCalls)))
671675
if !isPremiumDisabled || isPremium {
672-
entries.append(.voiceMessagePrivacy(presentationData.theme, presentationData.strings.Privacy_VoiceMessages, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.voiceMessages), isPremium))
676+
entries.append(.voiceMessagePrivacy(presentationData.theme, presentationData.strings.Privacy_VoiceMessages, stringForSelectiveSettings(strings: presentationData.strings, settings: isPremium ? privacySettings.voiceMessages : .enableEveryone(disableFor: [:])), isPremium))
673677
entries.append(.messagePrivacy(presentationData.theme, privacySettings.globalSettings.nonContactChatsPrivacy, isPremium))
674678
}
675679
entries.append(.groupPrivacy(presentationData.theme, presentationData.strings.PrivacySettings_InviteItem, stringForSelectiveSettings(strings: presentationData.strings, settings: privacySettings.groupInvitations)))

submodules/TelegramUI/Components/Stars/StarsImageComponent/Sources/StarsImageComponent.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public final class StarsImageComponent: Component {
253253
case media([AnyMediaReference])
254254
case extendedMedia([TelegramExtendedMedia])
255255
case transactionPeer(StarsContext.State.Transaction.Peer)
256-
case gift(Int64)
256+
case gift(Int32)
257257
case color(UIColor)
258258

259259
public static func == (lhs: StarsImageComponent.Subject, rhs: StarsImageComponent.Subject) -> Bool {
@@ -850,14 +850,7 @@ public final class StarsImageComponent: Component {
850850
if let current = self.animationNode {
851851
animationNode = current
852852
} else {
853-
let stickerName: String
854-
if count <= 1000 {
855-
stickerName = "Gift3"
856-
} else if count < 2500 {
857-
stickerName = "Gift6"
858-
} else {
859-
stickerName = "Gift12"
860-
}
853+
let stickerName: String = "Gift\(count)"
861854
animationNode = DefaultAnimatedStickerNodeImpl()
862855
animationNode.autoplay = true
863856
animationNode.setup(source: AnimatedStickerNodeLocalFileSource(name: stickerName), width: 384, height: 384, playbackMode: .still(.end), mode: .direct(cachePathPrefix: nil))

submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
243243
var giftAvailability: StarGift.Gift.Availability?
244244
var isRefProgram = false
245245
var isPaidMessage = false
246+
var premiumGiftMonths: Int32?
246247

247248
var delayedCloseOnOpenPeer = true
248249
switch subject {
@@ -456,6 +457,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
456457
switch transaction.peer {
457458
case let .peer(peer):
458459
if let months = transaction.premiumGiftMonths {
460+
premiumGiftMonths = months
459461
titleText = strings.Stars_Transaction_TelegramPremium(months)
460462
} else if transaction.flags.contains(.isPaidMessage) {
461463
isPaidMessage = true
@@ -679,8 +681,18 @@ private final class StarsTransactionSheetContent: CombinedComponent {
679681

680682
let imageSubject: StarsImageComponent.Subject
681683
var imageIcon: StarsImageComponent.Icon?
682-
if isGift {
683-
imageSubject = .gift(count.value)
684+
if let premiumGiftMonths {
685+
imageSubject = .gift(premiumGiftMonths)
686+
} else if isGift {
687+
var value: Int32 = 3
688+
if count.value <= 1000 {
689+
value = 3
690+
} else if count.value < 2500 {
691+
value = 6
692+
} else {
693+
value = 12
694+
}
695+
imageSubject = .gift(value)
684696
} else if !media.isEmpty {
685697
imageSubject = .media(media)
686698
} else if let photo {
@@ -1852,13 +1864,16 @@ public class StarsTransactionScreen: ViewControllerComponentContainer {
18521864
guard let self, let navigationController = self.navigationController as? NavigationController else {
18531865
return
18541866
}
1855-
self.dismissAnimated()
18561867
let _ = (context.engine.privacy.requestAccountPrivacySettings()
1857-
|> deliverOnMainQueue).start(next: { [weak navigationController] privacySettings in
1868+
|> deliverOnMainQueue).start(next: { [weak self, weak navigationController] privacySettings in
18581869
let controller = context.sharedContext.makeIncomingMessagePrivacyScreen(context: context, value: privacySettings.globalSettings.nonContactChatsPrivacy, exceptions: privacySettings.noPaidMessages, update: { settingValue in
18591870
let _ = context.engine.privacy.updateNonContactChatsPrivacy(value: settingValue).start()
18601871
})
18611872
navigationController?.pushViewController(controller)
1873+
1874+
Queue.mainQueue().after(0.6) {
1875+
self?.dismissAnimated()
1876+
}
18621877
})
18631878
}
18641879

0 commit comments

Comments
 (0)