From 6791b445a7b7dfb0f7215bca71cbe4797020ce8b Mon Sep 17 00:00:00 2001 From: Denis Shilovich Date: Tue, 21 Jan 2025 07:16:25 +0000 Subject: [PATCH] 1.9.5 (426) --- MODULE.bazel.lock | 12 +- Nicegram/NGData/Sources/NGSettings.swift | 4 - Nicegram/NGLab/Sources/RegDate.swift | 38 ------ Nicegram/NGPersonality/BUILD | 22 ---- .../Sources/CollectActiveHours.swift | 32 ----- .../Sources/CollectContactsActivity.swift | 17 --- .../Sources/CollectDailyActivity.swift | 15 --- .../Sources/CollectGhostScore.swift | 37 ------ .../Sources/CollectInfluencerScore.swift | 124 ------------------ .../Sources/CollectMessagesActivity.swift | 108 --------------- .../CollectPersonalityProviderImpl.swift | 102 -------------- Nicegram/NGUtils/BUILD | 1 + .../Sources/AttUserActionsHelper.swift | 41 ++++++ .../Sources/TelegramThemeMapping.swift | 19 +++ Nicegram/NGUtils/Sources/WalletUtils.swift | 40 ++++-- Package.resolved | 12 +- Package.swift | 4 +- .../ar.lproj/NiceLocalizable.strings | 5 +- .../de.lproj/NiceLocalizable.strings | 2 + .../en.lproj/NiceLocalizable.strings | 3 +- .../es.lproj/NiceLocalizable.strings | 2 + .../fr.lproj/NiceLocalizable.strings | 2 + .../it.lproj/NiceLocalizable.strings | 5 +- .../ko.lproj/NiceLocalizable.strings | 6 +- .../pl.lproj/NiceLocalizable.strings | 2 + .../pt.lproj/NiceLocalizable.strings | 2 + .../ru.lproj/NiceLocalizable.strings | 2 + .../tr.lproj/NiceLocalizable.strings | 5 +- .../zh-hans.lproj/NiceLocalizable.strings | 2 + .../zh-hant.lproj/NiceLocalizable.strings | 4 +- submodules/DebugSettingsUI/BUILD | 2 +- submodules/GalleryUI/BUILD | 1 - .../Items/UniversalVideoGalleryItem.swift | 12 +- .../Source/Signal_SwiftCombine.swift | 18 --- .../Sources/CallControllerNodeV2.swift | 7 +- .../PendingMessages/EnqueueMessage.swift | 13 ++ .../Contacts/ContactManagement.swift | 2 +- submodules/TelegramUI/BUILD | 1 - .../Sources/ChatHistoryEntry.swift | 6 + .../Components/Chat/ChatMessageItemImpl/BUILD | 1 + .../Sources/NicegramHelpers.swift | 46 +++++++ .../Sources/ChatMessageNicegramAdNode.swift | 26 +--- .../ChatMessageNicegramWalletTxNode/BUILD | 25 ++++ .../ChatMessageNicegramWalletTxItem.swift | 64 +++++++++ .../ChatMessageNicegramWalletTxNode.swift | 98 ++++++++++++++ .../Components/PeerInfo/PeerInfoScreen/BUILD | 1 + .../ListItems/PeerInfoScreenWalletItem.swift | 67 ++++++++++ .../Sources/PeerInfoScreen.swift | 14 ++ .../TelegramUI/Sources/AppDelegate.swift | 60 ++------- .../Chat/ChatControllerLoadDisplayNode.swift | 21 ++- ...ChatControllerOpenMessageContextMenu.swift | 13 ++ .../TelegramUI/Sources/ChatController.swift | 23 ++++ .../Sources/ChatControllerNode.swift | 12 +- .../Sources/ChatHistoryListNode.swift | 36 ++++- .../Sources/Nicegram/NGDeeplinkHandler.swift | 12 -- .../NicegramMapChatHistoryEntries.swift | 19 +++ .../Wallet/ContactsRetrieverImpl.swift | 6 +- 57 files changed, 597 insertions(+), 679 deletions(-) delete mode 100644 Nicegram/NGPersonality/BUILD delete mode 100644 Nicegram/NGPersonality/Sources/CollectActiveHours.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectContactsActivity.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectDailyActivity.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectGhostScore.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectInfluencerScore.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectMessagesActivity.swift delete mode 100644 Nicegram/NGPersonality/Sources/CollectPersonalityProviderImpl.swift create mode 100644 Nicegram/NGUtils/Sources/AttUserActionsHelper.swift create mode 100644 Nicegram/NGUtils/Sources/TelegramThemeMapping.swift create mode 100644 submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/NicegramHelpers.swift create mode 100644 submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/BUILD create mode 100644 submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxItem.swift create mode 100644 submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxNode.swift create mode 100644 submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenWalletItem.swift diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 1c6aa3c0a3b..427b0e808f6 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -633,8 +633,8 @@ "bzlTransitiveDigest": "8/YWyYftd8THfVoADvrOmQLl45wUGfP2MVjLM5FFn50=", "usagesDigest": "voXBMcSNlo2fnK6JIvInIrncYhBKKG8nBeKvToaUA0Y=", "recordedFileInputs": { - "@@//Package.resolved": "0a9227f8ff163593786caf74e9b66bc91525f0d4e09a61de2bfcb7e844dd6889", - "@@//Package.swift": "9696be545e5e35e7ca27cb12df2537c71dd74d8e30c3ce548220ad63d293afaf" + "@@//Package.resolved": "f59b0cc1e27e57bf358405fd2599f9ba0220c488e99307e77e5604714067a91c", + "@@//Package.swift": "676d7b30e2702b0736b91d68d1b802024126594a48575260feeb6e297c0984b8" }, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1138,7 +1138,7 @@ "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_nicegram_assistant_ios", - "commit": "6a3a0634dc2f8174de1245a9a18227f78472c94f", + "commit": "e1d7fa102de1973d5a7c0c82b4b9785ee44cfd83", "remote": "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", "version": "", "init_submodules": false, @@ -1328,9 +1328,9 @@ "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_wallet_core", - "commit": "23ae9525ed3bd28a010d6cdd78e39955b1b2cdef", + "commit": "d631d5b498e6bb44e923cf12366c945ee9b864d5", "remote": "https://github.com/trustwallet/wallet-core.git", - "version": "4.2.3", + "version": "4.2.0", "init_submodules": false, "recursive_init_submodules": true, "patch_args": [ @@ -1404,7 +1404,7 @@ "ruleClassName": "swift_package", "attributes": { "bazel_package_name": "swiftpkg_nicegram_wallet_ios", - "commit": "0814446b00d6c35271e38ae798eeaf8c871d74cf", + "commit": "e2f5a6b002697c32e672f07eba14e3cc8a046dbe", "remote": "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", "version": "", "init_submodules": false, diff --git a/Nicegram/NGData/Sources/NGSettings.swift b/Nicegram/NGData/Sources/NGSettings.swift index 017419e3fdd..0d27ce1904a 100644 --- a/Nicegram/NGData/Sources/NGSettings.swift +++ b/Nicegram/NGData/Sources/NGSettings.swift @@ -185,9 +185,6 @@ public func checkPremium(completion: @escaping (Bool) -> Void) { } public func isPremium() -> Bool { -#if DEBUG - return true -#else if #available(iOS 13.0, *) { return PremiumContainer.shared .getPremiumStatusUseCase() @@ -195,7 +192,6 @@ public func isPremium() -> Bool { } else { return false } -#endif } public func usetrButton() -> [(Bool, [String])] { diff --git a/Nicegram/NGLab/Sources/RegDate.swift b/Nicegram/NGLab/Sources/RegDate.swift index ba4de231f3d..7513e274747 100644 --- a/Nicegram/NGLab/Sources/RegDate.swift +++ b/Nicegram/NGLab/Sources/RegDate.swift @@ -142,44 +142,6 @@ public func makeNiceRegDateStr(_ date: String) -> String { } } -public func getDaysFromRegDate(with id: Int64) -> Signal { - if let dateString = getCachedRegDate(id) { - return .single(days(from: dateString)) - } else { - return getRegDate(id) - .skipError() - |> map { dateString in - days(from: dateString) - } - } -} - -private func days(from dateString: String, to: Date = Date()) -> Int? { - let monthDateFormatter = DateFormatter() - monthDateFormatter.dateFormat = "yyyy-MM" - - let dayDateFormatter = DateFormatter() - dayDateFormatter.dateFormat = "yyyy-MM-dd" - - var convertDateFormatter = DateFormatter() - - var date: Date? - if let monthDate = monthDateFormatter.date(from: dateString) { - date = monthDate - } else if let dayDate = dayDateFormatter.date(from: dateString) { - date = dayDate - } - - if let date { - let calendar = Calendar.current - let components = calendar.dateComponents([.day], from: date, to: to) - if let days = components.day { - return days - } - } - - return nil -} public func resetRegDateCache() -> Void { UserDefaults.standard.removePersistentDomain(forName: "CachedRegDate") diff --git a/Nicegram/NGPersonality/BUILD b/Nicegram/NGPersonality/BUILD deleted file mode 100644 index f9aa1dd7a5a..00000000000 --- a/Nicegram/NGPersonality/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") - -swift_library( - name = "NGPersonality", - module_name = "NGPersonality", - srcs = glob([ - "Sources/**/*.swift", - ]), - deps = [ - "//submodules/TelegramCore:TelegramCore", - "//submodules/TelegramApi:TelegramApi", - "//submodules/AccountContext:AccountContext", - "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", - "//submodules/AvatarNode:AvatarNode", - "//Nicegram/NGUtils:NGUtils", - "//Nicegram/NGLab:NGLab", - "@swiftpkg_nicegram_assistant_ios//:FeatPersonality" - ], - visibility = [ - "//visibility:public", - ], -) diff --git a/Nicegram/NGPersonality/Sources/CollectActiveHours.swift b/Nicegram/NGPersonality/Sources/CollectActiveHours.swift deleted file mode 100644 index 7a1e7a5a297..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectActiveHours.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Foundation -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectActiveHoursUseCase = container.collectActiveHoursUseCase() - -public func collectMessageActivity(with userId: Int64) { - guard checkPreferencesStateUseCase(with: userId, personality: .activeHours([])) else { return } - - Task { - await collectActiveHoursUseCase.collectMessageActivity(with: userId) - } -} - -public func collectScrollActivity(with userId: Int64) { - guard checkPreferencesStateUseCase(with: userId, personality: .activeHours([])) else { return } - - collectActiveHoursUseCase.collectScrollActivity(with: userId) -} - -public func collectCallActivity(with userId: Int64) { - guard checkPreferencesStateUseCase(with: userId, personality: .activeHours([])) else { return } - - collectActiveHoursUseCase.collectCallActivity(with: userId) -} - -public func collectVideoActivity(with userId: Int64) { - guard checkPreferencesStateUseCase(with: userId, personality: .activeHours([])) else { return } - - collectActiveHoursUseCase.collectVideoActivity(with: userId) -} diff --git a/Nicegram/NGPersonality/Sources/CollectContactsActivity.swift b/Nicegram/NGPersonality/Sources/CollectContactsActivity.swift deleted file mode 100644 index d5da55858a7..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectContactsActivity.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Foundation -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectContactsActivityUseCase = container.collectContactsActivityUseCase() - -public func collectContactsActivity( - with userId: Int64, - count: Int -) { - guard checkPreferencesStateUseCase(with: userId, personality: .contactsActivity(.empty)) else { return } - - Task { - await collectContactsActivityUseCase(with: userId, count: count) - } -} diff --git a/Nicegram/NGPersonality/Sources/CollectDailyActivity.swift b/Nicegram/NGPersonality/Sources/CollectDailyActivity.swift deleted file mode 100644 index f2843ca240d..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectDailyActivity.swift +++ /dev/null @@ -1,15 +0,0 @@ -import UIKit -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectDailyActivityUseCases = container.collectDailyActivityUseCases() - -public func collectDailyActivity( - with userId: Int64, - notificationName: NSNotification.Name -) async { - guard checkPreferencesStateUseCase(with: userId, personality: .dailyActivity(.empty)) else { return } - - await collectDailyActivityUseCases(with: userId, notificationName: notificationName) -} diff --git a/Nicegram/NGPersonality/Sources/CollectGhostScore.swift b/Nicegram/NGPersonality/Sources/CollectGhostScore.swift deleted file mode 100644 index a214611a081..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectGhostScore.swift +++ /dev/null @@ -1,37 +0,0 @@ -import TelegramApi -import TelegramCore -import AccountContext -import SwiftSignalKit -import Network -import MtProtoKit -import Postbox -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkCollectStateUseCase = container.checkCollectStateUseCase() -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectGhostScoreUseCase = container.collectGhostScoreUseCase() - -public func collectGhostScore( - with context: AccountContext -) async { - let id = context.account.peerId.toInt64() - guard checkPreferencesStateUseCase(with: id, personality: .ghostScore(.empty)) else { return } - guard checkCollectStateUseCase(with: id, personality: .ghostScore(.empty)) else { return } - - let count = await withCheckedContinuation { continuation in - _ = context.account.postbox.transaction { transaction -> ChatListTotalUnreadState in - transaction.getTotalUnreadState(groupId: .root) - } - .start { state in - let count = state.count(for: .filtered, in: .messages, with: .contact) - - continuation.resume(returning: count) - } - } - - await collectGhostScoreUseCase( - with: context.account.peerId.toInt64(), - count: count - ) -} diff --git a/Nicegram/NGPersonality/Sources/CollectInfluencerScore.swift b/Nicegram/NGPersonality/Sources/CollectInfluencerScore.swift deleted file mode 100644 index 75c8c19ec80..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectInfluencerScore.swift +++ /dev/null @@ -1,124 +0,0 @@ -import TelegramApi -import TelegramCore -import AccountContext -import SwiftSignalKit -import Network -import MtProtoKit -import Postbox -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkCollectStateUseCase = container.checkCollectStateUseCase() -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectInfluencerScoreUseCase = container.collectInfluencerScoreUseCase() - -public func collectInfluencerScore( - with context: AccountContext -) async { - let id = context.account.peerId.toInt64() - guard checkPreferencesStateUseCase(with: id, personality: .influencerScore(.empty)) else { return } - guard checkCollectStateUseCase(with: id, personality: .influencerScore(.empty)) else { return } - - let result = await withCheckedContinuation { continuation in - _ = influencerScore(with: context) - .start(next: { result in - continuation.resume(returning: result) - }) - } - - await collectInfluencerScoreUseCase( - with: context.account.peerId.toInt64(), - ownerChannelCount: result.0, - ownerChannelParticipantsCount: result.1, - ownerGroupCount: result.2, - ownerGroupParticipantsCount: result.3, - groupCount: result.4, - groupParticipantsCount: result.5 - ) -} - -private func influencerScore( - with context: AccountContext -) -> Signal<(Int32, Int32, Int32, Int32, Int32, Int32), NoError> { - dialogs(with: context) - |> map { dialogs -> [(PeerId.Namespace, Bool, Int32)] in - switch dialogs { - case let .dialogs(_, _, chats, _): - return chats.compactMap { information(from: $0) } - case let .dialogsSlice(_, _, _, chats, _): - return chats.compactMap { information(from: $0) } - default: return [] - } - } - |> map { chats -> (Int32, Int32, Int32, Int32, Int32, Int32) in - var ownerChannelCount: Int32 = 0 - var ownerChannelParticipantsCount: Int32 = 0 - var ownerGroupCount: Int32 = 0 - var ownerGroupParticipantsCount: Int32 = 0 - - var groupCount: Int32 = 0 - var groupParticipantsCount: Int32 = 0 - - chats.forEach { chat in - if chat.0 == Namespaces.Peer.CloudChannel { - if chat.1 { - ownerChannelCount += 1 - ownerChannelParticipantsCount += chat.2 - } - } else if chat.0 == Namespaces.Peer.CloudGroup { - if chat.1 { - ownerGroupCount += 1 - ownerGroupParticipantsCount += chat.2 - } - groupCount += 1 - groupParticipantsCount += chat.2 - } - } - - return ( - ownerChannelCount, - ownerChannelParticipantsCount, - ownerGroupCount, - ownerGroupParticipantsCount, - groupCount, - groupParticipantsCount - ) - } -} - -private func dialogs( - with context: AccountContext -) -> Signal { - context.account.network.request(Api.functions.messages.getDialogs( - flags: 0, - folderId: nil, - offsetDate: 0, - offsetId: 0, - offsetPeer: .inputPeerSelf, - limit: .max, - hash: 0 - )) - |> map(Optional.init) - |> `catch` { error -> Signal in - return .single(nil) - } -} - -private func information(from chat: Api.Chat) -> (PeerId.Namespace, Bool, Int32)? { - switch chat { - case let .chat(flags, _, _, _, participantsCount, _, _, _, _, _): - let isCreator = (flags & (1 << 0)) != 0 - return (Namespaces.Peer.CloudGroup, isCreator, participantsCount) - case let .channel(flags, _, _, _, _, _, _, _, _, _, _, _, participantsCount, _, _, _, _, _, _, _, _): - let isCreator = (flags & (1 << 0)) != 0 - - var type = Namespaces.Peer.CloudChannel - if (flags & Int32(1 << 8)) != 0 { - type = Namespaces.Peer.CloudGroup - } - - return (type, isCreator, participantsCount ?? 0) - case .chatEmpty, .chatForbidden, .channelForbidden: - return nil - } -} diff --git a/Nicegram/NGPersonality/Sources/CollectMessagesActivity.swift b/Nicegram/NGPersonality/Sources/CollectMessagesActivity.swift deleted file mode 100644 index 6050b39f321..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectMessagesActivity.swift +++ /dev/null @@ -1,108 +0,0 @@ -import TelegramApi -import TelegramCore -import AccountContext -import SwiftSignalKit -import Network -import MtProtoKit -import Postbox -import FeatPersonality - -private let container = PersonalityContainer.shared -private let checkCollectStateUseCase = container.checkCollectStateUseCase() -private let checkPreferencesStateUseCase = container.checkPreferencesStateUseCase() -private let collectMessagesActivityUseCase = container.collectMessagesActivityUseCase() - -public func collectMessagesActivity( - with context: AccountContext -) async { - let id = context.account.peerId.toInt64() - guard checkPreferencesStateUseCase(with: id, personality: .messagesActivity(.empty)) else { return } - guard checkCollectStateUseCase(with: id, personality: .messagesActivity(.empty)) else { return } - - let result = await withCheckedContinuation { continuation in - _ = combineLatest( - searchGlobal(with: context), - search(with: context) - ) - .start { all, user in - var allCount: Int32 = 0 - var userCount: Int32 = 0 - - switch all { - case let .channelMessages(_, _, count, _, _, _, _, _): - allCount = count - case let .messagesSlice(_, count, _, _, _, _, _): - allCount = count - default: break - } - switch user { - case let .channelMessages(_, _, count, _, _, _, _, _): - userCount = count - case let .messagesSlice(_, count, _, _, _, _, _): - userCount = count - default: break - } - - continuation.resume(returning: (allCount, userCount)) - } - } - - await collectMessagesActivityUseCase( - with: context.account.peerId.toInt64(), - allMessagesCount: result.0, - userMessagesCount: result.1 - ) -} - -// limit = 0, return only count without messages -func search( - with context: AccountContext, - peer: Api.InputPeer = .inputPeerEmpty, - from: Api.InputPeer = .inputPeerSelf, - limit: Int32 = 0 -) -> Signal { - context.account.network.request(Api.functions.messages.search( - flags: 0, - peer: peer, - q: "", - fromId: from, - savedPeerId: nil, - savedReaction: nil, - topMsgId: nil, - filter: .inputMessagesFilterEmpty, - minDate: 0, - maxDate: 0, - offsetId: 0, - addOffset: 0, - limit: limit, - maxId: 0, - minId: 0, - hash: 0 - )) - |> map(Optional.init) - |> `catch` { error -> Signal in - return .single(nil) - } -} - -private func searchGlobal( - with context: AccountContext, - limit: Int32 = 0 -) -> Signal { - context.account.network.request(Api.functions.messages.searchGlobal( - flags: 0, - folderId: nil, - q: "", - filter: .inputMessagesFilterEmpty, - minDate: 0, - maxDate: 0, - offsetRate: 0, - offsetPeer: .inputPeerEmpty, - offsetId: 0, - limit: limit - )) - |> map(Optional.init) - |> `catch` { error -> Signal in - return .single(nil) - } -} diff --git a/Nicegram/NGPersonality/Sources/CollectPersonalityProviderImpl.swift b/Nicegram/NGPersonality/Sources/CollectPersonalityProviderImpl.swift deleted file mode 100644 index 8614265786e..00000000000 --- a/Nicegram/NGPersonality/Sources/CollectPersonalityProviderImpl.swift +++ /dev/null @@ -1,102 +0,0 @@ -import MemberwiseInit -import NGCore -import Postbox -import SwiftSignalKit -import TelegramCore -import TelegramBridge -import TelegramCore -import NGUtils -import NGLab -import UIKit -import AccountContext -import AvatarNode -import FeatPersonality - -public final class PersonalityProviderImpl { - private let contextProvider: ContextProvider - - public init(contextProvider: ContextProvider) { - self.contextProvider = contextProvider - } -} - -extension PersonalityProviderImpl: PersonalityProvider { - public func loadInformation() async -> PersonalityInformation { - do { - let context = try contextProvider.context().unwrap() - - let presentationData = context.sharedContext.currentPresentationData.with { $0 } - - let result = try await loadUserInformation(with: context).awaitForFirstValue() - - return PersonalityInformation( - id: result.0, - displayName: result.1, - avatar: result.2, - daysFromCreation: result.3, - overallDarkAppearance: presentationData.theme.overallDarkAppearance - ) - } catch { - return PersonalityInformation(id: 0) - } - } - - public func collect(with id: Int64) async { - do { - let context = try contextProvider.context().unwrap() - - try await context.account.postbox.transaction { transaction in - let contactPeerIds = transaction.getContactPeerIds() - - collectContactsActivity(with: id, count: contactPeerIds.count) - }.awaitForFirstValue() - - await collectDailyActivity( - with: id, - notificationName: UIApplication.didBecomeActiveNotification - ) - await collectGhostScore(with: context) - await collectInfluencerScore(with: context) - await collectMessagesActivity(with: context) - } catch {} - } -} - -private extension PersonalityProviderImpl { - func loadUserInformation(with context: AccountContext) -> Signal<(Int64, String?, UIImage?, Int?), NoError> { - return context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)) - |> mapToSignal { peer -> Signal<(Int64, String?, UIImage?, Int?), NoError> in - if case let .user(user) = peer { - return peerAvatarCompleteImage( - account: context.account, - peer: EnginePeer(user), - forceProvidedRepresentation: false, - representation: nil, - size: CGSize(width: 50, height: 50) - ) - |> mapToSignal { image -> Signal<(Int64, String?, UIImage?, Int?), NoError> in - getDaysFromRegDate(with: user.id.toInt64()) - |> map { days -> (Int64, String?, UIImage?, Int?) in - var displayName = user.username - let firstName = user.firstName - let lastName = user.lastName - - if let firstName, - let lastName, - !firstName.isEmpty && - !lastName.isEmpty { - displayName = "\(firstName) \(lastName)" - } else if let firstName, - !firstName.isEmpty { - displayName = firstName - } - - return (user.id.toInt64() , displayName?.capitalized, image, days) - } - } - } - - return .single((0, nil, nil, nil)) - } - } -} diff --git a/Nicegram/NGUtils/BUILD b/Nicegram/NGUtils/BUILD index 5e44b5faf3e..5393040e426 100644 --- a/Nicegram/NGUtils/BUILD +++ b/Nicegram/NGUtils/BUILD @@ -9,6 +9,7 @@ swift_library( deps = [ "//submodules/AccountContext:AccountContext", "@FirebaseSDK//:FirebaseAnalytics", + "@swiftpkg_nicegram_assistant_ios//:FeatAttentionEconomy", "@swiftpkg_nicegram_assistant_ios//:NGAnalytics", "@swiftpkg_nicegram_wallet_ios//:NicegramWallet", ], diff --git a/Nicegram/NGUtils/Sources/AttUserActionsHelper.swift b/Nicegram/NGUtils/Sources/AttUserActionsHelper.swift new file mode 100644 index 00000000000..c126e8d5a1c --- /dev/null +++ b/Nicegram/NGUtils/Sources/AttUserActionsHelper.swift @@ -0,0 +1,41 @@ +import FeatAttentionEconomy +import Foundation +import Postbox +import TelegramCore + +public struct AttUserActionsHelper { + private static let saveUserActionUseCase = AttUserActionsModule.shared.saveUserActionUseCase() + + public static func save( + peerId: PeerId?, + type: AttUserActionType, + userId: PeerId? + ) { + guard let peerId, let userId else { + return + } + + guard peerId.isChannelOrGroup() else { + return + } + + Task { + await saveUserActionUseCase( + AttUserAction( + id: UUID().uuidString, + chatId: peerId.ng_toInt64(), + timestamp: Int64(Date().timeIntervalSince1970), + type: type, + userId: userId.ng_toInt64() + ) + ) + } + } +} + +private extension PeerId { + func isChannelOrGroup() -> Bool { + namespace == Namespaces.Peer.CloudChannel || + namespace == Namespaces.Peer.CloudGroup + } +} diff --git a/Nicegram/NGUtils/Sources/TelegramThemeMapping.swift b/Nicegram/NGUtils/Sources/TelegramThemeMapping.swift new file mode 100644 index 00000000000..e9f515a4732 --- /dev/null +++ b/Nicegram/NGUtils/Sources/TelegramThemeMapping.swift @@ -0,0 +1,19 @@ +import NicegramWallet +import TelegramPresentationData + +public extension WalletTelegramTheme { + init(_ theme: PresentationTheme) { + let list = theme.list + self.init( + list: .init( + itemAccentColor: list.itemAccentColor, + itemBlocksBackgroundColor: list.itemBlocksBackgroundColor, + itemPrimaryTextColor: list.itemPrimaryTextColor + ) + ) + } + + init(_ presentationData: PresentationData) { + self.init(presentationData.theme) + } +} diff --git a/Nicegram/NGUtils/Sources/WalletUtils.swift b/Nicegram/NGUtils/Sources/WalletUtils.swift index b0006354422..9ff19306021 100644 --- a/Nicegram/NGUtils/Sources/WalletUtils.swift +++ b/Nicegram/NGUtils/Sources/WalletUtils.swift @@ -20,30 +20,46 @@ public extension WalletTgUtils { } static func peerToWalletContact( - peer: EnginePeer - ) -> WalletContact { + id: PeerId, + context: AccountContext + ) async -> WalletContact? { + if let peer = await peerById(id, context: context) { + WalletContact(peer) + } else { + nil + } + } +} + +public extension WalletContact { + init(_ peer: EnginePeer) { let username: String if let addressName = peer.addressName, !addressName.isEmpty { username = "@\(addressName)" } else { username = "" } + + let canSendMessage = canSendMessagesToPeer(peer._asPeer()) + + var canInviteToWallet = false + if case let .user(user) = peer, user.botInfo == nil { + canInviteToWallet = true + } + if !canSendMessage { + canInviteToWallet = false + } - return WalletContact( + self.init( id: .init(peer.id), + canInviteToWallet: canInviteToWallet, + canSendMessage: canSendMessage, name: peer.compactDisplayTitle, username: username ) } - static func peerToWalletContact( - id: PeerId, - context: AccountContext - ) async -> WalletContact? { - if let peer = await peerById(id, context: context) { - peerToWalletContact(peer: peer) - } else { - nil - } + init(_ peer: Peer) { + self.init(EnginePeer(peer)) } } diff --git a/Package.resolved b/Package.resolved index 3519f6b217e..23ee7f10908 100644 --- a/Package.resolved +++ b/Package.resolved @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", "state" : { - "branch" : "feat/NCG-6903_personality", - "revision" : "6a3a0634dc2f8174de1245a9a18227f78472c94f" + "branch" : "feat/tx-message-view", + "revision" : "fc843f86a2efb1a6d06c3ef87f8530ca9b1b7aa2" } }, { @@ -122,8 +122,8 @@ "kind" : "remoteSourceControl", "location" : "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", "state" : { - "branch" : "develop", - "revision" : "0814446b00d6c35271e38ae798eeaf8c871d74cf" + "branch" : "feat/tx-message-view", + "revision" : "1345e3328b2f5317d8a2ac9d21259c1177274cbf" } }, { @@ -356,8 +356,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/trustwallet/wallet-core.git", "state" : { - "revision" : "23ae9525ed3bd28a010d6cdd78e39955b1b2cdef", - "version" : "4.2.3" + "revision" : "ed9152aa17a5ab2f6b9ecd015ac2c334a6888791", + "version" : "4.2.2" } }, { diff --git a/Package.swift b/Package.swift index e36382e0b36..9f811cadc58 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "nicegram-package", dependencies: [ - .package(url: "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", branch: "feat/NCG-6903_personality"), - .package(url: "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", branch: "develop") + .package(url: "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", branch: "feat/tx-message-view"), + .package(url: "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", branch: "feat/tx-message-view") ] ) diff --git a/Telegram/Telegram-iOS/ar.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/ar.lproj/NiceLocalizable.strings index ac0bd28f407..6efce313484 100644 --- a/Telegram/Telegram-iOS/ar.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/ar.lproj/NiceLocalizable.strings @@ -1,10 +1,12 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "عرض تقرير CertiK"; +"Wallet" = "المحفظة"; /*Common*/ "Nicegram.PrivacyPolicy" = "سياسة الخصوصية"; -"Nicegram.EULA" = "اتفاقية ترخيص المستخدم النهائي\n"; +"Nicegram.EULA" = "اتفاقية ترخيص المستخدم النهائي +"; /*ChatFilter*/ "ChatFilter.Bots" = "بوتات"; @@ -168,6 +170,7 @@ "NicegramSettings.EnableGrayscaleAll" = "الشاشة كاملة بالأبيض والأسود"; "NicegramSettings.EnableGrayscaleInChatList" = "الرمادي في قائمة الدردشة"; "NicegramSettings.EnableGrayscaleInChat" = "الرمادي في الدردشة"; +"NicegramSettings.EnableAppleSpeech2Text" = "تفعيل Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "أقدم من"; diff --git a/Telegram/Telegram-iOS/de.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/de.lproj/NiceLocalizable.strings index 92ff5ef80cc..9e647812c95 100644 --- a/Telegram/Telegram-iOS/de.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/de.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "CertiK-Bericht einsehen"; +"Wallet" = "Wallet"; /*Common*/ "Nicegram.PrivacyPolicy" = "Datenschutzbestimmungen"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Vollbild-Graustufen"; "NicegramSettings.EnableGrayscaleInChatList" = "Graustufen in der Chatliste"; "NicegramSettings.EnableGrayscaleInChat" = "Graustufen im Chat"; +"NicegramSettings.EnableAppleSpeech2Text" = "Apple Speech2Text aktivieren"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Älter als"; diff --git a/Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings index 054f0b99e9f..8b598ce47d5 100644 --- a/Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "View CertiK Report"; +"Wallet" = "Wallet"; /*Common*/ "Nicegram.PrivacyPolicy" = "Privacy policy"; @@ -207,7 +208,7 @@ /*Hidden Chats*/ "ChatContextMenu.Hide" = "Hide"; "ChatContextMenu.Unhide" = "Unhide"; -"HiddenChatsTooltip" = "Press and hold the 'N' logo to reveal hidden secret chats"; +"HiddenChatsTooltip" = "Press and hold this button to reveal hidden secret chats"; /*Data Sharing*/ "NicegramSettings.ShareBotsToggle" = "Share bots information"; diff --git a/Telegram/Telegram-iOS/es.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/es.lproj/NiceLocalizable.strings index e1f9e182115..39efec99400 100644 --- a/Telegram/Telegram-iOS/es.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/es.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Ver informe de CertiK"; +"Wallet" = "Billetera"; /*Common*/ "Nicegram.PrivacyPolicy" = "Política de privacidad"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Escala de grises en pantalla completa"; "NicegramSettings.EnableGrayscaleInChatList" = "Escala de grises en la lista de chat"; "NicegramSettings.EnableGrayscaleInChat" = "Escala de grises en el chat"; +"NicegramSettings.EnableAppleSpeech2Text" = "Activar Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Mayor que"; diff --git a/Telegram/Telegram-iOS/fr.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/fr.lproj/NiceLocalizable.strings index 31d33780612..599c8349816 100644 --- a/Telegram/Telegram-iOS/fr.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/fr.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Voir le rapport CertiK"; +"Wallet" = "Portefeuille"; /*Common*/ "Nicegram.PrivacyPolicy" = "Politique de confidentialité"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Écran complet en niveaux de gris"; "NicegramSettings.EnableGrayscaleInChatList" = "Niveaux de gris dans la liste de chat"; "NicegramSettings.EnableGrayscaleInChat" = "Gris dans le chat"; +"NicegramSettings.EnableAppleSpeech2Text" = "Activer Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Plus vieux que"; diff --git a/Telegram/Telegram-iOS/it.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/it.lproj/NiceLocalizable.strings index 374891a9477..4d3427e52a0 100644 --- a/Telegram/Telegram-iOS/it.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/it.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Visualizza il rapporto CertiK"; +"Wallet" = "Portafoglio"; /*Common*/ "Nicegram.PrivacyPolicy" = "Informativa sulla privacy"; @@ -70,7 +71,8 @@ "NiceFeatures.Use.DataStorage" = "Per favore, usa «%1» per configurare il tuo browser predefinito"; "NiceFeatures.Browser.Header" = "URL"; "NiceFeatures.Browser.UseBrowser" = "Apri link nel browser"; -"NiceFeatures.Browser.UseBrowserNotice" = "Nicegram aprirà i link in un browser esterno invece di farlo nell'app.\nIl browser selezionato deve essere installato."; +"NiceFeatures.Browser.UseBrowserNotice" = "Nicegram aprirà i link in un browser esterno invece di farlo nell'app. +Il browser selezionato deve essere installato."; "ChatFilter.Missed" = "Mancati"; /*Premium*/ @@ -168,6 +170,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Grigio scala a schermo intero"; "NicegramSettings.EnableGrayscaleInChatList" = "Scala di grigi nella lista chat"; "NicegramSettings.EnableGrayscaleInChat" = "In scala di grigi nella chat"; +"NicegramSettings.EnableAppleSpeech2Text" = "Attiva Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Più vecchio di"; diff --git a/Telegram/Telegram-iOS/ko.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/ko.lproj/NiceLocalizable.strings index d6ab52531bf..dcc0e6dfae8 100644 --- a/Telegram/Telegram-iOS/ko.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/ko.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "CertiK 보고서 보기"; +"Wallet" = "지갑"; /*Common*/ "Nicegram.PrivacyPolicy" = "개인 정보 보호정책"; @@ -108,7 +109,9 @@ "Messages.Translate" = "번역"; "Messages.UndoTranslate" = "번역 취소"; "Messages.TranslateError" = "죄송합니다. 번역 할 수 없습니다."; -"Messages.SelectAllFromUser" = "이 사용자에게서 온 모든 메시지 선택 \n\n"; +"Messages.SelectAllFromUser" = "이 사용자에게서 온 모든 메시지 선택 + +"; "Messages.ToLanguage" = "언어"; "Messages.ToLanguage.WithCode" = "언어: %@"; "Messages.TranslateError.ToLanguageNotFound" = "텍스트를 번역할 언어를 결정할 수 없습니다. 수동으로 선택하고 다시 시도하십시오."; @@ -168,6 +171,7 @@ "NicegramSettings.EnableGrayscaleAll" = "전체 화면 흑백"; "NicegramSettings.EnableGrayscaleInChatList" = "채팅 목록의 그레이스케일"; "NicegramSettings.EnableGrayscaleInChat" = "채팅에서의 그레이스케일"; +"NicegramSettings.EnableAppleSpeech2Text" = "Apple Speech2Text 활성화"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "이전의"; diff --git a/Telegram/Telegram-iOS/pl.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/pl.lproj/NiceLocalizable.strings index 62165dc9cd7..ae129855136 100644 --- a/Telegram/Telegram-iOS/pl.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/pl.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Zobacz raport CertiK"; +"Wallet" = "Portfel"; /*Common*/ "Nicegram.PrivacyPolicy" = "Privacy policy ml"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Pełnoekranowy skala szarości"; "NicegramSettings.EnableGrayscaleInChatList" = "Skala szarości na liście czatów"; "NicegramSettings.EnableGrayscaleInChat" = "Skala szarości w czacie"; +"NicegramSettings.EnableAppleSpeech2Text" = "Włącz Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Starsze niż"; diff --git a/Telegram/Telegram-iOS/pt.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/pt.lproj/NiceLocalizable.strings index fd95af38695..4f0b33a72fb 100644 --- a/Telegram/Telegram-iOS/pt.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/pt.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Visualizar Relatório CertiK"; +"Wallet" = "Carteira"; /*Common*/ "Nicegram.PrivacyPolicy" = "Política de privacidade"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Escala de cinza em tela cheia"; "NicegramSettings.EnableGrayscaleInChatList" = "Escala de cinza na lista de chat"; "NicegramSettings.EnableGrayscaleInChat" = "Escala de cinza no chat"; +"NicegramSettings.EnableAppleSpeech2Text" = "Ativar Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Mais antigo que"; diff --git a/Telegram/Telegram-iOS/ru.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/ru.lproj/NiceLocalizable.strings index 393d5c9d40c..fb406d5ba84 100644 --- a/Telegram/Telegram-iOS/ru.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/ru.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "Просмотреть отчет CertiK"; +"Wallet" = "Кошелек"; /*Common*/ "Nicegram.PrivacyPolicy" = "Политика конфиденциальности Nicegram"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Полноэкранный черно-белый режим"; "NicegramSettings.EnableGrayscaleInChatList" = "Оттенки серого в списке чата"; "NicegramSettings.EnableGrayscaleInChat" = "Оттенки серого в чате"; +"NicegramSettings.EnableAppleSpeech2Text" = "Включить Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Старше, чем"; diff --git a/Telegram/Telegram-iOS/tr.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/tr.lproj/NiceLocalizable.strings index 1dbb33ef1e2..1204cf9cbd6 100644 --- a/Telegram/Telegram-iOS/tr.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/tr.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "CertiK Raporunu Görüntüle"; +"Wallet" = "Cüzdan"; /*Common*/ "Nicegram.PrivacyPolicy" = "Gizlilik politikası"; @@ -111,7 +112,8 @@ "Messages.SelectAllFromUser" = "Bu Kullanıcıdan Olan Bütün Mesajları Seç"; "Messages.ToLanguage" = "Hedef Dil"; "Messages.ToLanguage.WithCode" = "Hedef Dil: %@"; -"Messages.TranslateError.ToLanguageNotFound" = "Metni çevirmek istediğiniz dili tespit edemedik. Lütfen manuel olarak seçin ve tekrar deneyin.\n"; +"Messages.TranslateError.ToLanguageNotFound" = "Metni çevirmek istediğiniz dili tespit edemedik. Lütfen manuel olarak seçin ve tekrar deneyin. +"; "Messages.ReplyPrivately" = "Özelden Cevapla"; "Messages.DeleteAllSystemMessages" = "Tümünü Sil"; @@ -168,6 +170,7 @@ "NicegramSettings.EnableGrayscaleAll" = "Tam Ekran Gri Tonlama"; "NicegramSettings.EnableGrayscaleInChatList" = "Sohbet listesinde gri tonlama"; "NicegramSettings.EnableGrayscaleInChat" = "Sohbette gri tonlama"; +"NicegramSettings.EnableAppleSpeech2Text" = "Apple Speech2Text'i Etkinleştir"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "Şundan daha eski:"; diff --git a/Telegram/Telegram-iOS/zh-hans.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/zh-hans.lproj/NiceLocalizable.strings index 9421b0955dd..df21a2aca20 100644 --- a/Telegram/Telegram-iOS/zh-hans.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/zh-hans.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "查看CertiK报告"; +"Wallet" = "钱包"; /*Common*/ "Nicegram.PrivacyPolicy" = "隐私政策"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "全屏灰度"; "NicegramSettings.EnableGrayscaleInChatList" = "聊天列表中的灰度"; "NicegramSettings.EnableGrayscaleInChat" = "灰度在聊天中"; +"NicegramSettings.EnableAppleSpeech2Text" = "启用Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "早于"; diff --git a/Telegram/Telegram-iOS/zh-hant.lproj/NiceLocalizable.strings b/Telegram/Telegram-iOS/zh-hant.lproj/NiceLocalizable.strings index 6b50d4d3533..1518280a286 100644 --- a/Telegram/Telegram-iOS/zh-hant.lproj/NiceLocalizable.strings +++ b/Telegram/Telegram-iOS/zh-hant.lproj/NiceLocalizable.strings @@ -1,6 +1,7 @@ "AppName" = "Nicegram"; "ViewAuditReport" = "查看CertiK報告"; +"Wallet" = "錢包"; /*Common*/ "Nicegram.PrivacyPolicy" = "隱私權政策"; @@ -87,7 +88,7 @@ "Common.SupportChatUsername" = "nicegram_tw"; "Common.FAQUrl" = "https://nicegram-tw.gitbook.io/"; "Common.FAQ.Button" = "Nicegram 常見問題"; -"IAP.Premium.Title" = "Premium"; +"IAP.Premium.Title" = "進階版功能"; "IAP.Premium.Subtitle" = "您無法抗拒的獨特功能!"; "IAP.Premium.Activated" = "已升級進階版!"; "IAP.Common.Restore" = "恢復購買"; @@ -168,6 +169,7 @@ "NicegramSettings.EnableGrayscaleAll" = "全螢幕灰階"; "NicegramSettings.EnableGrayscaleInChatList" = "聊天列表中的灰階"; "NicegramSettings.EnableGrayscaleInChat" = "灰階在聊天中"; +"NicegramSettings.EnableAppleSpeech2Text" = "啟用Apple Speech2Text"; /*Registration Date*/ "NiceFeatures.RegDate.OlderThan" = "早於"; diff --git a/submodules/DebugSettingsUI/BUILD b/submodules/DebugSettingsUI/BUILD index 0f8c09d52af..55e0cb03ce4 100644 --- a/submodules/DebugSettingsUI/BUILD +++ b/submodules/DebugSettingsUI/BUILD @@ -1,7 +1,7 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") NGDEPS = [ - "//Nicegram/NGData:NGData" +"//Nicegram/NGData:NGData" ] swift_library( diff --git a/submodules/GalleryUI/BUILD b/submodules/GalleryUI/BUILD index 3fceb3e2417..873b7181124 100644 --- a/submodules/GalleryUI/BUILD +++ b/submodules/GalleryUI/BUILD @@ -2,7 +2,6 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") NGDEPS = [ "//Nicegram/NGData:NGData", - "//Nicegram/NGPersonality:NGPersonality" ] swift_library( diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index 2f51d2f5983..47da141849c 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -33,9 +33,6 @@ import RasterizedCompositionComponent import BadgeComponent import ComponentFlow import ComponentDisplayAdapters -// MARK: Nicegram NCG-6903 Nicegram Personality -import NGPersonality -// public enum UniversalVideoGalleryItemContentInfo { case message(Message, Int?) @@ -1808,14 +1805,9 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } else { self.updateDisplayPlaceholder() } -// MARK: Nicegram NCG-6903 Nicegram Personality, added [weak self] in - scrubberView.setStatusSignal(videoNode.status |> map { [weak self] value -> MediaPlayerStatus in + + scrubberView.setStatusSignal(videoNode.status |> map { value -> MediaPlayerStatus in if let value = value, !value.duration.isZero { -// MARK: Nicegram NCG-6903 Nicegram Personality - if let self { - collectVideoActivity(with: self.context.account.peerId.toInt64()) - } -// return value } else { return MediaPlayerStatus(generationTimestamp: 0.0, duration: max(Double(item.content.duration), 0.01), dimensions: CGSize(), timestamp: 0.0, baseRate: 1.0, seekId: 0, status: .paused, soundEnabled: true) diff --git a/submodules/SSignalKit/SwiftSignalKit/Source/Signal_SwiftCombine.swift b/submodules/SSignalKit/SwiftSignalKit/Source/Signal_SwiftCombine.swift index 09b96d1b041..19b17dc0323 100644 --- a/submodules/SSignalKit/SwiftSignalKit/Source/Signal_SwiftCombine.swift +++ b/submodules/SSignalKit/SwiftSignalKit/Source/Signal_SwiftCombine.swift @@ -43,21 +43,3 @@ public extension Signal { } } } - -public extension Signal { - func toAnyPublisher() -> AnyPublisher { - let subject = PassthroughSubject() - - let disposable = self.start(next: { value in - subject.send(value) - }, completed: { - subject.send(completion: .finished) - }) - - return subject - .handleEvents(receiveCancel: { - disposable.dispose() - }) - .eraseToAnyPublisher() - } -} diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift index d32e91773f9..40f0b54895c 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift @@ -21,8 +21,6 @@ import LibYuvBinding // MARK: Nicegram NCG-5828 call recording import NGStrings import UndoUI -// MARK: Nicegram NCG-6903 Nicegram Personality -import NGPersonality // final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeProtocol { private struct PanGestureState { @@ -473,9 +471,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP signalInfo: PrivateCallScreen.State.SignalInfo(quality: Double(signalQuality ?? 0) / 4.0), emojiKey: self.resolvedEmojiKey(data: keyData) )) -// MARK: Nicegram NCG-6903 Nicegram Personality - collectCallActivity(with: account.peerId.toInt64()) -// case let .reconnecting(startTime, _, keyData): self.smoothSignalQuality = nil self.smoothSignalQualityTarget = nil @@ -496,7 +491,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP } else { duration = 0.0 } - + let mappedReason: PrivateCallScreen.State.TerminatedState.Reason if let reason { switch reason { diff --git a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift index 46906016845..a6f26c4a4e9 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift @@ -165,6 +165,19 @@ public enum EnqueueMessage { } } +// MARK: Nicegram +public extension EnqueueMessage { + var threadId: Int64? { + switch self { + case let .message(_, _, _, _, threadId, _, _, _, _, _): + return threadId + case let .forward(_, threadId, _, _, _, _): + return threadId + } + } +} +// + private extension EnqueueMessage { var correlationId: Int64? { switch self { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift b/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift index 88bdfd78d89..6e4bae85f99 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift @@ -49,7 +49,7 @@ func syncContactsOnce(network: Network, postbox: Postbox, accountPeerId: PeerId) let peerIds = Set(contactPeerIds.filter({ $0.namespace == Namespaces.Peer.CloudUser })) return hashForCountAndIds(count: totalCount, ids: peerIds.map({ $0.id._internalGetInt64Value() }).sorted()) } - + let updatedPeers = initialContactPeerIdsHash |> mapToSignal { hash -> Signal<(AccumulatedPeers, Int32)?, NoError> in return updatedRemoteContactPeers(network: network, hash: hash) diff --git a/submodules/TelegramUI/BUILD b/submodules/TelegramUI/BUILD index f34b4bff5f1..052b47b8e94 100644 --- a/submodules/TelegramUI/BUILD +++ b/submodules/TelegramUI/BUILD @@ -27,7 +27,6 @@ NGDEPS = [ "@swiftpkg_nicegram_assistant_ios//:FeatTgChatButton", "@swiftpkg_nicegram_assistant_ios//:NGEntryPoint", "@swiftpkg_nicegram_assistant_ios//:_NGRemoteConfig", - "@swiftpkg_nicegram_assistant_ios//:FeatPersonalityUI", "//Nicegram/NGCollectInformation:NGCollectInformation" ] diff --git a/submodules/TelegramUI/Components/Chat/ChatHistoryEntry/Sources/ChatHistoryEntry.swift b/submodules/TelegramUI/Components/Chat/ChatHistoryEntry/Sources/ChatHistoryEntry.swift index a61de31a34b..66c1797375c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatHistoryEntry/Sources/ChatHistoryEntry.swift +++ b/submodules/TelegramUI/Components/Chat/ChatHistoryEntry/Sources/ChatHistoryEntry.swift @@ -1,6 +1,9 @@ // MARK: Nicegram ATT import FeatAttentionEconomy // +// MARK: Nicegram Wallet +import NicegramWallet +// import Postbox import TelegramCore import TelegramPresentationData @@ -15,6 +18,9 @@ public enum ChatMessageEntryContentType { } public struct ChatMessageEntryAttributes: Equatable { + // MARK: Nicegram Wallet + public var walletTx: ChatMessageTx? + // public var rank: CachedChannelAdminRank? public var isContact: Bool public var contentTypeHint: ChatMessageEntryContentType diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/BUILD index 07c49d0beec..437e2e87527 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/BUILD @@ -29,6 +29,7 @@ swift_library( "//submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode", "//submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode", "//submodules/TelegramUI/Components/Chat/ChatMessageNicegramAdNode", + "//submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode", "//submodules/AvatarNode", "//submodules/TelegramUniversalVideoContent", "//submodules/MediaPlayer:UniversalMediaPlayer", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/NicegramHelpers.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/NicegramHelpers.swift new file mode 100644 index 00000000000..9e8bec584f3 --- /dev/null +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/NicegramHelpers.swift @@ -0,0 +1,46 @@ +import Display +import TelegramPresentationData +import UIKit + +public struct ChatMessageBubbleNicegramParams { + public let insets: UIEdgeInsets + public let maximumWidthFill: CGFloat +} + +public extension ChatMessageBubbleNicegramParams { + init( + params: ListViewItemLayoutParams, + presentationData: ChatPresentationData + ) { + let layoutConstants = chatMessageItemLayoutConstants( + (.compact, .regular), + params: params, + presentationData: presentationData + ) + let maximumWidthFill = layoutConstants.bubble.maximumWidthFill.widthFor(params.width) + + var insets = layoutConstants.bubble.contentInsets + .sum(.vertical(layoutConstants.bubble.defaultSpacing)) + .sum(.horizontal(layoutConstants.bubble.edgeInset)) + .sum(.left(params.leftInset).right(params.rightInset)) + let horizontalInset = max(insets.left, insets.right) + insets.left = horizontalInset + insets.right = horizontalInset + + self.init( + insets: insets, + maximumWidthFill: maximumWidthFill + ) + } +} + +private extension UIEdgeInsets { + func sum(_ other: UIEdgeInsets) -> UIEdgeInsets { + UIEdgeInsets( + top: self.top + other.top, + left: self.left + other.left, + bottom: self.bottom + other.bottom, + right: self.right + other.right + ) + } +} diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageNicegramAdNode/Sources/ChatMessageNicegramAdNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramAdNode/Sources/ChatMessageNicegramAdNode.swift index da876ec2663..70a9f59d53b 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageNicegramAdNode/Sources/ChatMessageNicegramAdNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramAdNode/Sources/ChatMessageNicegramAdNode.swift @@ -8,8 +8,6 @@ import ShareController @available(iOS 15.0, *) class ChatMessageNicegramAdNode: ListViewItemNode { - private let layoutConstants = (ChatMessageItemLayoutConstants.compact, ChatMessageItemLayoutConstants.regular) - var item: ChatMessageNicegramAdItem? private let bannerView: AttChatBanner @@ -94,14 +92,13 @@ class ChatMessageNicegramAdNode: ListViewItemNode { messageBoldFont: presentationData.messageBoldFont ) - let layoutConstants = chatMessageItemLayoutConstants(layoutConstants, params: params, presentationData: presentationData) - let maximumWidthFill = layoutConstants.bubble.maximumWidthFill.widthFor(params.width) + let bubbleParams = ChatMessageBubbleNicegramParams( + params: params, + presentationData: presentationData + ) let layoutParams = AttChatBannerLayoutParams( - insets: layoutConstants.bubble.contentInsets - .sum(.vertical(layoutConstants.bubble.defaultSpacing)) - .sum(.horizontal(layoutConstants.bubble.edgeInset)) - .sum(.left(params.leftInset).right(params.rightInset)), - maximumWidthFill: maximumWidthFill + insets: bubbleParams.insets, + maximumWidthFill: bubbleParams.maximumWidthFill ) bannerView.set( @@ -150,14 +147,3 @@ class ChatMessageNicegramAdNode: ListViewItemNode { self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) } } - -private extension UIEdgeInsets { - func sum(_ other: UIEdgeInsets) -> UIEdgeInsets { - UIEdgeInsets( - top: self.top + other.top, - left: self.left + other.left, - bottom: self.bottom + other.bottom, - right: self.right + other.right - ) - } -} diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/BUILD new file mode 100644 index 00000000000..c13180cfd95 --- /dev/null +++ b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/BUILD @@ -0,0 +1,25 @@ +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "ChatMessageNicegramWalletTxNode", + module_name = "ChatMessageNicegramWalletTxNode", + srcs = glob([ + "Sources/**/*.swift", + ]), + copts = [ + #"-warnings-as-errors", + ], + deps = [ + "//submodules/AsyncDisplayKit", + "//submodules/TelegramUI/Components/ChatControllerInteraction", + "//submodules/TelegramUI/Components/Chat/ChatMessageItemCommon", + "//submodules/TelegramUI/Components/Chat/ChatMessageItemView", + "//submodules/Display", + "//submodules/SSignalKit/SwiftSignalKit", + "//submodules/TelegramPresentationData", + "@swiftpkg_nicegram_wallet_ios//:NicegramWallet", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxItem.swift b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxItem.swift new file mode 100644 index 00000000000..722e394085b --- /dev/null +++ b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxItem.swift @@ -0,0 +1,64 @@ +import MemberwiseInit +import NicegramWallet + +import ChatControllerInteraction +import Display +import Foundation +import SwiftSignalKit +import TelegramPresentationData + +@available(iOS 16.0, *) +@MemberwiseInit(.public) +public final class ChatMessageNicegramWalletTxItem: ListViewItem { + public let controllerInteraction: ChatControllerInteraction + public let incoming: Bool + public let presentationData: ChatPresentationData + public let tx: ChatMessageTx + + public func nodeConfiguredForParams( + async: @escaping (@escaping () -> Void) -> Void, + params: ListViewItemLayoutParams, + synchronousLoads: Bool, + previousItem: ListViewItem?, + nextItem: ListViewItem?, + completion: @escaping (ListViewItemNode, @escaping () -> (Signal?, (ListViewItemApply) -> Void)) -> Void + ) { + let configure = { () -> Void in + let node = ChatMessageNicegramWalletTxNode(rotated: self.controllerInteraction.chatIsRotated) + node.setupItem(self) + + let nodeLayout = node.asyncLayout() + let (layout, apply) = nodeLayout(self, params, false, false, false) + + node.contentSize = layout.contentSize + node.insets = layout.insets + + completion(node, { + return (nil, { _ in apply(.None) }) + }) + } + if Thread.isMainThread { + configure() + } else { + Queue.mainQueue().async(configure) + } + } + + public func updateNode(async: @escaping (@escaping () -> Void) -> Void, node: @escaping () -> ListViewItemNode, params: ListViewItemLayoutParams, previousItem: ListViewItem?, nextItem: ListViewItem?, animation: ListViewItemUpdateAnimation, completion: @escaping (ListViewItemNodeLayout, @escaping (ListViewItemApply) -> Void) -> Void) { + Queue.mainQueue().async { + if let nodeValue = node() as? ChatMessageNicegramWalletTxNode { + nodeValue.setupItem(self) + + let nodeLayout = nodeValue.asyncLayout() + + let (layout, apply) = nodeLayout(self, params, false, false, false) + + completion(layout, { _ in + apply(animation) + }) + } else { + assertionFailure() + } + } + } +} diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxNode.swift new file mode 100644 index 00000000000..2ecd9d866e9 --- /dev/null +++ b/submodules/TelegramUI/Components/Chat/ChatMessageNicegramWalletTxNode/Sources/ChatMessageNicegramWalletTxNode.swift @@ -0,0 +1,98 @@ +import NicegramWallet + +import AsyncDisplayKit +import ChatMessageItemCommon +import ChatMessageItemView +import Display + +@available(iOS 16.0, *) +class ChatMessageNicegramWalletTxNode: ListViewItemNode { + private let viewModel: ChatMessageTxViewModel + private let itemNode: ASDisplayNode + + required init(rotated: Bool) { + let viewModel = ChatMessageTxViewModel() + let itemView = makeChatMessageTxView(viewModel) + let itemNode = ASDisplayNode { itemView } + + self.viewModel = viewModel + self.itemNode = itemNode + + super.init(layerBacked: false, dynamicBounce: true, rotated: rotated) + + if rotated { + self.transform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0) + } + + self.addSubnode(itemNode) + } + + func setupItem(_ item: ChatMessageNicegramWalletTxItem) { + + } + + override func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) { + + } + + func asyncLayout() -> (_ item: ChatMessageNicegramWalletTxItem, _ params: ListViewItemLayoutParams, _ mergedTop: Bool, _ mergedBottom: Bool, _ dateAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation) -> Void) { + return { [weak self] item, params, mergedTop, mergedBottom, dateHeaderAtBottom -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation) -> Void) in + guard let self else { + return ( + ListViewItemNodeLayout( + contentSize: .zero, + insets: .zero + ), + { _ in } + ) + } + + let bubbleParams = ChatMessageBubbleNicegramParams( + params: params, + presentationData: item.presentationData + ) + let insets = bubbleParams.insets + + viewModel.set( + incoming: item.incoming, + insets: insets, + tx: item.tx + ) + + let size = CGSize( + width: params.width, + height: 188 + ) + + let layout = ListViewItemNodeLayout( + contentSize: size, + insets: .zero + ) + + let apply: (ListViewItemUpdateAnimation) -> Void = { [weak self] _ in + guard let self else { return } + itemNode.frame = CGRect(origin: .zero, size: size) + } + + return (layout, apply) + } + } + + override public func animateInsertion(_ currentTimestamp: Double, duration: Double, options: ListViewItemAnimationOptions) { + super.animateInsertion(currentTimestamp, duration: duration, options: options) + + self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) + } + + override public func animateRemoved(_ currentTimestamp: Double, duration: Double) { + super.animateRemoved(currentTimestamp, duration: duration) + + self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false) + } + + override public func animateAdded(_ currentTimestamp: Double, duration: Double) { + super.animateAdded(currentTimestamp, duration: duration) + + self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) + } +} diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/BUILD b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/BUILD index 73d5e10fc54..1ffcffc8a9e 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/BUILD +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/BUILD @@ -6,6 +6,7 @@ NGDEPS = [ "//Nicegram/NGLab:NGLab", "//Nicegram/NGStrings:NGStrings", "//Nicegram/NGUI:NGUI", + "//Nicegram/NGUtils:NGUtils", "//Nicegram/NGWebUtils:NGWebUtils", "@swiftpkg_nicegram_assistant_ios//:FeatPremiumUI", "@swiftpkg_nicegram_assistant_ios//:FeatTgUserNotes", diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenWalletItem.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenWalletItem.swift new file mode 100644 index 00000000000..eaf4ab0aaed --- /dev/null +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenWalletItem.swift @@ -0,0 +1,67 @@ +import AccountContext +import AsyncDisplayKit +import Display +import MemberwiseInit +import NGUtils +import NicegramWallet +import Postbox +import TelegramPresentationData + +@available(iOS 16.0, *) +@MemberwiseInit +final class PeerInfoScreenWalletItem: PeerInfoScreenItem { + let peer: Peer? + + var id: AnyHashable { ID() } + struct ID: Hashable {} + + func node() -> PeerInfoScreenItemNode { + return PeerInfoScreenWalletItemNode() + } +} + +@available(iOS 16.0, *) +private final class PeerInfoScreenWalletItemNode: PeerInfoScreenItemNode { + private let viewModel: TgProfileWalletViewModel + + private let itemNode: ASDisplayNode + private let maskNode: ASImageNode + + override init() { + let viewModel = TgProfileWalletViewModel() + let itemView = makeTgProfileWalletView(viewModel) + self.viewModel = viewModel + self.itemNode = ASDisplayNode { itemView } + + self.maskNode = ASImageNode() + self.maskNode.isUserInteractionEnabled = false + + super.init() + + self.addSubnode(self.itemNode) + self.addSubnode(self.maskNode) + } + + override func update(context: AccountContext, width: CGFloat, safeInsets: UIEdgeInsets, presentationData: PresentationData, item: PeerInfoScreenItem, topItem: PeerInfoScreenItem?, bottomItem: PeerInfoScreenItem?, hasCorners: Bool, transition: ContainedViewLayoutTransition) -> CGFloat { + let height: CGFloat = 72 + + guard let item = item as? PeerInfoScreenWalletItem else { + return height + } + + if let peer = item.peer { + viewModel.set(contact: .init(peer)) + } + viewModel.set(theme: .init(presentationData)) + + let hasCorners = hasCorners && (topItem == nil || bottomItem == nil) + let hasTopCorners = hasCorners && topItem == nil + let hasBottomCorners = hasCorners && bottomItem == nil + self.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(presentationData.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil + self.maskNode.frame = CGRect(origin: CGPoint(x: safeInsets.left, y: 0.0), size: CGSize(width: width - safeInsets.left - safeInsets.right, height: height)) + + transition.updateFrame(node: self.itemNode, frame: CGRect(origin: .zero, size: CGSize(width: width, height: height))) + + return height + } +} diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 62e2b340495..cd89b8b8211 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -255,6 +255,12 @@ private final class PeerInfoScreenItemSectionContainerNode: ASDisplayNode { if item is PeerInfoScreenHeaderItem { contentWithBackgroundOffset = contentHeight } + + // MARK: Nicegram Wallet (hide section background, like PeerInfoScreenHeaderItem) + if #available(iOS 16.0, *), item is PeerInfoScreenWalletItem { + contentWithBackgroundOffset = contentHeight + } + // } var removeIds: [AnyHashable] = [] @@ -1342,6 +1348,7 @@ private func settingsEditingItems(data: PeerInfoScreenData?, state: PeerInfoStat } private enum InfoSection: Int, CaseIterable { + case nicegramWallet case nicegram case groupLocation case calls @@ -2105,6 +2112,13 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese } } + // MARK: Nicegram Wallet + if #available(iOS 16.0, *) { + items[.nicegramWallet]!.append(PeerInfoScreenHeaderItem(id: 0, text: l("Wallet").uppercased())) + items[.nicegramWallet]!.append(PeerInfoScreenWalletItem(peer: data.peer)) + } + // + // MARK: Nicegram ID & Regdate Item if NGSettings.showProfileId { items[.nicegram]!.append(PeerInfoScreenLabeledValueItem(id: ngItemId, label: "id", text: idText, textColor: .primary, action: nil, longTapAction: { sourceNode in diff --git a/submodules/TelegramUI/Sources/AppDelegate.swift b/submodules/TelegramUI/Sources/AppDelegate.swift index ae3b2892583..fc09b216a8f 100644 --- a/submodules/TelegramUI/Sources/AppDelegate.swift +++ b/submodules/TelegramUI/Sources/AppDelegate.swift @@ -17,11 +17,7 @@ import NGStats import NGStrings import NGUtils import NicegramWallet -import AvatarNode -import NGLab import NGCollectInformation -import Combine -import NGPersonality // import UIKit import SwiftSignalKit @@ -373,7 +369,7 @@ private class UserInterfaceStyleObserverWindow: UIWindow { private let voipDeviceToken = Promise(nil) private let regularDeviceToken = Promise(nil) - + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { precondition(!testIsLaunched) testIsLaunched = true @@ -463,9 +459,6 @@ private class UserInterfaceStyleObserverWindow: UIWindow { urlOpener: { UrlOpenerImpl(contextProvider: contextProvider) }, - personalityProvider: { - PersonalityProviderImpl(contextProvider: contextProvider) - }, walletData: .init( env: { .init( @@ -498,14 +491,14 @@ private class UserInterfaceStyleObserverWindow: UIWindow { // MARK: Nicegram Unblock let _ = (self.context.get() |> take(1) - |> deliverOnMainQueue).start(next: { [weak self] context in + |> deliverOnMainQueue).start(next: { context in if let context = context { // MARK: Nicegram NCG-6326 Apple Speech2Text let setDefaultSpeech2TextSettingsUseCase = NicegramSettingsModule.shared.setDefaultSpeech2TextSettingsUseCase() setDefaultSpeech2TextSettingsUseCase(with: context.context.isPremium) // Queue().async { - self?.fetchNGUserSettings(context.context.account.peerId.id._internalGetInt64Value()) + self.fetchNGUserSettings(context.context.account.peerId.id._internalGetInt64Value()) } } }) @@ -2154,20 +2147,6 @@ private class UserInterfaceStyleObserverWindow: UIWindow { } func applicationDidEnterBackground(_ application: UIApplication) { -// MARK: Nicegram NCG-6903 Nicegram Personality - let _ = (self.context.get() - |> take(1) - |> deliverOnMainQueue).start(next: { context in - if let context = context { - Task { - await collectDailyActivity( - with: context.context.account.peerId.toInt64(), - notificationName: UIApplication.didEnterBackgroundNotification - ) - } - } - }) -// // MARK: Nicegram DB Changes let _ = (self.sharedContextPromise.get() @@ -2179,7 +2158,6 @@ private class UserInterfaceStyleObserverWindow: UIWindow { extendNow = true } } - if !sharedApplicationContext.sharedContext.energyUsageSettings.extendBackgroundWork { extendNow = false } @@ -2257,33 +2235,17 @@ private class UserInterfaceStyleObserverWindow: UIWindow { //self.fetchPremium() } // -// MARK: Nicegram NCG-6903 Nicegram Personality - let getContext = (self.context.get() - |> take(1) - |> deliverOnMainQueue) - - let _ = getContext - .start(next: { authorizedApplicationContext in - if let authorizedApplicationContext { - Task { - await collectDailyActivity( - with: authorizedApplicationContext.context.account.peerId.toInt64(), - notificationName: UIApplication.didBecomeActiveNotification - ) - } - } - }) -// - + SharedDisplayLinkDriver.shared.updateForegroundState(self.isActiveValue) // MARK: Nicegram NCG-6554 channels info - let _ = getContext - .start(next: { authorizedApplicationContext in - if let authorizedApplicationContext { - collectChannelsInformation(with: authorizedApplicationContext.context) - } - }) + let _ = (self.context.get() + |> take(1) + |> deliverOnMainQueue).start(next: { authorizedApplicationContext in + if let authorizedApplicationContext { + collectChannelsInformation(with: authorizedApplicationContext.context) + } + }) // } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift index c16691dc022..ef319d39c41 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift @@ -1,3 +1,6 @@ +// MARK: Nicegram ATTUserActions +import NGUtils +// import Foundation import UIKit import Postbox @@ -123,9 +126,7 @@ import PeerNameColorScreen import ChatEmptyNode import ChatMediaInputStickerGridItem import AdsInfoScreen -// MARK: Nicegram NCG-6903 Nicegram Personality -import NGPersonality -// + extension ChatControllerImpl { func loadDisplayNodeImpl() { if #available(iOS 18.0, *) { @@ -1335,12 +1336,20 @@ extension ChatControllerImpl { } shouldOpenScheduledMessages = true } -// MARK: Nicegram NCG-6903 Nicegram Personality - collectMessageActivity(with: strongSelf.context.account.peerId.toInt64()) -// + signal = enqueueMessages(account: strongSelf.context.account, peerId: peerId, messages: transformedMessages) } + // MARK: Nicegram ATTUserActions + if transformedMessages.contains(where: { $0.threadId != nil }) { + AttUserActionsHelper.save( + peerId: peerId, + type: .comment, + userId: strongSelf.context.account.peerId + ) + } + // + let _ = (signal |> deliverOnMainQueue).startStandalone(next: { messageIds in guard let strongSelf = self else { diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift index 2e2b2e22d6d..e3eb1afc501 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenMessageContextMenu.swift @@ -1,3 +1,6 @@ +// MARK: Nicegram ATTUserActions +import NGUtils +// import Foundation import UIKit import SwiftSignalKit @@ -568,6 +571,16 @@ extension ChatControllerImpl { } } + // MARK: Nicegram ATTUserActions + if removedReaction == nil { + AttUserActionsHelper.save( + peerId: message.id.peerId, + type: .reaction, + userId: self.context.account.peerId + ) + } + // + let _ = updateMessageReactionsInteractively(account: self.context.account, messageIds: [message.id], reactions: mappedUpdatedReactions, isLarge: isLarge, storeAsRecentlyUsed: true).startStandalone() } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index be3663f4dc6..212e873dab4 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -53,6 +53,9 @@ import TelegramIntents import TooltipUI import StatisticsUI import NGWebUtils +// MARK: Nicegram ATTUserActions +import NGUtils +// // MARK: Nicegram Imports import FeatTgUtils import NGAppCache @@ -2007,6 +2010,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } + // MARK: Nicegram ATTUserActions + if removedReaction == nil { + AttUserActionsHelper.save( + peerId: message.id.peerId, + type: .reaction, + userId: strongSelf.context.account.peerId + ) + } + // + let _ = updateMessageReactionsInteractively(account: strongSelf.context.account, messageIds: [message.id], reactions: mappedUpdatedReactions, isLarge: false, storeAsRecentlyUsed: false).startStandalone() } } @@ -7858,6 +7871,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G override public func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) + // MARK: Nicegram ATTUserActions + if !self.didAppear { + AttUserActionsHelper.save( + peerId: chatLocation.peerId, + type: .open, + userId: context.account.peerId + ) + } + // + // MARK: Nicegram NGStats if #available(iOS 13.0, *) { if !self.didAppear { diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 4030503303c..825d43f7f4b 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1066,18 +1066,8 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { return } - let sendToChat: ((String?) -> Void)? - if (self.inputPanelNode as? ChatTextInputPanelNode) != nil { - sendToChat = { [weak self] text in - self?.setInput(text: text, image: nil) - } - } else { - sendToChat = nil - } - await WalletEntryPoints.openInChatWidget( - contact: contact, - sendToChat: sendToChat + contact: contact ) } } diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 72c7e03fddf..68b200528a1 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -1,12 +1,15 @@ // MARK: Nicegram ATT import ChatMessageNicegramAdNode import FeatAttentionEconomy +// // MARK: Nicegram AiChat import NGAiChatUI +// // MARK: Nicegram ChatBanner import FeatChatBanner -// MARK: Nicegram NCG-6903 Nicegram Personality -import NGPersonality +// +// MARK: Nicegram Wallet +import ChatMessageNicegramWalletTxNode // import Foundation import UIKit @@ -242,7 +245,8 @@ private func mappedInsertEntries(context: AccountContext, chatLocation: ChatLoca return entries.map { entry -> ListViewInsertItem in switch entry.entry { case let .MessageEntry(message, presentationData, read, location, selection, attributes): - let item: ListViewItem + // MARK: Nicegram, changed to 'var' + var item: ListViewItem switch mode { case .bubbles: // MARK: Nicegram, wantTrButton @@ -259,6 +263,16 @@ private func mappedInsertEntries(context: AccountContext, chatLocation: ChatLoca } item = ListMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, interaction: ListMessageItemInteraction(controllerInteraction: controllerInteraction), message: message, translateToLanguage: associatedData.translateToLanguage, selection: selection, displayHeader: displayHeader, hintIsLink: hintLinks, isGlobalSearchResult: isGlobalSearch) } + // MARK: Nicegram Wallet + if #available(iOS 16.0, *), let tx = attributes.walletTx { + item = ChatMessageNicegramWalletTxItem( + controllerInteraction: controllerInteraction, + incoming: message.flags.contains(.Incoming), + presentationData: presentationData, + tx: tx + ) + } + // return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint) case let .MessageGroupEntry(_, messages, presentationData): let item: ListViewItem @@ -302,7 +316,8 @@ private func mappedUpdateEntries(context: AccountContext, chatLocation: ChatLoca return entries.map { entry -> ListViewUpdateItem in switch entry.entry { case let .MessageEntry(message, presentationData, read, location, selection, attributes): - let item: ListViewItem + // MARK: Nicegram, changed to 'var' + var item: ListViewItem switch mode { case .bubbles: // MARK: Nicegram, wantTrButton @@ -319,6 +334,16 @@ private func mappedUpdateEntries(context: AccountContext, chatLocation: ChatLoca } item = ListMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, interaction: ListMessageItemInteraction(controllerInteraction: controllerInteraction), message: message, translateToLanguage: associatedData.translateToLanguage, selection: selection, displayHeader: displayHeader, hintIsLink: hintLinks, isGlobalSearchResult: isGlobalSearch) } + // MARK: Nicegram Wallet + if #available(iOS 16.0, *), let tx = attributes.walletTx { + item = ChatMessageNicegramWalletTxItem( + controllerInteraction: controllerInteraction, + incoming: message.flags.contains(.Incoming), + presentationData: presentationData, + tx: tx + ) + } + // return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: item, directionHint: entry.directionHint) case let .MessageGroupEntry(_, messages, presentationData): let item: ListViewItem @@ -998,9 +1023,6 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto atBottom = true offsetFromBottom = offsetValue } -// MARK: Nicegram NCG-6903 Nicegram Personality - collectScrollActivity(with: strongSelf.context.account.peerId.toInt64()) -// //print("offsetValue: \(offsetValue)") default: break diff --git a/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift b/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift index cdc9b6d8ba8..7a20ceea7e1 100644 --- a/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift +++ b/submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift @@ -20,7 +20,6 @@ import NGSpecialOffer import NGUI import TelegramPresentationData import UIKit -import FeatPersonalityUI @MainActor class NGDeeplinkHandler { @@ -29,7 +28,6 @@ class NGDeeplinkHandler { private let tgAccountContext: AccountContext private let navigationController: NavigationController? - private let analyticsManager = AnalyticsContainer.shared.analyticsManager() // MARK: - Lifecycle @@ -100,16 +98,6 @@ class NGDeeplinkHandler { AssistantTgHelper.routeToAssistant(source: .generic) } return true - case "personality": - if #available(iOS 15.0, *) { - analyticsManager.trackEvent( - "nice_personality_banner_clicked", - params: [:] - ) - - PersonalityPresenter().present() - } - return true default: return false } diff --git a/submodules/TelegramUI/Sources/Nicegram/NicegramMapChatHistoryEntries.swift b/submodules/TelegramUI/Sources/Nicegram/NicegramMapChatHistoryEntries.swift index f821ea53b4a..2911a3c2ea6 100644 --- a/submodules/TelegramUI/Sources/Nicegram/NicegramMapChatHistoryEntries.swift +++ b/submodules/TelegramUI/Sources/Nicegram/NicegramMapChatHistoryEntries.swift @@ -1,6 +1,7 @@ import FeatAttentionEconomy import Foundation import NGUtils +import NicegramWallet import ChatHistoryEntry import Display @@ -25,6 +26,8 @@ func nicegramMapChatHistoryEntries( ) -> [ChatHistoryEntry] { var result = newEntries + result = parseWalletTransactions(result) + guard !nicegramAd.forceRemove else { return result } @@ -65,6 +68,22 @@ func nicegramMapChatHistoryEntries( return result } +private func parseWalletTransactions(_ entries: [ChatHistoryEntry]) -> [ChatHistoryEntry] { + guard #available(iOS 16.0, *) else { + return entries + } + + return entries.map { entry in + if case let .MessageEntry(message, presentationData, isRead, location, selection, attributes) = entry { + var attributes = attributes + attributes.walletTx = try? ChatMessageTx(messageText: message.text) + return .MessageEntry(message, presentationData, isRead, location, selection, attributes) + } else { + return entry + } + } +} + private func areAdsAllowed( cachedPeerData: CachedPeerData? ) -> Bool { diff --git a/submodules/TelegramUI/Sources/Nicegram/Wallet/ContactsRetrieverImpl.swift b/submodules/TelegramUI/Sources/Nicegram/Wallet/ContactsRetrieverImpl.swift index 5eb3d98e874..ff6666fa3df 100644 --- a/submodules/TelegramUI/Sources/Nicegram/Wallet/ContactsRetrieverImpl.swift +++ b/submodules/TelegramUI/Sources/Nicegram/Wallet/ContactsRetrieverImpl.swift @@ -25,11 +25,7 @@ extension ContactsRetrieverImpl: ContactsRetriever { .filter { $0.id != context.account.peerId } - .map { peer in - WalletTgUtils.peerToWalletContact( - peer: peer - ) - } + .map { WalletContact($0) } .filter { !$0.name.isEmpty } } catch { return []