From 8600c1d3a58aa53ec928783cfa0b9d46a0cf99b0 Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Wed, 17 Apr 2024 15:12:27 +0200 Subject: [PATCH] Allow for env variables for configuring delete-message undo time limit for toasts (#19653) * tweak: allow for env variable to configure undo-time-limit when deleting a message in chat * tweak: add env variable undo timeout for deleting messages for everyone * tweak: extend timeout duration for undo toast when deleting a message for a user * tweak: extend timeout duration for undo toast when deleting a message for everyone --- .env.e2e | 2 ++ src/status_im/config.cljs | 13 +++++++++++++ .../chat/messenger/messages/drawers/view.cljs | 5 +++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.env.e2e b/.env.e2e index f47607e159..ed270643dc 100644 --- a/.env.e2e +++ b/.env.e2e @@ -35,3 +35,5 @@ LOCAL_PAIRING_ENABLED=1 FAST_CREATE_COMMUNITY_ENABLED=1 TEST_NETWORKS_ENABLED=1 SHOW_NOT_IMPLEMENTED_FEATURES=1 +DELETE_MESSAGE_FOR_ME_UNDO_TIME_LIMIT=10000 +DELETE_MESSAGE_UNDO_TIME_LIMIT=10000 diff --git a/src/status_im/config.cljs b/src/status_im/config.cljs index c18dfbe8e2..841cfb321c 100644 --- a/src/status_im/config.cljs +++ b/src/status_im/config.cljs @@ -2,6 +2,7 @@ (:require [clojure.string :as string] [react-native.config :as react-native-config] + [status-im.constants :as constants] [utils.ens.core :as utils.ens] [utils.ethereum.chain :as chain])) @@ -70,6 +71,18 @@ ; currently not supported in status-go (def enable-remove-profile-picture? false) +(defn env-variable->int + [env-var-name default-value] + (js/parseInt (get-config env-var-name default-value))) + +(def delete-message-for-me-undo-time-limit-ms + (env-variable->int :DELETE_MESSAGE_FOR_ME_UNDO_TIME_LIMIT + constants/delete-message-for-me-undo-time-limit-ms)) + +(def delete-message-undo-time-limit-ms + (env-variable->int :DELETE_MESSAGE_UNDO_TIME_LIMIT + constants/delete-message-undo-time-limit-ms)) + (def verify-transaction-chain-id (js/parseInt (get-config :VERIFY_TRANSACTION_CHAIN_ID "1"))) (def verify-transaction-url (if (= :mainnet (chain/chain-id->chain-keyword verify-transaction-chain-id)) diff --git a/src/status_im/contexts/chat/messenger/messages/drawers/view.cljs b/src/status_im/contexts/chat/messenger/messages/drawers/view.cljs index 037a442eba..c0aa534435 100644 --- a/src/status_im/contexts/chat/messenger/messages/drawers/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/drawers/view.cljs @@ -7,6 +7,7 @@ [react-native.gesture :as gesture] [reagent.core :as reagent] [status-im.common.contact-list-item.view :as contact-list-item] + [status-im.config :as config] [status-im.constants :as constants] [status-im.contexts.chat.messenger.composer.reply.view :as reply] [status-im.contexts.chat.messenger.messages.drawers.style :as style] @@ -140,7 +141,7 @@ (rf/dispatch [:hide-bottom-sheet]) (rf/dispatch [:chat.ui/delete-message-for-me message-data - constants/delete-message-for-me-undo-time-limit-ms])) + config/delete-message-for-me-undo-time-limit-ms])) :label (i18n/label :t/delete-for-me) :icon :i/delete @@ -155,7 +156,7 @@ :on-press (fn [] (rf/dispatch [:hide-bottom-sheet]) (rf/dispatch [:chat.ui/delete-message message-data - constants/delete-message-undo-time-limit-ms])) + config/delete-message-undo-time-limit-ms])) :label (i18n/label :t/delete-for-everyone) :icon :i/delete :id :delete-for-all}])))