Skip to content

Commit cb802c5

Browse files
author
Isaac
committed
Revert "Experiment"
This reverts commit 8c54db6.
1 parent d40e803 commit cb802c5

23 files changed

Lines changed: 125 additions & 3901 deletions

File tree

Telegram/NotificationService/Sources/NotificationService.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,18 +1978,13 @@ private final class NotificationServiceHandler {
19781978
if let media = message.media.first {
19791979
parsedMedia = media
19801980
}
1981-
if enableInlineEmoji, let textEntitiesAttribute = message.textEntitiesAttribute, let author = message.author {
1982-
let authorTitle = author.debugDisplayTitle
1983-
let messagePrefix = "\(authorTitle): "
1984-
let messagePrefixLength = (messagePrefix as NSString).length
1981+
if enableInlineEmoji, let textEntitiesAttribute = message.textEntitiesAttribute {
1982+
content.body = message.text
19851983
for entity in textEntitiesAttribute.entities {
19861984
if case let .CustomEmoji(_, fileId) = entity.type {
1987-
content.customEmoji.append(NotificationContent.CustomEmoji(range: (entity.range.lowerBound + messagePrefixLength) ..< (entity.range.upperBound + messagePrefixLength), fileId: fileId))
1985+
content.customEmoji.append(NotificationContent.CustomEmoji(range: entity.range, fileId: fileId))
19881986
}
19891987
}
1990-
if !content.customEmoji.isEmpty {
1991-
content.body = messagePrefix + message.text
1992-
}
19931988
}
19941989
}
19951990

submodules/DebugSettingsUI/Sources/DebugController.swift

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
109109
case playerV2(Bool)
110110
case devRequests(Bool)
111111
case enableUpdates(Bool)
112-
case pwa(Bool)
112+
case fakeAds(Bool)
113113
case enableLocalTranslation(Bool)
114114
case preferredVideoCodec(Int, String, String?, Bool)
115115
case disableVideoAspectScaling(Bool)
@@ -135,7 +135,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
135135
return DebugControllerSection.web.rawValue
136136
case .keepChatNavigationStack, .skipReadHistory, .alwaysDisplayTyping, .debugRatingLayout, .crashOnSlowQueries, .crashOnMemoryPressure:
137137
return DebugControllerSection.experiments.rawValue
138-
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .compressedEmojiCache, .storiesJpegExperiment, .checkSerializedData, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .fakeGlass, .browserExperiment, .allForumsHaveTabs, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .enableUpdates, .pwa, .enableLocalTranslation:
138+
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .compressedEmojiCache, .storiesJpegExperiment, .checkSerializedData, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .fakeGlass, .browserExperiment, .allForumsHaveTabs, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .enableUpdates, .fakeAds, .enableLocalTranslation:
139139
return DebugControllerSection.experiments.rawValue
140140
case .logTranslationRecognition, .resetTranslationStates:
141141
return DebugControllerSection.translation.rawValue
@@ -258,7 +258,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
258258
return 54
259259
case .devRequests:
260260
return 55
261-
case .pwa:
261+
case .fakeAds:
262262
return 56
263263
case .enableLocalTranslation:
264264
return 57
@@ -1392,12 +1392,12 @@ private enum DebugControllerEntry: ItemListNodeEntry {
13921392
})
13931393
}).start()
13941394
})
1395-
case let .pwa(value):
1396-
return ItemListSwitchItem(presentationData: presentationData, systemStyle: .glass, title: "Test1", value: value, sectionId: self.section, style: .blocks, updated: { value in
1395+
case let .fakeAds(value):
1396+
return ItemListSwitchItem(presentationData: presentationData, systemStyle: .glass, title: "Fake Ads", value: value, sectionId: self.section, style: .blocks, updated: { value in
13971397
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
13981398
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
13991399
var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings
1400-
settings.enablePWA = value
1400+
settings.fakeAds = value
14011401
return PreferencesEntry(settings)
14021402
})
14031403
}).start()
@@ -1488,7 +1488,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
14881488
}
14891489
}
14901490

