Skip to content

Commit

Permalink
trello.com/c/b82n6AMp fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid174 committed Jan 11, 2025
1 parent 45f3a34 commit 15ff53a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,6 @@ private extension ChatViewController {
func closeFileToolbarView() {
filesToolbarView.removeFromSuperview()
messageInputBar.invalidateIntrinsicContentSize()
viewModel.inputTextFileUpdated()
}

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

filesPicked = oldFiles

inputTextFileUpdated()
inputContentUpdated()

case .failure(let error):
dialog.send(.alert(error.localizedDescription))
Expand Down Expand Up @@ -1064,8 +1063,7 @@ extension ChatViewModel {
}
}

func inputTextFileUpdated() {

func inputContentUpdated() {
guard !inputText.isEmpty || filesPicked != nil else {
fee = ""
return
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() }
Expand Down

0 comments on commit 15ff53a

Please sign in to comment.