Skip to content

Commit 7efcdb4

Browse files
committed
Various fixes
1 parent f223dab commit 7efcdb4

File tree

10 files changed

+115
-68
lines changed

10 files changed

+115
-68
lines changed

Telegram/NotificationService/Sources/NotificationService.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,12 @@ private final class NotificationServiceHandler {
795795
var recordId: AccountRecordId?
796796
var isCurrentAccount: Bool = false
797797

798-
var automaticMediaDownloadSettings: MediaAutoDownloadSettings
799-
if let value = sharedData.entries[ApplicationSpecificSharedDataKeys.automaticMediaDownloadSettings]?.get(MediaAutoDownloadSettings.self) {
800-
automaticMediaDownloadSettings = value
801-
} else {
802-
automaticMediaDownloadSettings = MediaAutoDownloadSettings.defaultSettings
803-
}
798+
// var automaticMediaDownloadSettings: MediaAutoDownloadSettings
799+
// if let value = sharedData.entries[ApplicationSpecificSharedDataKeys.automaticMediaDownloadSettings]?.get(MediaAutoDownloadSettings.self) {
800+
// automaticMediaDownloadSettings = value
801+
// } else {
802+
// automaticMediaDownloadSettings = MediaAutoDownloadSettings.defaultSettings
803+
// }
804804
let shouldSynchronizeState = true//automaticMediaDownloadSettings.energyUsageSettings.synchronizeInBackground
805805

806806
if let keyId = notificationPayloadKeyId(data: payloadData) {
@@ -1186,7 +1186,7 @@ private final class NotificationServiceHandler {
11861186
action = .pollStories(peerId: peerId, content: content, storyId: storyId, isReaction: isReaction)
11871187
} else {
11881188
var reportDelivery = false
1189-
if let reportDeliveryUntilDate = aps["report_delivery_until_date"] as? Int32, let messageId = messageIdValue {
1189+
if let reportDeliveryUntilDate = aps["report_delivery_until_date"] as? Int32 {
11901190
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
11911191
if reportDeliveryUntilDate > currentTime {
11921192
reportDelivery = true
@@ -1696,9 +1696,6 @@ private final class NotificationServiceHandler {
16961696
let reportDeliverySignal: Signal<Bool, NoError>
16971697
if reportDelivery, let messageId {
16981698
reportDeliverySignal = _internal_reportMessageDelivery(postbox: stateManager.postbox, network: stateManager.network, messageIds: [messageId], fromPushNotification: true)
1699-
|> mapToSignal { _ -> Signal<Bool, NoError> in
1700-
return .single(true)
1701-
}
17021699
|> then(.single(true))
17031700
} else {
17041701
reportDeliverySignal = .single(true)

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@
263263
"PUSH_MESSAGE_WALLPAPER" = "%1$@ set a new wallpaper for the chat with you";
264264
"PUSH_MESSAGE_SAME_WALLPAPER" = "%1$@ set the same wallpaper for the chat with you";
265265

266+
"PUSH_MESSAGE_UNIQUE_STARGIFT" = "%1$@ sent you a Gift";
267+
266268
"PUSH_REMINDER_TITLE" = "🗓 Reminder";
267269
"PUSH_SENDER_YOU" = "📅 You";
268270

@@ -13532,7 +13534,7 @@ Sorry for the inconvenience.";
1353213534
"Gift.Transfer.Confirmation.Transfer" = "Transfer for";
1353313535
"Gift.Transfer.Confirmation.TransferFree" = "Transfer";
1353413536

13535-
"Gift.Transfer.Success" = "You have successfully gifter **%1$@** to **%2$@**.";
13537+
"Gift.Transfer.Success" = "You have successfully gifted **%1$@** to **%2$@**.";
1353613538

1353713539
"Gift.View.UpgradeForFree" = "Upgrade for Free";
1353813540
"Gift.View.KeepUpgradeOrConvertDescription" = "You can keep this gift, upgrade it, or sell it for %@. [More About Stars >]()";
@@ -13571,6 +13573,7 @@ Sorry for the inconvenience.";
1357113573

1357213574
"Notification.StarsGift.Upgrade" = "%@ turned the gift from you to a unique collectible";
1357313575
"Notification.StarsGift.UpgradeYou" = "You turned the gift from %@ to a unique collectible";
13576+
"Notification.StarsGift.UpgradeSelf" = "You turned the gift to a unique collectible";
1357413577

1357513578
"Notification.StarsGift.Transfer" = "%@ transferred you a unique collectible";
1357613579
"Notification.StarsGift.TransferYou" = "You transferred a unique collectible";
@@ -13605,8 +13608,8 @@ Sorry for the inconvenience.";
1360513608
"Gift.SendSelf.HideMyName.Info" = "Hide my name and message from visitors to my profile.";
1360613609

1360713610
"Notification.StarGift.Self.Title" = "Saved Gift";
13608-
"Notification.StarGift.Self.Bought" = "You bought a gift for %@";
13609-
"Notification.StarGift.Self.Bought" = "You can display this gift on your page or turn it into a unique collectible and send to others.";
13611+
"Notification.StarsGift.Self.Bought" = "You bought a gift for %@";
13612+
"Notification.StarsGift.Subtitle.Self" = "You can display this gift on your page or turn it into a unique collectible and send to others.";
1361013613

1361113614
"Gift.View.Self.Title" = "Saved Gift";
1361213615
"Gift.View.Self.Description" = "You can display this gift on your page or turn it into a unique collectible and send to others.";
@@ -13637,3 +13640,6 @@ Sorry for the inconvenience.";
1363713640

1363813641
"Premium.Gift.ContactSelection.ThisIsYou" = "THIS IS YOU";
1363913642
"Premium.Gift.ContactSelection.BuySelf" = "buy yourself a gift";
13643+
13644+
"Gift.View.Outgoing.NameHidden" = "Only %@ can see your name.";
13645+
"Gift.View.Outgoing.NameAndMessageHidden" = "Only %@ can see your name and message.";

submodules/TelegramCore/Sources/TelegramEngine/Messages/ReportMessageDelivery.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import Postbox
33
import SwiftSignalKit
44
import TelegramApi
55

6-
public func _internal_reportMessageDelivery(postbox: Postbox, network: Network, messageIds: [EngineMessage.Id], fromPushNotification: Bool) -> Signal<Never, NoError> {
6+
public func _internal_reportMessageDelivery(postbox: Postbox, network: Network, messageIds: [EngineMessage.Id], fromPushNotification: Bool) -> Signal<Bool, NoError> {
77
var signals: [Signal<Void, NoError>] = []
88
for (peerId, messageIds) in messagesIdsGroupedByPeerId(messageIds) {
99
signals.append(_internal_reportMessageDeliveryByPeerId(postbox: postbox, network: network, peerId: peerId, messageIds: messageIds, fromPushNotification: fromPushNotification))
1010
}
1111
return combineLatest(signals)
12-
|> ignoreValues
12+
|> mapToSignal { _ in
13+
return .single(true)
14+
}
1315
}
1416

1517
private func _internal_reportMessageDeliveryByPeerId(postbox: Postbox, network: Network, peerId: EnginePeer.Id, messageIds: [EngineMessage.Id], fromPushNotification: Bool) -> Signal<Void, NoError> {

submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
10861086
authorName = strings.Notification_StarsGift_UnknownUser
10871087
peerIds = []
10881088
}
1089-
if message.author?.id == accountPeerId {
1089+
if message.id.peerId == accountPeerId {
1090+
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Self_Bought(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
1091+
} else if message.author?.id == accountPeerId {
10901092
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
10911093
} else {
10921094
var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
@@ -1102,7 +1104,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
11021104
let peerName = EnginePeer(messagePeer).compactDisplayTitle
11031105
let peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]
11041106
if isUpgrade {
1105-
if message.author?.id == accountPeerId {
1107+
if message.id.peerId == accountPeerId {
1108+
attributedString = NSAttributedString(string: strings.Notification_StarsGift_UpgradeSelf, font: titleFont, textColor: primaryTextColor)
1109+
} else if message.author?.id == accountPeerId {
11061110
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
11071111
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_UpgradeYou(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
11081112
} else {

submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,13 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
466466
if case let .generic(gift) = gift {
467467
isStarGift = true
468468
let authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
469-
title = item.presentationData.strings.Notification_StarGift_Title(authorName).string
469+
470+
let isSelfGift = item.message.id.peerId == item.context.account.peerId
471+
if isSelfGift {
472+
title = item.presentationData.strings.Notification_StarGift_Self_Title
473+
} else {
474+
title = item.presentationData.strings.Notification_StarGift_Title(authorName).string
475+
}
470476
if let giftText, !giftText.isEmpty {
471477
text = giftText
472478
entities = giftEntities ?? []
@@ -480,6 +486,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
480486
text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string
481487
} else if upgradeStars != nil {
482488
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade
489+
} else if isSelfGift {
490+
text = item.presentationData.strings.Notification_StarsGift_Subtitle_Self
483491
} else if savedToProfile {
484492
if let convertStars {
485493
text = item.presentationData.strings.Notification_StarGift_Subtitle_Displaying(item.presentationData.strings.Notification_StarGift_Subtitle_Displaying_Stars(Int32(convertStars))).string

submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/ChatGiftPreviewItem.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class ChatGiftPreviewItem: ListViewItem, ItemListItem, ListItemComponentAd
3131

3232
let accountPeer: EnginePeer?
3333
let subject: ChatGiftPreviewItem.Subject
34+
let isSelf: Bool
3435
let text: String
3536
let entities: [MessageTextEntity]
3637
let includeUpgrade: Bool
@@ -48,6 +49,7 @@ final class ChatGiftPreviewItem: ListViewItem, ItemListItem, ListItemComponentAd
4849
nameDisplayOrder: PresentationPersonNameOrder,
4950
accountPeer: EnginePeer?,
5051
subject: ChatGiftPreviewItem.Subject,
52+
isSelf: Bool,
5153
text: String,
5254
entities: [MessageTextEntity],
5355
includeUpgrade: Bool
@@ -64,6 +66,7 @@ final class ChatGiftPreviewItem: ListViewItem, ItemListItem, ListItemComponentAd
6466
self.nameDisplayOrder = nameDisplayOrder
6567
self.accountPeer = accountPeer
6668
self.subject = subject
69+
self.isSelf = isSelf
6770
self.text = text
6871
self.entities = entities
6972
self.includeUpgrade = includeUpgrade
@@ -206,6 +209,10 @@ final class ChatGiftPreviewItemNode: ListViewItemNode {
206209
let separatorHeight = UIScreenPixel
207210

208211
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1))
212+
var chatPeerId = peerId
213+
if item.isSelf {
214+
chatPeerId = item.accountPeer?.id ?? chatPeerId
215+
}
209216

210217
var items: [ListViewItem] = []
211218
for _ in 0 ..< 1 {
@@ -232,7 +239,7 @@ final class ChatGiftPreviewItemNode: ListViewItemNode {
232239
]
233240
}
234241

235-
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: "", attributes: [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
242+
let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: chatPeerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: "", attributes: [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
236243
items.append(item.context.sharedContext.makeChatMessagePreviewItem(context: item.context, messages: [message], theme: item.componentTheme, strings: item.strings, wallpaper: item.wallpaper, fontSize: item.fontSize, chatBubbleCorners: item.chatBubbleCorners, dateTimeFormat: item.dateTimeFormat, nameOrder: item.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil, backgroundNode: currentBackgroundNode, availableReactions: nil, accountPeer: nil, isCentered: false, isPreview: true, isStandalone: false))
237244
}
238245

submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ final class GiftSetupScreenComponent: Component {
819819
nameDisplayOrder: presentationData.nameDisplayOrder,
820820
accountPeer: accountPeer,
821821
subject: subject,
822+
isSelf: component.peerId == component.context.account.peerId,
822823
text: self.textInputState.text.string,
823824
entities: generateChatInputTextEntities(self.textInputState.text),
824825
includeUpgrade: self.includeUpgrade

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ private final class GiftViewSheetContent: CombinedComponent {
382382
var canUpgrade = false
383383
var upgradeStars: Int64?
384384
var uniqueGift: StarGift.UniqueGift?
385+
var isSelfGift = false
386+
385387
if case let .soldOutGift(gift) = subject {
386388
animationFile = gift.file
387389
stars = gift.price
@@ -417,7 +419,14 @@ private final class GiftViewSheetContent: CombinedComponent {
417419
savedToProfile = arguments.savedToProfile
418420
incoming = arguments.incoming || arguments.peerId == component.context.account.peerId
419421
nameHidden = arguments.nameHidden
420-
titleString = incoming ? strings.Gift_View_ReceivedTitle : strings.Gift_View_Title
422+
423+
isSelfGift = arguments.messageId?.peerId == component.context.account.peerId
424+
425+
if isSelfGift {
426+
titleString = strings.Gift_View_Self_Title
427+
} else {
428+
titleString = incoming ? strings.Gift_View_ReceivedTitle : strings.Gift_View_Title
429+
}
421430
} else {
422431
animationFile = nil
423432
stars = 0
@@ -839,13 +848,22 @@ private final class GiftViewSheetContent: CombinedComponent {
839848
originY += 21.0
840849
}
841850

842-
if nameHidden && incoming && uniqueGift == nil {
851+
if nameHidden && uniqueGift == nil {
843852
let textFont = Font.regular(13.0)
844853
let textColor = theme.list.itemSecondaryTextColor
845854

855+
let hiddenDescription: String
856+
if incoming {
857+
hiddenDescription = text != nil ? strings.Gift_View_NameAndMessageHidden : strings.Gift_View_NameHidden
858+
} else if let peerId = subject.arguments?.peerId, let peer = state.peerMap[peerId] {
859+
hiddenDescription = text != nil ? strings.Gift_View_Outgoing_NameAndMessageHidden(peer.compactDisplayTitle).string : strings.Gift_View_Outgoing_NameHidden(peer.compactDisplayTitle).string
860+
} else {
861+
hiddenDescription = ""
862+
}
863+
846864
let hiddenText = hiddenText.update(
847865
component: MultilineTextComponent(
848-
text: .plain(NSAttributedString(string: text != nil ? strings.Gift_View_NameAndMessageHidden : strings.Gift_View_NameHidden, font: textFont, textColor: textColor)),
866+
text: .plain(NSAttributedString(string: hiddenDescription, font: textFont, textColor: textColor)),
849867
horizontalAlignment: .center,
850868
maximumNumberOfLines: 2,
851869
lineSpacing: 0.2
@@ -1003,24 +1021,28 @@ private final class GiftViewSheetContent: CombinedComponent {
10031021
}
10041022
))
10051023
}
1006-
tableItems.append(.init(
1007-
id: "from",
1008-
title: strings.Gift_View_From,
1009-
component: fromComponent
1010-
))
1024+
if !isSelfGift {
1025+
tableItems.append(.init(
1026+
id: "from",
1027+
title: strings.Gift_View_From,
1028+
component: fromComponent
1029+
))
1030+
}
10111031
} else {
1012-
tableItems.append(.init(
1013-
id: "from_anon",
1014-
title: strings.Gift_View_From,
1015-
component: AnyComponent(
1016-
PeerCellComponent(
1017-
context: component.context,
1018-
theme: theme,
1019-
strings: strings,
1020-
peer: nil
1032+
if !isSelfGift {
1033+
tableItems.append(.init(
1034+
id: "from_anon",
1035+
title: strings.Gift_View_From,
1036+
component: AnyComponent(
1037+
PeerCellComponent(
1038+
context: component.context,
1039+
theme: theme,
1040+
strings: strings,
1041+
peer: nil
1042+
)
10211043
)
1022-
)
1023-
))
1044+
))
1045+
}
10241046
}
10251047
}
10261048

0 commit comments

Comments
 (0)