1491-
private func debugControllerEntries(context: AccountContext?, sharedContext: SharedAccountContext, presentationData: PresentationData, loggingSettings: LoggingSettings, mediaInputSettings: MediaInputSettings, experimentalSettings: ExperimentalUISettings, networkSettings: NetworkSettings?, hasLegacyAppData: Bool, useBetaFeatures: Bool) -> [DebugControllerEntry] {
1491+
private func debugControllerEntries(sharedContext: SharedAccountContext, presentationData: PresentationData, loggingSettings: LoggingSettings, mediaInputSettings: MediaInputSettings, experimentalSettings: ExperimentalUISettings, networkSettings: NetworkSettings?, hasLegacyAppData: Bool, useBetaFeatures: Bool) -> [DebugControllerEntry] {
14921492
var entries: [DebugControllerEntry] = []
14931493

14941494
let isMainApp = sharedContext.applicationBindings.isMainApp
@@ -1572,18 +1572,7 @@ private func debugControllerEntries(context: AccountContext?, sharedContext: Sha
15721572
entries.append(.playerV2(experimentalSettings.playerV2))
15731573

15741574
entries.append(.devRequests(experimentalSettings.devRequests))
1575-
1576-
if let data = context?.currentAppConfiguration.with({ $0 }).data {
1577-
var displayPwa = false
1578-
if let _ = data["ios_display_pwa"] {
1579-
displayPwa = true
1580-
} else if let isDev = data["dev"] as? Double, isDev == 1.0 {
1581-
displayPwa = true
1582-
}
1583-
if displayPwa {
1584-
entries.append(.pwa(experimentalSettings.enablePWA))
1585-
}
1586-
}
1575+
entries.append(.fakeAds(experimentalSettings.fakeAds))
15871576
entries.append(.enableLocalTranslation(experimentalSettings.enableLocalTranslation))
15881577
entries.append(.enableUpdates(experimentalSettings.enableUpdates))
15891578
}
@@ -1669,7 +1658,7 @@ public func debugController(sharedContext: SharedAccountContext, context: Accoun
16691658
}
16701659

16711660
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text("Debug"), leftNavigationButton: leftNavigationButton, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
1672-
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: debugControllerEntries(context: context, sharedContext: sharedContext, presentationData: presentationData, loggingSettings: loggingSettings, mediaInputSettings: mediaInputSettings, experimentalSettings: experimentalSettings, networkSettings: networkSettings, hasLegacyAppData: hasLegacyAppData, useBetaFeatures: useBetaFeatures), style: .blocks)
1661+
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: debugControllerEntries(sharedContext: sharedContext, presentationData: presentationData, loggingSettings: loggingSettings, mediaInputSettings: mediaInputSettings, experimentalSettings: experimentalSettings, networkSettings: networkSettings, hasLegacyAppData: hasLegacyAppData, useBetaFeatures: useBetaFeatures), style: .blocks)
16731662

16741663
return (controllerState, (listState, arguments))
16751664
}

