From bf803f199e8493c7860dce31f0820c28c5517403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bardon?= Date: Tue, 2 Aug 2022 17:31:32 +0200 Subject: [PATCH] chore: PR fix: Remove `keyEquivalent`s from `MessageMenu` items Also format --- .../Sources/ConversationFeature/Chat/Chat.swift | 4 ++-- .../ConversationFeature/Chat/ChatReducer.swift | 9 ++++----- .../ConversationFeature/Chat/MessageMenu.swift | 15 +-------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Prose/ProseLib/Sources/ConversationFeature/Chat/Chat.swift b/Prose/ProseLib/Sources/ConversationFeature/Chat/Chat.swift index abbab61e..88859356 100644 --- a/Prose/ProseLib/Sources/ConversationFeature/Chat/Chat.swift +++ b/Prose/ProseLib/Sources/ConversationFeature/Chat/Chat.swift @@ -218,7 +218,7 @@ struct ChatView: NSViewRepresentable { } extension ChatView.Coordinator: NSMenuDelegate { - func menuDidClose(_ menu: NSMenu) { + func menuDidClose(_: NSMenu) { self.viewStore.send(.menuDidClose) } } @@ -282,7 +282,7 @@ final class ViewStoreScriptMessageHandler: NSObject, WKScriptMessageHandler { extension WKUserContentController { func addEventHandler(_ handler: JSEventHandler, viewStore: ViewStore) { - let handlerName: String = "handler_" + handler.event.replacingOccurrences(of: ":", with: "_") + let handlerName = "handler_" + handler.event.replacingOccurrences(of: ":", with: "_") self.add( ViewStoreScriptMessageHandler(handler: handler, viewStore: viewStore), diff --git a/Prose/ProseLib/Sources/ConversationFeature/Chat/ChatReducer.swift b/Prose/ProseLib/Sources/ConversationFeature/Chat/ChatReducer.swift index bdc1319f..09f417a0 100644 --- a/Prose/ProseLib/Sources/ConversationFeature/Chat/ChatReducer.swift +++ b/Prose/ProseLib/Sources/ConversationFeature/Chat/ChatReducer.swift @@ -1,8 +1,6 @@ // -// File.swift -// -// -// Created by RĂ©mi Bardon on 02/08/2022. +// This file is part of prose-app-macos. +// Copyright (c) 2022 Prose Foundation // import ComposableArchitecture @@ -163,7 +161,8 @@ let chatReducer = Reducer< guard let reaction = payload.reaction.first else { return .none } if let messageId = payload.ids.first { - return environment.proseClient.toggleReaction(state.chatId, messageId, reaction).fireAndForget() + return environment.proseClient.toggleReaction(state.chatId, messageId, reaction) + .fireAndForget() } else { logger.notice("Could not toggle reaction: No message selected") return .none diff --git a/Prose/ProseLib/Sources/ConversationFeature/Chat/MessageMenu.swift b/Prose/ProseLib/Sources/ConversationFeature/Chat/MessageMenu.swift index cd03d399..53908a27 100644 --- a/Prose/ProseLib/Sources/ConversationFeature/Chat/MessageMenu.swift +++ b/Prose/ProseLib/Sources/ConversationFeature/Chat/MessageMenu.swift @@ -17,15 +17,6 @@ public enum MessageMenuAction: Equatable { enum Tag: Int { case copyText, edit, addReaction, remove - var keyEquivalent: String { - switch self { - case .copyText: return "c" - case .edit: return "e" - case .addReaction: return "r" - case .remove: return "d" - } - } - var systemImage: String? { switch self { case .copyText: return "doc.on.clipboard" @@ -61,11 +52,7 @@ public final class MessageMenu: NSMenu { action: Action?, isDisabled: Bool = false ) -> NSMenuItem { - let item = NSMenuItem( - title: title, - action: #selector(self.itemTapped(_:)), - keyEquivalent: action?.tag.keyEquivalent ?? "" - ) + let item = NSMenuItem(title: title, action: #selector(self.itemTapped(_:)), keyEquivalent: "") // Set target to receive the events item.target = self