Skip to content

Commit

Permalink
add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed May 11, 2022
1 parent c1af45f commit d5116eb
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 154 deletions.
7 changes: 7 additions & 0 deletions src/status_im/contact/core.cljs
Expand Up @@ -5,6 +5,7 @@
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.navigation :as navigation]
[status-im.utils.fx :as fx]
[status-im.async-storage.core :as async-storage]
[taoensso.timbre :as log]
[status-im.constants :as constants]
[status-im.contact.block :as contact.block]))
Expand Down Expand Up @@ -133,3 +134,9 @@
nickname
#(re-frame/dispatch [:sanitize-messages-and-process-response %]))
(navigation/navigate-back)))

(fx/defn switch-mutual-contact-requests-enabled
{:events [:multiaccounts.ui/switch-mutual-contact-requests-enabled]}
[{:keys [db]} enabled?]
{::async-storage/set! {:mutual-contact-requests-enabled? enabled?}
:db (assoc db :mutual-contact-requests/enabled? enabled?)})
13 changes: 12 additions & 1 deletion src/status_im/multiaccounts/login/core.cljs
Expand Up @@ -31,7 +31,6 @@
[taoensso.timbre :as log]
[status-im.data-store.invitations :as data-store.invitations]
[status-im.chat.models.link-preview :as link-preview]
[status-im.chat.models :as chat.models]
[status-im.utils.mobile-sync :as utils.mobile-sync]
[status-im.async-storage.core :as async-storage]
[status-im.notifications-center.core :as notifications-center]
Expand Down Expand Up @@ -97,6 +96,13 @@
:wallet-connect-enabled?
#(re-frame/dispatch [:multiaccounts.ui/switch-wallet-connect-enabled %]))))

(re-frame/reg-fx
::initialize-mutual-contact-requests
(fn []
(async-storage/get-item
:mutual-contact-requests-enabled?
#(re-frame/dispatch [:multiaccounts.ui/switch-mutual-contact-requests-enabled %]))))

(defn rpc->accounts [accounts]
(reduce (fn [acc {:keys [chat type wallet] :as account}]
(if chat
Expand Down Expand Up @@ -362,6 +368,10 @@
[cofx]
{::initialize-wallet-connect nil})

(fx/defn initialize-mutual-contact-requests
[cofx]
{::initialize-mutual-contact-requests nil})

(fx/defn get-node-config-callback
{:events [::get-node-config-callback]}
[{:keys [db] :as cofx} node-config-json]
Expand Down Expand Up @@ -397,6 +407,7 @@
(initialize-appearance)
(initialize-communities-enabled)
(initialize-wallet-connect)
(initialize-mutual-contact-requests)
(get-node-config)
(communities/fetch)
(logging/set-log-level (:log-level multiaccount))
Expand Down
7 changes: 4 additions & 3 deletions src/status_im/subs.cljs
Expand Up @@ -42,7 +42,6 @@
[quo.design-system.colors :as colors]
[status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]))

(def mutual-contact-requests-enabled? true)
;; TOP LEVEL ===========================================================================================================

(defn reg-root-key-sub [sub-name db-key]
Expand Down Expand Up @@ -278,6 +277,8 @@
(reg-root-key-sub :wallet-connect/session-managed :wallet-connect/session-managed)
(reg-root-key-sub :contact-requests/pending :contact-requests/pending)

(reg-root-key-sub :mutual-contact-requests/enabled? :mutual-contact-requests/enabled?)

(re-frame/reg-sub
:communities
:<- [:raw-communities]
Expand Down Expand Up @@ -954,7 +955,6 @@
(fn [ui-props [_ prop]]
(get ui-props prop)))


(re-frame/reg-sub
:chats/current-chat-contact
:<- [:contacts/contacts]
Expand Down Expand Up @@ -1056,7 +1056,8 @@
:<- [:contacts/blocked-set]
:<- [:contacts/contacts]
:<- [:chat/inputs]
(fn [[{:keys [group-chat chat-id] :as current-chat} my-public-key community blocked-users-set contacts inputs]]
:<- [:mutual-contact-requests/enabled?]
(fn [[{:keys [group-chat chat-id] :as current-chat} my-public-key community blocked-users-set contacts inputs mutual-contact-requests-enabled?]]
(when current-chat
(cond-> current-chat
(chat.models/public-chat? current-chat)
Expand Down
12 changes: 12 additions & 0 deletions src/status_im/ui/screens/advanced_settings/views.cljs
Expand Up @@ -14,6 +14,7 @@
wakuv2-flag
current-fleet
webview-debug
mutual-contact-requests-enabled?
wallet-connect-enabled?]}]
(keep
identity
Expand Down Expand Up @@ -114,6 +115,15 @@
[:multiaccounts.ui/waku-bloom-filter-mode-switched (not waku-bloom-filter-mode)])
:accessory :switch
:active waku-bloom-filter-mode}
{:size :small
:title (i18n/label :t/mutual-contact-requests)
:accessibility-label :wallet-connect-settings-switch
:container-margin-bottom 8
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/switch-mutual-contact-requests-enabled (not mutual-contact-requests-enabled?)])
:accessory :switch
:active mutual-contact-requests-enabled?}
{:size :small
:title (i18n/label :t/wallet-connect)
:accessibility-label :wallet-connect-settings-switch
Expand Down Expand Up @@ -141,6 +151,7 @@
transactions-management-enabled? [:wallet/transactions-management-enabled?]
current-log-level [:log-level/current-log-level]
current-fleet [:fleets/current-fleet]
mutual-contact-requests-enabled? [:mutual-contact-requests/enabled?]
wallet-connect-enabled? [:wallet-connect/enabled?]]
[list/flat-list
{:data (flat-list-data
Expand All @@ -153,6 +164,7 @@
:wakuv2-flag wakuv2-flag
:waku-bloom-filter-mode waku-bloom-filter-mode
:webview-debug webview-debug
:mutual-contact-requests-enabled? mutual-contact-requests-enabled?
:wallet-connect-enabled? wallet-connect-enabled?})
:key-fn (fn [_ i] (str i))
:render-fn render-item}]))
96 changes: 48 additions & 48 deletions src/status_im/ui/screens/chat/message/message.cljs
Expand Up @@ -47,7 +47,7 @@

(defview mention-element [from]
(letsubs [contact-name [:contacts/contact-name-by-identity from]]
contact-name))
contact-name))