submodules/TelegramCore/Sources/Network/FetchedMediaResource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ final class MediaReferenceRevalidationContext {
729729

730730
func attachBot(accountPeerId: PeerId, postbox: Postbox, network: Network, background: Bool, peer: PeerReference) -> Signal<AttachMenuBot, RevalidateMediaReferenceError> {
731731
return self.genericItem(key: .attachBot(peer: peer), background: background, request: { next, error in
732-
return (_internal_getAttachMenuBot(accountPeerId: accountPeerId, postbox: postbox, network: network, botId: peer.id, cached: false, allowManuallyCached: false)
732+
return (_internal_getAttachMenuBot(accountPeerId: accountPeerId, postbox: postbox, network: network, botId: peer.id, cached: false)
733733
|> mapError { _ -> RevalidateMediaReferenceError in
734734
return .generic
735735
}).start(next: { value in

submodules/TelegramCore/Sources/SyncCore/SyncCore_Namespaces.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ public struct Namespaces {
149149
public static let cachedChatThemes: Int8 = 50
150150
public static let cachedLiveStorySendAsPeers: Int8 = 51
151151
public static let cachedGiftUpgradesAttributes: Int8 = 52
152-
public static let manuallyCachedAttachMenuBots: Int8 = 53
153-
public static let cachedBotWebViews: Int8 = 54
154152
}
155153

156154
public struct UnorderedItemList {

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

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -283,51 +283,6 @@ private func removeCachedAttachMenuBot(postbox: Postbox, botId: PeerId) -> Signa
283283
}
284284
}
285285

286-
enum CachedAttachMenuBotResult {
287-
case empty
288-
case bot(AttachMenuBots.Bot)
289-
}
290-
291-
private func manuallyCachedAttachMenuBot(transaction: Transaction, peerId: PeerId) -> CachedAttachMenuBotResult? {
292-
let key = ValueBoxKey(length: 8)
293-
key.setInt64(0, value: peerId.toInt64())
294-
295-
if let entry = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.manuallyCachedAttachMenuBots, key: key)) {
296-
let cached = entry.get(AttachMenuBots.Bot.self)
297-
if let cached {
298-
return .bot(cached)
299-
} else if let _ = entry.get(EmptyAttachMenuBotMarker.self) {
300-
return .empty
301-
} else {
302-
return nil
303-
}
304-
} else {
305-
return nil
306-
}
307-
}
308-
309-
struct EmptyAttachMenuBotMarker: Codable {
310-
var trueValue: Bool
311-
}
312-
313-
private func setManuallyCachedAttachMenuBot(transaction: Transaction, peerId: PeerId, bot: AttachMenuBots.Bot?) {
314-
let key = ValueBoxKey(length: 8)
315-
key.setInt64(0, value: peerId.toInt64())
316-
317-
let entryId = ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.manuallyCachedAttachMenuBots, key: key)
318-
if let bot {
319-
if let entry = CodableEntry(bot) {
320-
transaction.putItemCacheEntry(id: entryId, entry: entry)
321-
} else {
322-
transaction.removeItemCacheEntry(id: entryId)
323-
}
324-
} else {
325-
if let entry = CodableEntry(EmptyAttachMenuBotMarker(trueValue: true)) {
326-
transaction.putItemCacheEntry(id: entryId, entry: entry)
327-
}
328-
}
329-
}
330-
331286
func managedSynchronizeAttachMenuBots(accountPeerId: PeerId, postbox: Postbox, network: Network, force: Bool = false) -> Signal<Void, NoError> {
332287
let poll = Signal<Void, NoError> { subscriber in
333288
let signal: Signal<Void, NoError> = cachedAttachMenuBots(postbox: postbox)
@@ -554,33 +509,19 @@ public enum GetAttachMenuBotError {
554509
case generic
555510
}
556511

557-
func _internal_getAttachMenuBot(accountPeerId: PeerId, postbox: Postbox, network: Network, botId: PeerId, cached: Bool, allowManuallyCached: Bool) -> Signal<AttachMenuBot, GetAttachMenuBotError> {
512+
func _internal_getAttachMenuBot(accountPeerId: PeerId, postbox: Postbox, network: Network, botId: PeerId, cached: Bool) -> Signal<AttachMenuBot, GetAttachMenuBotError> {
558513
return postbox.transaction { transaction -> Signal<AttachMenuBot, GetAttachMenuBotError> in
559514
if cached, let cachedBots = cachedAttachMenuBots(transaction: transaction)?.bots {
560515
if let bot = cachedBots.first(where: { $0.peerId == botId }), let peer = transaction.getPeer(bot.peerId) {
561516
return .single(AttachMenuBot(peer: EnginePeer(peer), shortName: bot.name, icons: bot.icons, peerTypes: bot.peerTypes, flags: bot.flags))
562517
}
563518
}
564-
if allowManuallyCached, let bot = manuallyCachedAttachMenuBot(transaction: transaction, peerId: botId) {
565-
switch bot {
566-
case let .bot(bot):
567-
if let peer = transaction.getPeer(bot.peerId) {
568-
return .single(AttachMenuBot(peer: EnginePeer(peer), shortName: bot.name, icons: bot.icons, peerTypes: bot.peerTypes, flags: bot.flags))
569-
}
570-
case .empty:
571-
return .fail(.generic)
572-
}
573-
}
574519

575520
guard let peer = transaction.getPeer(botId), let inputUser = apiInputUser(peer) else {
576521
return .complete()
577522
}
578523
return network.request(Api.functions.messages.getAttachMenuBot(bot: inputUser))
579524
|> mapError { _ -> GetAttachMenuBotError in
580-
let _ = postbox.transaction({ transaction -> Void in
581-
setManuallyCachedAttachMenuBot(transaction: transaction, peerId: peer.id, bot: nil)
582-
}).startStandalone()
583-
584525
return .generic
585526
}
586527
|> mapToSignal { result -> Signal<AttachMenuBot, GetAttachMenuBotError> in
@@ -645,15 +586,6 @@ func _internal_getAttachMenuBot(accountPeerId: PeerId, postbox: Postbox, network
645586
if (apiFlags & (1 << 5)) != 0 {
646587
flags.insert(.showInSettingsDisclaimer)
647588
}
648-
649-
setManuallyCachedAttachMenuBot(transaction: transaction, peerId: peer.id, bot: AttachMenuBots.Bot(
650-
peerId: peer.id,
651-
name: name,
652-
icons: icons,
653-
peerTypes: peerTypes,
654-
flags: flags
655-
))
656-
657589
return .single(AttachMenuBot(peer: EnginePeer(peer), shortName: name, icons: icons, peerTypes: peerTypes, flags: flags))
658590
}
659591
}

0 commit comments

Comments
 (0)