diff --git a/locales/en.yml b/locales/en.yml index 5138f697..24bb73a8 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -50,7 +50,6 @@ main_page: received: "Received" system: "System" - show_resend_button: "Show Resend Button" resend_button_on_hover_desc: "Press And Hold To Send" state_text_enabled: "Enabled" @@ -120,6 +119,9 @@ config_page: hide: "Hide (Use Enter key to send)" show: "Show" show_and_disable_enter_key: "Show and disable sending using the Enter key." + show_resend_button: + label: "Show Resend Button" + desc: "When hovering over a sent message log, the resend button appears. Click to edit, long press to resend." font_family: label: "Font Family" ui_language: diff --git a/locales/ja.yml b/locales/ja.yml index a9a6901b..bd0ffe60 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -50,7 +50,6 @@ main_page: received: "受信" system: "システム" - show_resend_button: "再送信ボタンを表示する" resend_button_on_hover_desc: "長押しで送信" state_text_enabled: "有効" @@ -120,6 +119,9 @@ config_page: hide: "非表示 (エンターキーを使って送信)" show: "表示" show_and_disable_enter_key: "表示し、エンターキーでの送信を無効" + show_resend_button: + label: "再送信ボタンを表示する" + desc: "送信済メッセージログにマウスホバーすると、再送信ボタンが表示されます。クリックで編集モード、長押しで再送信します。" font_family: label: "使用フォント" ui_language: diff --git a/locales/ko.yml b/locales/ko.yml index 139f41a7..39df6d4a 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -47,7 +47,6 @@ main_page: received: "수신" system: "시스템" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "Enabled" diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index 0a13c7f8..dd1dafc7 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -47,7 +47,6 @@ main_page: received: "接受" system: "系统" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "启用" diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index 4fd2fce4..08210a7d 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -47,7 +47,6 @@ main_page: received: "已接收" system: "系統" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "啟用" diff --git a/src-python/config.py b/src-python/config.py index 64c09440..e7df74e5 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -407,6 +407,17 @@ class Config: self._MESSAGE_BOX_RATIO = value self.saveConfig(inspect.currentframe().f_code.co_name, value, immediate_save=True) + @property + @json_serializable('SHOW_RESEND_BUTTON') + def SHOW_RESEND_BUTTON(self): + return self._SHOW_RESEND_BUTTON + + @SHOW_RESEND_BUTTON.setter + def SHOW_RESEND_BUTTON(self, value): + if isinstance(value, bool): + self._SHOW_RESEND_BUTTON = value + self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property @json_serializable('FONT_FAMILY') def FONT_FAMILY(self): @@ -1090,6 +1101,7 @@ class Config: self._UI_SCALING = 100 self._TEXTBOX_UI_SCALING = 100 self._MESSAGE_BOX_RATIO = 10 + self._SHOW_RESEND_BUTTON = False self._FONT_FAMILY = "Yu Gothic UI" self._UI_LANGUAGE = "en" self._MAIN_WINDOW_GEOMETRY = { diff --git a/src-python/controller.py b/src-python/controller.py index 969fff98..760166f1 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -832,6 +832,20 @@ class Controller: config.MESSAGE_BOX_RATIO = data return {"status":200, "result":config.MESSAGE_BOX_RATIO} + @staticmethod + def getShowResendButton(*args, **kwargs) -> dict: + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + + @staticmethod + def setEnableShowResendButton(*args, **kwargs) -> dict: + config.SHOW_RESEND_BUTTON = True + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + + @staticmethod + def setDisableShowResendButton(*args, **kwargs) -> dict: + config.SHOW_RESEND_BUTTON = False + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + @staticmethod def getFontFamily(*args, **kwargs) -> dict: return {"status":200, "result":config.FONT_FAMILY} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 28207de5..fa1b0da9 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -131,6 +131,10 @@ mapping = { "/get/data/message_box_ratio": {"status": True, "variable":controller.getMessageBoxRatio}, "/set/data/message_box_ratio": {"status": True, "variable":controller.setMessageBoxRatio}, + "/get/data/show_resend_button": {"status": True, "variable":controller.getShowResendButton}, + "/set/enable/show_resend_button": {"status": True, "variable":controller.setEnableShowResendButton}, + "/set/disable/show_resend_button": {"status": True, "variable":controller.setDisableShowResendButton}, + "/get/data/font_family": {"status": True, "variable":controller.getFontFamily}, "/set/data/font_family": {"status": True, "variable":controller.setFontFamily}, diff --git a/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx b/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx index d9ecb7c6..29a300cb 100644 --- a/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx @@ -14,6 +14,7 @@ import { useUiScaling, useMessageLogUiScaling, useSendMessageButtonType, + useShowResendButton, useSelectedFontFamily, useTransparency, } from "@logics_configs"; @@ -22,6 +23,7 @@ import { SliderContainer, DropdownMenuContainer, RadioButtonContainer, + CheckboxContainer, } from "../_templates/Templates"; export const Appearance = () => { @@ -31,6 +33,7 @@ export const Appearance = () => { + > @@ -160,6 +163,20 @@ const SendMessageButtonTypeContainer = () => { ); }; +const ShowResendButtonContainer = () => { + const { t } = useTranslation(); + const { currentShowResendButton, toggleShowResendButton } = useShowResendButton(); + + return ( + + ); +}; + const FontFamilyContainer = () => { const { t } = useTranslation(); const { currentSelectedFontFamily, setSelectedFontFamily } = useSelectedFontFamily(); diff --git a/src-ui/app/main_page/main_section/message_container/log_box/message_container/MessageContainer.jsx b/src-ui/app/main_page/main_section/message_container/log_box/message_container/MessageContainer.jsx index 1298c8da..1dbc7607 100644 --- a/src-ui/app/main_page/main_section/message_container/log_box/message_container/MessageContainer.jsx +++ b/src-ui/app/main_page/main_section/message_container/log_box/message_container/MessageContainer.jsx @@ -4,7 +4,7 @@ import clsx from "clsx"; import styles from "./MessageContainer.module.scss"; import { MessageSubMenuContainer } from "./message_sub_menu_container/MessageSubMenuContainer"; import { useMessage } from "@logics_common"; -import { useIsVisibleResendButton } from "@logics_main"; +import { useShowResendButton } from "@logics_configs"; export const MessageContainer = ({ messages, status, category, created_at }) => { const { t } = useTranslation(); @@ -12,7 +12,7 @@ export const MessageContainer = ({ messages, status, category, created_at }) => sendMessage, updateMessageInputValue, } = useMessage(); - const { currentIsVisibleResendButton } = useIsVisibleResendButton(); + const { currentShowResendButton } = useShowResendButton(); const [is_hovered, setIsHovered] = useState(false); const [is_locked, setIsLocked] = useState(false); @@ -77,7 +77,7 @@ export const MessageContainer = ({ messages, status, category, created_at }) => )} - {currentIsVisibleResendButton.data && is_sent_message && is_hovered ? ( + {currentShowResendButton.data && is_sent_message && is_hovered ? ( { @@ -13,18 +11,12 @@ export const MessageLogSettingsContainer = (props) => { const [is_opened, setIsOpened] = useState(false); const [is_hovered, setIsHovered] = useState(false); - const { currentIsVisibleResendButton, toggleIsVisibleResendButton } = useIsVisibleResendButton(); - const container_class_name = clsx(styles.container, { [styles.to_visible_toggle_bar]: props.to_visible_toggle_bar, [styles.is_hovered]: is_hovered, [styles.is_opened]: is_opened }); - const toggleVisibleResendButton = () => { - toggleIsVisibleResendButton(); - }; - return ( setIsHovered(true)} @@ -38,15 +30,6 @@ export const MessageLogSettingsContainer = (props) => { - - {t("main_page.message_log.show_resend_button")} - - ); diff --git a/src-ui/logics/configs/appearance/useShowResendButton.js b/src-ui/logics/configs/appearance/useShowResendButton.js new file mode 100644 index 00000000..10a9fd00 --- /dev/null +++ b/src-ui/logics/configs/appearance/useShowResendButton.js @@ -0,0 +1,28 @@ +import { useStore_ShowResendButton } from "@store"; +import { useStdoutToPython } from "@useStdoutToPython"; + +export const useShowResendButton = () => { + const { asyncStdoutToPython } = useStdoutToPython(); + const { currentShowResendButton, updateShowResendButton, pendingShowResendButton } = useStore_ShowResendButton(); + + const getShowResendButton = () => { + pendingShowResendButton(); + asyncStdoutToPython("/get/data/show_resend_button"); + }; + + const toggleShowResendButton = () => { + pendingShowResendButton(); + if (currentShowResendButton.data) { + asyncStdoutToPython("/set/disable/show_resend_button"); + } else { + asyncStdoutToPython("/set/enable/show_resend_button"); + } + }; + + return { + currentShowResendButton, + getShowResendButton, + updateShowResendButton, + toggleShowResendButton, + }; +}; \ No newline at end of file diff --git a/src-ui/logics/configs/index.js b/src-ui/logics/configs/index.js index aadb1519..f2552bd4 100644 --- a/src-ui/logics/configs/index.js +++ b/src-ui/logics/configs/index.js @@ -4,6 +4,7 @@ export { useMessageLogUiScaling } from "./appearance/useMessageLogUiScaling"; export { useSelectedFontFamily } from "./appearance/useSelectedFontFamily"; export { useTransparency } from "./appearance/useTransparency"; export { useSendMessageButtonType } from "./others/useSendMessageButtonType"; +export { useShowResendButton } from "./appearance/useShowResendButton"; export { useUiLanguage } from "./appearance/useUiLanguage"; export { useUiScaling } from "./appearance/useUiScaling"; diff --git a/src-ui/logics/main/index.js b/src-ui/logics/main/index.js index 14e817dc..827e8cef 100644 --- a/src-ui/logics/main/index.js +++ b/src-ui/logics/main/index.js @@ -1,4 +1,3 @@ -export { useIsVisibleResendButton } from "./useIsVisibleResendButton"; export { useIsMainPageCompactMode } from "./useIsMainPageCompactMode"; export { useLanguageSettings } from "./useLanguageSettings"; export { useMainFunction } from "./useMainFunction"; diff --git a/src-ui/logics/main/useIsVisibleResendButton.js b/src-ui/logics/main/useIsVisibleResendButton.js deleted file mode 100644 index c479af0b..00000000 --- a/src-ui/logics/main/useIsVisibleResendButton.js +++ /dev/null @@ -1,15 +0,0 @@ -import { useStore_IsVisibleResendButton } from "@store"; - -export const useIsVisibleResendButton = () => { - const { currentIsVisibleResendButton, updateIsVisibleResendButton } = useStore_IsVisibleResendButton(); - - const toggleIsVisibleResendButton = () => { - updateIsVisibleResendButton(!currentIsVisibleResendButton.data); - }; - - return { - currentIsVisibleResendButton, - toggleIsVisibleResendButton, - updateIsVisibleResendButton, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index 8961c2cf..a4a1ad87 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -149,6 +149,10 @@ export const ROUTE_META_LIST = [ { endpoint: "/get/data/send_message_button_type", ns: configs, hook_name: "useSendMessageButtonType", method_name: "updateSendMessageButtonType" }, { endpoint: "/set/data/send_message_button_type", ns: configs, hook_name: "useSendMessageButtonType", method_name: "updateSendMessageButtonType" }, + { endpoint: "/get/data/show_resend_button", ns: configs, hook_name: "useShowResendButton", method_name: "updateShowResendButton" }, + { endpoint: "/set/enable/show_resend_button", ns: configs, hook_name: "useShowResendButton", method_name: "updateShowResendButton" }, + { endpoint: "/set/disable/show_resend_button", ns: configs, hook_name: "useShowResendButton", method_name: "updateShowResendButton" }, + { endpoint: "/get/data/font_family", ns: configs, hook_name: "useSelectedFontFamily", method_name: "updateSelectedFontFamily" }, { endpoint: "/set/data/font_family", ns: configs, hook_name: "useSelectedFontFamily", method_name: "updateSelectedFontFamily" }, diff --git a/src-ui/store.js b/src-ui/store.js index 159385ae..23b865a4 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -172,7 +172,6 @@ export const { atomInstance: Atom_MessageLogs, useHook: useStore_MessageLogs } = // export const { atomInstance: Atom_MessageLogs, useHook: useStore_MessageLogs } = createAtomWithHook(generateTestConversationData(20), "MessageLogs"); // For testing export const { atomInstance: Atom_MessageInputBoxRatio, useHook: useStore_MessageInputBoxRatio } = createAtomWithHook(20, "MessageInputBoxRatio"); export const { atomInstance: Atom_MessageInputValue, useHook: useStore_MessageInputValue } = createAtomWithHook("", "MessageInputValue"); -export const { atomInstance: Atom_IsVisibleResendButton, useHook: useStore_IsVisibleResendButton } = createAtomWithHook(false, "IsVisibleResendButton", {is_state_ok: true}); @@ -213,6 +212,7 @@ export const { atomInstance: Atom_UiLanguage, useHook: useStore_UiLanguage } = c export const { atomInstance: Atom_UiScaling, useHook: useStore_UiScaling } = createAtomWithHook(100, "UiScaling"); export const { atomInstance: Atom_MessageLogUiScaling, useHook: useStore_MessageLogUiScaling } = createAtomWithHook(100, "MessageLogUiScaling"); export const { atomInstance: Atom_SendMessageButtonType, useHook: useStore_SendMessageButtonType } = createAtomWithHook("show", "SendMessageButtonType"); +export const { atomInstance: Atom_ShowResendButton, useHook: useStore_ShowResendButton } = createAtomWithHook(false, "ShowResendButton"); export const { atomInstance: Atom_SelectedFontFamily, useHook: useStore_SelectedFontFamily } = createAtomWithHook("Yu Gothic UI", "SelectedFontFamily"); export const { atomInstance: Atom_SelectableFontFamilyList, useHook: useStore_SelectableFontFamilyList } = createAtomWithHook({}, "SelectableFontFamilyList"); export const { atomInstance: Atom_Transparency, useHook: useStore_Transparency } = createAtomWithHook(100, "Transparency");
{t("main_page.message_log.show_resend_button")}