Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trello.com/c/b82n6AMp adding cost to media/files #638

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Adamant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,7 @@
938F7D562955C1DA001915CA /* XCRemoteSwiftPackageReference "MessageKit" */,
4184F16F2A33044E00D7B8B9 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
3AC76E3B2AB09118008042C4 /* XCRemoteSwiftPackageReference "Elegant-Emoji-Picker" */,
84B761662D2E79A50022DCA9 /* XCRemoteSwiftPackageReference "PopupKit" */,
);
productRefGroup = E913C8EF1FFFA51D001A83F7 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -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";
Expand Down
32 changes: 16 additions & 16 deletions Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@
"repositoryURL": "https://github.com/google/GoogleDataTransport.git",
"state": {
"branch": null,
"revision": "aae45a320fd0d11811820335b1eabc8753902a40",
"version": "9.2.5"
"revision": "a637d318ae7ae246b02d7305121275bc75ed5565",
"version": "9.4.0"
}
},
{
"package": "GoogleUtilities",
"repositoryURL": "https://github.com/google/GoogleUtilities.git",
"state": {
"branch": null,
"revision": "bc27fad73504f3d4af235de451f02ee22586ebd3",
"version": "7.12.1"
"revision": "57a1d307f42df690fdef2637f3e5b776da02aad6",
"version": "7.13.3"
}
},
{
Expand All @@ -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"
}
},
{
Expand All @@ -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"
}
},
{
Expand All @@ -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"
}
},
{
Expand All @@ -204,7 +204,7 @@
"repositoryURL": "https://github.com/rechsteiner/Parchment",
"state": {
"branch": "main",
"revision": "13aad3e9308e8a4e38cb579430dbf66465418777",
"revision": "dfb23ea5118ca8bfbc578065627fccf4ec4a362e",
"version": null
}
},
Expand All @@ -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"
}
},
{
Expand Down Expand Up @@ -276,7 +276,7 @@
"repositoryURL": "https://github.com/socketio/socket.io-client-swift",
"state": {
"branch": "master",
"revision": "175da8b5156f6b132436f0676cc84c2f6a766b6e",
"revision": "42da871d9369f290d6ec4930636c40672143905b",
"version": null
}
},
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove packages updating

}
},
{
Expand Down
1 change: 1 addition & 0 deletions Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ private extension ChatViewController {
func closeFileToolbarView() {
filesToolbarView.removeFromSuperview()
messageInputBar.invalidateIntrinsicContentSize()
viewModel.inputTextFileUpdated()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not do it here.

@ObservableValue var filesPicked: [FileResult]?

We can easily observe new files from the ChatViewModel

}

func didTapTransfer(id: String) {
Expand Down
42 changes: 27 additions & 15 deletions Adamant/Modules/Chat/ViewModel/ChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,9 @@ final class ChatViewModel: NSObject {
}

filesPicked = oldFiles

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not add extra spaces between simple lined of code

inputTextFileUpdated()

case .failure(let error):
dialog.send(.alert(error.localizedDescription))
}
Expand Down Expand Up @@ -1060,6 +1063,29 @@ extension ChatViewModel {
self?.dateHeaderHidden = true
}
}

func inputTextFileUpdated() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename to inputContentUpdated


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this extra space

guard !inputText.isEmpty || filesPicked != nil else {
fee = ""
return
}

var filesText: String = ""

if let filesPicked {
filesText = filesPicked.map{
($0.name ?? "") + ($0.extenstion ?? "")
}.joined(separator: "")
}
Copy link
Member

@just-software-dev just-software-dev Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let filesText = filesPicked?.map {
   [$0.name, $0.extenstion].compactMap { $0 }.joined(separator: ".")
}?.joined(separator: ";") ?? .empty


let feeString = AdamantBalanceFormat.full.format(
AdamantMessage.text(inputText + filesText).fee,
withCurrencySymbol: AdmWalletService.currencySymbol
)

fee = "~\(feeString)"
}
}

extension ChatViewModel: NSFetchedResultsControllerDelegate {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down