From 45d4b28fe6e9bed21e730a36b1e6c56c2828dfec Mon Sep 17 00:00:00 2001 From: Leonid Vilner Date: Fri, 10 Jan 2025 22:35:16 +0800 Subject: [PATCH 1/6] [trello.com/c/b82n6AMp] adding cost when sending media/files --- Adamant.xcodeproj/project.pbxproj | 9 ++++ .../xcshareddata/swiftpm/Package.resolved | 32 +++++++------- .../Chat/View/ChatViewController.swift | 1 + .../Chat/ViewModel/ChatViewModel.swift | 42 ++++++++++++------- .../Sources/CommonKit/AdamantSecret.swift | 17 ++++++++ 5 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 CommonKit/Sources/CommonKit/AdamantSecret.swift diff --git a/Adamant.xcodeproj/project.pbxproj b/Adamant.xcodeproj/project.pbxproj index 19cfcd91d..65627120a 100644 --- a/Adamant.xcodeproj/project.pbxproj +++ b/Adamant.xcodeproj/project.pbxproj @@ -3070,6 +3070,7 @@ 938F7D562955C1DA001915CA /* XCRemoteSwiftPackageReference "MessageKit" */, 4184F16F2A33044E00D7B8B9 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, 3AC76E3B2AB09118008042C4 /* XCRemoteSwiftPackageReference "Elegant-Emoji-Picker" */, + 84B761662D2E79A50022DCA9 /* XCRemoteSwiftPackageReference "PopupKit" */, ); productRefGroup = E913C8EF1FFFA51D001A83F7 /* Products */; projectDirPath = ""; @@ -4422,6 +4423,14 @@ minimumVersion = 5.0.0; }; }; + 84B761662D2E79A50022DCA9 /* XCRemoteSwiftPackageReference "PopupKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Pointwelve/PopupKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.1.1; + }; + }; 938F7D562955C1DA001915CA /* XCRemoteSwiftPackageReference "MessageKit" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/MessageKit/MessageKit.git"; diff --git a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5828488fd..ff7b1d3e3 100644 --- a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -105,8 +105,8 @@ "repositoryURL": "https://github.com/google/GoogleDataTransport.git", "state": { "branch": null, - "revision": "aae45a320fd0d11811820335b1eabc8753902a40", - "version": "9.2.5" + "revision": "a637d318ae7ae246b02d7305121275bc75ed5565", + "version": "9.4.0" } }, { @@ -114,8 +114,8 @@ "repositoryURL": "https://github.com/google/GoogleUtilities.git", "state": { "branch": null, - "revision": "bc27fad73504f3d4af235de451f02ee22586ebd3", - "version": "7.12.1" + "revision": "57a1d307f42df690fdef2637f3e5b776da02aad6", + "version": "7.13.3" } }, { @@ -141,8 +141,8 @@ "repositoryURL": "https://github.com/nathantannar4/InputBarAccessoryView", "state": { "branch": null, - "revision": "17ced92a5dccb36512b408b6276353631d7cbe57", - "version": "6.3.0" + "revision": "c7acd5fa32e54cd7a44ad7eb9a7730da35b54c95", + "version": "6.5.1" } }, { @@ -159,8 +159,8 @@ "repositoryURL": "https://github.com/firebase/leveldb.git", "state": { "branch": null, - "revision": "9d108e9112aa1d65ce508facf804674546116d9c", - "version": "1.22.3" + "revision": "a0bc79961d7be727d258d33d5a6b2f1023270ba1", + "version": "1.22.5" } }, { @@ -177,8 +177,8 @@ "repositoryURL": "https://github.com/MessageKit/MessageKit.git", "state": { "branch": null, - "revision": "1993e8e90d4e9a61b8d9bc8ceb733964ce943376", - "version": "4.2.0" + "revision": "b024c1287ac30fb6ea2ee07169e6193efc11d972", + "version": "4.3.0" } }, { @@ -204,7 +204,7 @@ "repositoryURL": "https://github.com/rechsteiner/Parchment", "state": { "branch": "main", - "revision": "13aad3e9308e8a4e38cb579430dbf66465418777", + "revision": "dfb23ea5118ca8bfbc578065627fccf4ec4a362e", "version": null } }, @@ -222,8 +222,8 @@ "repositoryURL": "https://github.com/google/promises.git", "state": { "branch": null, - "revision": "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", - "version": "2.3.1" + "revision": "540318ecedd63d883069ae7f1ed811a2df00b6ac", + "version": "2.4.0" } }, { @@ -276,7 +276,7 @@ "repositoryURL": "https://github.com/socketio/socket.io-client-swift", "state": { "branch": "master", - "revision": "175da8b5156f6b132436f0676cc84c2f6a766b6e", + "revision": "42da871d9369f290d6ec4930636c40672143905b", "version": null } }, @@ -285,8 +285,8 @@ "repositoryURL": "https://github.com/daltoniam/Starscream", "state": { "branch": null, - "revision": "ac6c0fc9da221873e01bd1a0d4818498a71eef33", - "version": "4.0.6" + "revision": "c6bfd1af48efcc9a9ad203665db12375ba6b145a", + "version": "4.0.8" } }, { diff --git a/Adamant/Modules/Chat/View/ChatViewController.swift b/Adamant/Modules/Chat/View/ChatViewController.swift index b309fc4d0..d519625a5 100644 --- a/Adamant/Modules/Chat/View/ChatViewController.swift +++ b/Adamant/Modules/Chat/View/ChatViewController.swift @@ -943,6 +943,7 @@ private extension ChatViewController { func closeFileToolbarView() { filesToolbarView.removeFromSuperview() messageInputBar.invalidateIntrinsicContentSize() + viewModel.inputTextFileUpdated() } func didTapTransfer(id: String) { diff --git a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift index 202505026..ddbfce93b 100644 --- a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift +++ b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift @@ -938,6 +938,9 @@ final class ChatViewModel: NSObject { } filesPicked = oldFiles + + inputTextFileUpdated() + case .failure(let error): dialog.send(.alert(error.localizedDescription)) } @@ -1060,6 +1063,29 @@ extension ChatViewModel { self?.dateHeaderHidden = true } } + + func inputTextFileUpdated() { + + guard !inputText.isEmpty || filesPicked != nil else { + fee = "" + return + } + + var filesText: String = "" + + if let filesPicked { + filesText = filesPicked.map{ + ($0.name ?? "") + ($0.extenstion ?? "") + }.joined(separator: "") + } + + let feeString = AdamantBalanceFormat.full.format( + AdamantMessage.text(inputText + filesText).fee, + withCurrencySymbol: AdmWalletService.currencySymbol + ) + + fee = "~\(feeString)" + } } extension ChatViewModel: NSFetchedResultsControllerDelegate { @@ -1095,7 +1121,7 @@ private extension ChatViewModel { func setupObservers() { $inputText .removeDuplicates() - .sink { [weak self] _ in self?.inputTextUpdated() } + .sink { [weak self] _ in self?.inputTextFileUpdated() } .store(in: &subscriptions) chatFileService.updateFileFields @@ -1429,20 +1455,6 @@ private extension ChatViewModel { } } - func inputTextUpdated() { - guard !inputText.isEmpty else { - fee = "" - return - } - - let feeString = AdamantBalanceFormat.full.format( - AdamantMessage.text(inputText).fee, - withCurrencySymbol: AdmWalletService.currencySymbol - ) - - fee = "~\(feeString)" - } - func updatePartnerInformation() { guard let publicKey = chatroom?.partner?.publicKey else { return diff --git a/CommonKit/Sources/CommonKit/AdamantSecret.swift b/CommonKit/Sources/CommonKit/AdamantSecret.swift new file mode 100644 index 000000000..ef810ecb2 --- /dev/null +++ b/CommonKit/Sources/CommonKit/AdamantSecret.swift @@ -0,0 +1,17 @@ +// +// File.swift +// CommonKit +// +// Created by Leonid Vilner on 08.01.2025. +// + +import Foundation + +enum AdamantSecret { + // MARK: App data + static let appIdentifierPrefix = "J2L77FMN46" + + // MARK: Keychain + static let oldKeychainPass = "tertherherh" + static let keychainValuePassword = "wergwergwerg" +} From 45f3a340d6942f141ad3c06824c7130599f1856c Mon Sep 17 00:00:00 2001 From: Leonid Vilner Date: Fri, 10 Jan 2025 22:46:04 +0800 Subject: [PATCH 2/6] trello.com/c/b82n6AMp fixing files --- CommonKit/Sources/CommonKit/AdamantSecret.swift | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 CommonKit/Sources/CommonKit/AdamantSecret.swift diff --git a/CommonKit/Sources/CommonKit/AdamantSecret.swift b/CommonKit/Sources/CommonKit/AdamantSecret.swift deleted file mode 100644 index ef810ecb2..000000000 --- a/CommonKit/Sources/CommonKit/AdamantSecret.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// File.swift -// CommonKit -// -// Created by Leonid Vilner on 08.01.2025. -// - -import Foundation - -enum AdamantSecret { - // MARK: App data - static let appIdentifierPrefix = "J2L77FMN46" - - // MARK: Keychain - static let oldKeychainPass = "tertherherh" - static let keychainValuePassword = "wergwergwerg" -} From 15ff53a72ae61b610a4cce15d1331d597e68f787 Mon Sep 17 00:00:00 2001 From: Leonid Vilner Date: Sat, 11 Jan 2025 22:39:56 +0800 Subject: [PATCH 3/6] trello.com/c/b82n6AMp fixing issues --- .../Chat/View/ChatViewController.swift | 1 - .../Chat/ViewModel/ChatViewModel.swift | 21 ++++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Adamant/Modules/Chat/View/ChatViewController.swift b/Adamant/Modules/Chat/View/ChatViewController.swift index d519625a5..b309fc4d0 100644 --- a/Adamant/Modules/Chat/View/ChatViewController.swift +++ b/Adamant/Modules/Chat/View/ChatViewController.swift @@ -943,7 +943,6 @@ private extension ChatViewController { func closeFileToolbarView() { filesToolbarView.removeFromSuperview() messageInputBar.invalidateIntrinsicContentSize() - viewModel.inputTextFileUpdated() } func didTapTransfer(id: String) { diff --git a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift index ddbfce93b..a41c66935 100644 --- a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift +++ b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift @@ -938,8 +938,7 @@ final class ChatViewModel: NSObject { } filesPicked = oldFiles - - inputTextFileUpdated() + inputContentUpdated() case .failure(let error): dialog.send(.alert(error.localizedDescription)) @@ -1064,8 +1063,7 @@ extension ChatViewModel { } } - func inputTextFileUpdated() { - + func inputContentUpdated() { guard !inputText.isEmpty || filesPicked != nil else { fee = "" return @@ -1074,9 +1072,9 @@ extension ChatViewModel { var filesText: String = "" if let filesPicked { - filesText = filesPicked.map{ - ($0.name ?? "") + ($0.extenstion ?? "") - }.joined(separator: "") + filesText = filesPicked.map { + [$0.name, $0.extenstion].compactMap { $0 }.joined(separator: ".") + }.joined(separator: ";") } let feeString = AdamantBalanceFormat.full.format( @@ -1121,7 +1119,7 @@ private extension ChatViewModel { func setupObservers() { $inputText .removeDuplicates() - .sink { [weak self] _ in self?.inputTextFileUpdated() } + .sink { [weak self] _ in self?.inputContentUpdated() } .store(in: &subscriptions) chatFileService.updateFileFields @@ -1157,6 +1155,13 @@ private extension ChatViewModel { } .store(in: &subscriptions) + $filesPicked + .sink { [weak self] _ in + guard let self else { return } + inputContentUpdated() + } + .store(in: &subscriptions) + NotificationCenter.default .notifications(named: .AdamantVisibleWalletsService.visibleWallets) .sink { @MainActor [weak self] _ in self?.updateAttachmentButtonAvailability() } From ae6065dc80846f1e305e92d65f4e47e4de81147f Mon Sep 17 00:00:00 2001 From: Leonid Vilner <55400550+leonid174@users.noreply.github.com> Date: Tue, 14 Jan 2025 20:58:42 +0800 Subject: [PATCH 4/6] Update Package.resolved package downgrade --- Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved index ff7b1d3e3..07af8e013 100644 --- a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -285,8 +285,8 @@ "repositoryURL": "https://github.com/daltoniam/Starscream", "state": { "branch": null, - "revision": "c6bfd1af48efcc9a9ad203665db12375ba6b145a", - "version": "4.0.8" + "revision": "ac6c0fc9da221873e01bd1a0d4818498a71eef33", + "version": "4.0.6" } }, { From 9a3fa7731addf0ca5d59106cdb379cce4dda3734 Mon Sep 17 00:00:00 2001 From: Leonid Vilner <55400550+leonid174@users.noreply.github.com> Date: Tue, 14 Jan 2025 21:58:24 +0800 Subject: [PATCH 5/6] Update Package.resolved version fix --- .../xcshareddata/swiftpm/Package.resolved | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved index 07af8e013..5828488fd 100644 --- a/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -105,8 +105,8 @@ "repositoryURL": "https://github.com/google/GoogleDataTransport.git", "state": { "branch": null, - "revision": "a637d318ae7ae246b02d7305121275bc75ed5565", - "version": "9.4.0" + "revision": "aae45a320fd0d11811820335b1eabc8753902a40", + "version": "9.2.5" } }, { @@ -114,8 +114,8 @@ "repositoryURL": "https://github.com/google/GoogleUtilities.git", "state": { "branch": null, - "revision": "57a1d307f42df690fdef2637f3e5b776da02aad6", - "version": "7.13.3" + "revision": "bc27fad73504f3d4af235de451f02ee22586ebd3", + "version": "7.12.1" } }, { @@ -141,8 +141,8 @@ "repositoryURL": "https://github.com/nathantannar4/InputBarAccessoryView", "state": { "branch": null, - "revision": "c7acd5fa32e54cd7a44ad7eb9a7730da35b54c95", - "version": "6.5.1" + "revision": "17ced92a5dccb36512b408b6276353631d7cbe57", + "version": "6.3.0" } }, { @@ -159,8 +159,8 @@ "repositoryURL": "https://github.com/firebase/leveldb.git", "state": { "branch": null, - "revision": "a0bc79961d7be727d258d33d5a6b2f1023270ba1", - "version": "1.22.5" + "revision": "9d108e9112aa1d65ce508facf804674546116d9c", + "version": "1.22.3" } }, { @@ -177,8 +177,8 @@ "repositoryURL": "https://github.com/MessageKit/MessageKit.git", "state": { "branch": null, - "revision": "b024c1287ac30fb6ea2ee07169e6193efc11d972", - "version": "4.3.0" + "revision": "1993e8e90d4e9a61b8d9bc8ceb733964ce943376", + "version": "4.2.0" } }, { @@ -204,7 +204,7 @@ "repositoryURL": "https://github.com/rechsteiner/Parchment", "state": { "branch": "main", - "revision": "dfb23ea5118ca8bfbc578065627fccf4ec4a362e", + "revision": "13aad3e9308e8a4e38cb579430dbf66465418777", "version": null } }, @@ -222,8 +222,8 @@ "repositoryURL": "https://github.com/google/promises.git", "state": { "branch": null, - "revision": "540318ecedd63d883069ae7f1ed811a2df00b6ac", - "version": "2.4.0" + "revision": "e70e889c0196c76d22759eb50d6a0270ca9f1d9e", + "version": "2.3.1" } }, { @@ -276,7 +276,7 @@ "repositoryURL": "https://github.com/socketio/socket.io-client-swift", "state": { "branch": "master", - "revision": "42da871d9369f290d6ec4930636c40672143905b", + "revision": "175da8b5156f6b132436f0676cc84c2f6a766b6e", "version": null } }, From 30694640305d35658e613894d3e5fa4ba0225630 Mon Sep 17 00:00:00 2001 From: Leonid Vilner Date: Tue, 14 Jan 2025 22:03:35 +0800 Subject: [PATCH 6/6] trello.com/c/b82n6AMp --- Adamant/Modules/Chat/ViewModel/ChatViewModel.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift index a41c66935..30d45f73a 100644 --- a/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift +++ b/Adamant/Modules/Chat/ViewModel/ChatViewModel.swift @@ -938,7 +938,6 @@ final class ChatViewModel: NSObject { } filesPicked = oldFiles - inputContentUpdated() case .failure(let error): dialog.send(.alert(error.localizedDescription))