From 32086a28e81bd1ed360992c86950094f96353e47 Mon Sep 17 00:00:00 2001 From: fmodf Date: Thu, 11 Jul 2024 13:24:43 +0200 Subject: [PATCH] wip --- .../AppCore/Actions/AppActions.swift | 1 - .../AppCore/Actions/MessagesActions.swift | 3 --- .../AppCore/Actions/SharingActions.swift | 1 + .../AppCore/Middlewares/MessagesMiddleware.swift | 12 ------------ .../AppCore/Reducers/AppReducer.swift | 3 --- .../AppCore/Services/CameraService.swift | 5 ----- .../AppCore/Services/GalleryService.swift | 5 ----- .../AppCore/{Services => XMPP}/XMPPService.swift | 0 ConversationsClassic/ConversationsClassicApp.swift | 1 - .../Attachments/AttachmentMediaPickerView.swift | 7 +++---- 10 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 ConversationsClassic/AppCore/Actions/MessagesActions.swift delete mode 100644 ConversationsClassic/AppCore/Middlewares/MessagesMiddleware.swift delete mode 100644 ConversationsClassic/AppCore/Services/CameraService.swift delete mode 100644 ConversationsClassic/AppCore/Services/GalleryService.swift rename ConversationsClassic/AppCore/{Services => XMPP}/XMPPService.swift (100%) diff --git a/ConversationsClassic/AppCore/Actions/AppActions.swift b/ConversationsClassic/AppCore/Actions/AppActions.swift index 2ef748d..5484839 100644 --- a/ConversationsClassic/AppCore/Actions/AppActions.swift +++ b/ConversationsClassic/AppCore/Actions/AppActions.swift @@ -10,6 +10,5 @@ enum AppAction: Codable { case rostersAction(_ action: RostersAction) case chatsAction(_ action: ChatsAction) case conversationAction(_ action: ConversationAction) - case messagesAction(_ action: MessagesAction) case sharingAction(_ action: SharingAction) } diff --git a/ConversationsClassic/AppCore/Actions/MessagesActions.swift b/ConversationsClassic/AppCore/Actions/MessagesActions.swift deleted file mode 100644 index 880c563..0000000 --- a/ConversationsClassic/AppCore/Actions/MessagesActions.swift +++ /dev/null @@ -1,3 +0,0 @@ -enum MessagesAction: Codable { - case dumb -} diff --git a/ConversationsClassic/AppCore/Actions/SharingActions.swift b/ConversationsClassic/AppCore/Actions/SharingActions.swift index 7280298..3148cb3 100644 --- a/ConversationsClassic/AppCore/Actions/SharingActions.swift +++ b/ConversationsClassic/AppCore/Actions/SharingActions.swift @@ -6,6 +6,7 @@ enum SharingAction: Stateable { case shareLocation(lat: Double, lon: Double) case shareContact(jid: String) case shareDocuments([Data]) + case shareMedia(ids: [String]) case checkCameraAccess case setCameraAccess(Bool) diff --git a/ConversationsClassic/AppCore/Middlewares/MessagesMiddleware.swift b/ConversationsClassic/AppCore/Middlewares/MessagesMiddleware.swift deleted file mode 100644 index d7042d9..0000000 --- a/ConversationsClassic/AppCore/Middlewares/MessagesMiddleware.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Combine - -final class MessagesMiddleware { - static let shared = MessagesMiddleware() - - func middleware(state _: AppState, action: AppAction) -> AnyPublisher { - switch action { - default: - return Empty().eraseToAnyPublisher() - } - } -} diff --git a/ConversationsClassic/AppCore/Reducers/AppReducer.swift b/ConversationsClassic/AppCore/Reducers/AppReducer.swift index 53af1cb..35fcd93 100644 --- a/ConversationsClassic/AppCore/Reducers/AppReducer.swift +++ b/ConversationsClassic/AppCore/Reducers/AppReducer.swift @@ -28,9 +28,6 @@ extension AppState { case .conversationAction(let action): ConversationState.reducer(state: &state.conversationsState, action: action) - case .messagesAction: - break // messages actions are processed by MessagesMiddleware, and other components - case .sharingAction(let action): SharingState.reducer(state: &state.sharingState, action: action) } diff --git a/ConversationsClassic/AppCore/Services/CameraService.swift b/ConversationsClassic/AppCore/Services/CameraService.swift deleted file mode 100644 index aedeb5a..0000000 --- a/ConversationsClassic/AppCore/Services/CameraService.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -final class CameraService { - var dumb = false -} diff --git a/ConversationsClassic/AppCore/Services/GalleryService.swift b/ConversationsClassic/AppCore/Services/GalleryService.swift deleted file mode 100644 index 3588fba..0000000 --- a/ConversationsClassic/AppCore/Services/GalleryService.swift +++ /dev/null @@ -1,5 +0,0 @@ -import Foundation - -final class GalleryService { - var dumb = false -} diff --git a/ConversationsClassic/AppCore/Services/XMPPService.swift b/ConversationsClassic/AppCore/XMPP/XMPPService.swift similarity index 100% rename from ConversationsClassic/AppCore/Services/XMPPService.swift rename to ConversationsClassic/AppCore/XMPP/XMPPService.swift diff --git a/ConversationsClassic/ConversationsClassicApp.swift b/ConversationsClassic/ConversationsClassicApp.swift index c2d19d6..3abb615 100644 --- a/ConversationsClassic/ConversationsClassicApp.swift +++ b/ConversationsClassic/ConversationsClassicApp.swift @@ -14,7 +14,6 @@ let store = AppStore( RostersMiddleware.shared.middleware, ChatsMiddleware.shared.middleware, ConversationMiddleware.shared.middleware, - MessagesMiddleware.shared.middleware, SharingMiddleware.shared.middleware ] ) diff --git a/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift b/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift index 02b983d..17481fb 100644 --- a/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift +++ b/ConversationsClassic/View/Screens/Attachments/AttachmentMediaPickerView.swift @@ -125,8 +125,7 @@ struct AttachmentMediaPickerView: View { } .clipped() .onTapGesture { - // let ids = selectedMedia.map { $0.id } - // sendGalleryMedia(ids: ids) + store.dispatch(.sharingAction(.shareMedia(ids: selectedItems))) store.dispatch(.sharingAction(.showSharing(false))) } } @@ -190,9 +189,9 @@ private struct GridViewItem: View { .onTapGesture { isSelected.toggle() if isSelected { - selected.removeAll { $0 == item.id } - } else { selected.append(item.id) + } else { + selected.removeAll { $0 == item.id } } } } else {