From a02ca5b04fb5dc6944c94208d27a05a92215f6ac Mon Sep 17 00:00:00 2001 From: fmodf Date: Sun, 14 Jul 2024 12:48:04 +0200 Subject: [PATCH] wip --- .../AppCore/Middlewares/SharingMiddleware.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ConversationsClassic/AppCore/Middlewares/SharingMiddleware.swift b/ConversationsClassic/AppCore/Middlewares/SharingMiddleware.swift index 3a8c1bb..312029f 100644 --- a/ConversationsClassic/AppCore/Middlewares/SharingMiddleware.swift +++ b/ConversationsClassic/AppCore/Middlewares/SharingMiddleware.swift @@ -7,7 +7,7 @@ import UIKit final class SharingMiddleware { static let shared = SharingMiddleware() - func middleware(state _: AppState, action: AppAction) -> AnyPublisher { + func middleware(state: AppState, action: AppAction) -> AnyPublisher { switch action { case .sharingAction(.checkCameraAccess): return Future { promise in @@ -114,6 +114,15 @@ final class SharingMiddleware { } return Empty().eraseToAnyPublisher() + case .sharingAction(.shareLocation(let lat, let lon)): + if let chat = state.conversationsState.currentChat { + let msg = "geo:\(lat),\(lon)" + return Just(.conversationAction(.sendMessage(from: chat.account, to: chat.participant, body: msg))) + .eraseToAnyPublisher() + } else { + return Empty().eraseToAnyPublisher() + } + default: return Empty().eraseToAnyPublisher() }