From 31867d43acffcc18f6dc4bd8f3c7b48f026eb6c1 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 7 May 2024 19:48:43 +0400 Subject: [PATCH] call button from contacts --- apps/ios/Shared/Model/ChatModel.swift | 6 ++++++ apps/ios/Shared/Views/Chat/ChatInfoView.swift | 4 ++-- apps/ios/Shared/Views/Chat/ChatView.swift | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/ios/Shared/Model/ChatModel.swift b/apps/ios/Shared/Model/ChatModel.swift index a4651e1d42..8671cd133d 100644 --- a/apps/ios/Shared/Model/ChatModel.swift +++ b/apps/ios/Shared/Model/ChatModel.swift @@ -43,6 +43,11 @@ private func addTermItem(_ items: inout [TerminalItem], _ item: TerminalItem) { items.append(item) } +enum OpenChatAction { + case message + case call(media: CallMediaType) +} + final class ChatModel: ObservableObject { @Published var onboardingStage: OnboardingStage? @Published var setDeliveryReceipts = false @@ -64,6 +69,7 @@ final class ChatModel: ObservableObject { // map of connections network statuses, key is agent connection id @Published var networkStatuses: Dictionary = [:] // current chat + @Published var openChatAction: OpenChatAction? @Published var chatId: String? @Published var reversedChatItems: [ChatItem] = [] var chatItemStatuses: Dictionary = [:] diff --git a/apps/ios/Shared/Views/Chat/ChatInfoView.swift b/apps/ios/Shared/Views/Chat/ChatInfoView.swift index 57919fffd3..8971b14b84 100644 --- a/apps/ios/Shared/Views/Chat/ChatInfoView.swift +++ b/apps/ios/Shared/Views/Chat/ChatInfoView.swift @@ -420,9 +420,9 @@ struct ChatInfoView: View { dismiss() makeCall = .audio } else { + chatModel.openChatAction = .call(media: .audio) chatModel.chatId = chat.id } - // CallController.shared.startCall(contact, .audio) } label: { actionButton("phone.fill", "call") } @@ -435,9 +435,9 @@ struct ChatInfoView: View { dismiss() makeCall = .video } else { + chatModel.openChatAction = .call(media: .video) chatModel.chatId = chat.id } - // CallController.shared.startCall(contact, .video) } label: { actionButton("video.fill", "video") } diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 912f2a390a..898590896a 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -257,6 +257,12 @@ struct ChatView: View { await markChatUnread(chat, unreadChat: false) } } + switch chatModel.openChatAction { + case .some(.message): () + case let .some(.call(media)): makeCall = media + case .none: () + } + chatModel.openChatAction = nil } private func searchToolbar() -> some View {