(def edited-at-text (str "" (i18n/label :t/edited)))

Expand Down Expand Up @@ -87,25 +87,25 @@
(defview quoted-message
[_ {:keys [from parsed-text image]} outgoing current-public-key public? pinned]
(letsubs [contact-name [:contacts/contact-name-by-identity from]]
[react/view {:style (style/quoted-message-container (and outgoing (not pinned)))}
[react/view {:style style/quoted-message-author-container}
[chat.utils/format-reply-author
from
contact-name
current-public-key
(partial style/quoted-message-author (and outgoing (not pinned)))
(and outgoing (not pinned))]]
(if (and image
[react/view {:style (style/quoted-message-container (and outgoing (not pinned)))}
[react/view {:style style/quoted-message-author-container}
[chat.utils/format-reply-author
from
contact-name
current-public-key
(partial style/quoted-message-author (and outgoing (not pinned)))
(and outgoing (not pinned))]]
(if (and image
;; Disabling images for public-chats
(not public?))
[react/fast-image {:style {:width 56
:height 56
:background-color :black
:border-radius 4}
:source {:uri image}}]
[react/text {:style (style/quoted-message-text (and outgoing (not pinned)))
:number-of-lines 5}
(components.reply/get-quoted-text-with-mentions parsed-text)])]))
(not public?))
[react/fast-image {:style {:width 56
:height 56
:background-color :black
:border-radius 4}
:source {:uri image}}]
[react/text {:style (style/quoted-message-text (and outgoing (not pinned)))
:number-of-lines 5}
(components.reply/get-quoted-text-with-mentions parsed-text)])]))

(defn render-inline [message-text outgoing pinned content-type acc {:keys [type literal destination]}]
(case type
Expand Down Expand Up @@ -268,42 +268,42 @@

(defview message-author-name [from opts]
(letsubs [contact-with-names [:contacts/contact-by-identity from]]
(chat.utils/format-author contact-with-names opts)))
(chat.utils/format-author contact-with-names opts)))

(defview message-my-name [opts]
(letsubs [contact-with-names [:multiaccount/contact]]
(chat.utils/format-author contact-with-names opts)))
(chat.utils/format-author contact-with-names opts)))

(defview community-content [{:keys [community-id] :as message}]
(letsubs [{:keys [name description verified] :as community} [:communities/community community-id]
communities-enabled? [:communities/enabled?]]
(when (and communities-enabled? community)
[react/view {:style (assoc (style/message-wrapper message)
:margin-vertical 10
:margin-left 8
:width 271)}
(when verified
[react/view (style/community-verified)
[react/text {:style {:font-size 13
:color colors/blue}} (i18n/label :t/communities-verified)]])
[react/view (style/community-message verified)
[react/view {:width 62
:padding-left 14}
(if (= community-id constants/status-community-id)
[react/image {:source (resources/get-image :status-logo)
:style {:width 40
:height 40}}]
[communities.icon/community-icon community])]
[react/view {:padding-right 14 :flex 1}
[react/text {:style {:font-weight "700" :font-size 17}}
name]
[react/text description]]]
[react/view (style/community-view-button)
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to
:community
{:community-id (:id community)}])}
[react/text {:style {:text-align :center
:color colors/blue}} (i18n/label :t/view)]]]])))
(when (and communities-enabled? community)
[react/view {:style (assoc (style/message-wrapper message)
:margin-vertical 10
:margin-left 8
:width 271)}
(when verified
[react/view (style/community-verified)
[react/text {:style {:font-size 13
:color colors/blue}} (i18n/label :t/communities-verified)]])
[react/view (style/community-message verified)
[react/view {:width 62
:padding-left 14}
(if (= community-id constants/status-community-id)
[react/image {:source (resources/get-image :status-logo)
:style {:width 40
:height 40}}]
[communities.icon/community-icon community])]
[react/view {:padding-right 14 :flex 1}
[react/text {:style {:font-weight "700" :font-size 17}}
name]
[react/text description]]]
[react/view (style/community-view-button)
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to
:community
{:community-id (:id community)}])}
[react/text {:style {:text-align :center
:color colors/blue}} (i18n/label :t/view)]]]])))

(defn message-content-wrapper
"Author, userpic and delivery wrapper"
Expand Down

0 comments on commit d5116eb

Please sign in to comment.