[Chore] Use common for repeated code (#14454)
* [Chore] Use common for repeated code * [Chore] Removed empty file
This commit is contained in:
parent
bc7578ae85
commit
f55b646c20
|
@ -1,11 +0,0 @@
|
||||||
(ns status-im.ui.screens.activity-center.notification.contact-request.style
|
|
||||||
(:require [quo2.foundations.colors :as colors]))
|
|
||||||
|
|
||||||
(def context-tag-text
|
|
||||||
{:color colors/white})
|
|
||||||
|
|
||||||
(def user-avatar-tag-text
|
|
||||||
{:color colors/white})
|
|
||||||
|
|
||||||
(def user-avatar-tag
|
|
||||||
{:background-color colors/white-opa-10})
|
|
|
@ -3,16 +3,13 @@
|
||||||
[quo2.core :as quo2]
|
[quo2.core :as quo2]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.multiaccounts.core :as multiaccounts]
|
[status-im.ui.screens.activity-center.notification.common.view :as common]
|
||||||
[status-im.ui.screens.activity-center.notification.contact-request.style :as style]
|
|
||||||
[status-im.ui.screens.activity-center.utils :as activity-center.utils]
|
|
||||||
[status-im.utils.datetime :as datetime]
|
[status-im.utils.datetime :as datetime]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [id author message last-message] :as notification}]
|
[{:keys [id author message last-message] :as notification}]
|
||||||
(let [message (or message last-message)
|
(let [message (or message last-message)
|
||||||
contact (rf/sub [:contacts/contact-by-identity author])
|
|
||||||
pressable (case (:contact-request-state message)
|
pressable (case (:contact-request-state message)
|
||||||
constants/contact-request-message-state-accepted
|
constants/contact-request-message-state-accepted
|
||||||
;; NOTE(2022-09-21): We need to dispatch to
|
;; NOTE(2022-09-21): We need to dispatch to
|
||||||
|
@ -30,14 +27,7 @@
|
||||||
:icon :main-icons2/add-user
|
:icon :main-icons2/add-user
|
||||||
:timestamp (datetime/timestamp->relative (:timestamp notification))
|
:timestamp (datetime/timestamp->relative (:timestamp notification))
|
||||||
:unread? (not (:read notification))
|
:unread? (not (:read notification))
|
||||||
:context [[quo2/user-avatar-tag
|
:context [[common/user-avatar-tag author]
|
||||||
{:color :purple
|
|
||||||
:override-theme :dark
|
|
||||||
:size :small
|
|
||||||
:style style/user-avatar-tag
|
|
||||||
:text-style style/user-avatar-tag-text}
|
|
||||||
(activity-center.utils/contact-name contact)
|
|
||||||
(multiaccounts/displayed-photo contact)]
|
|
||||||
(i18n/label :t/contact-request-sent)]
|
(i18n/label :t/contact-request-sent)]
|
||||||
:message {:body (get-in message [:content :text])}
|
:message {:body (get-in message [:content :text])}
|
||||||
:status (case (:contact-request-state message)
|
:status (case (:contact-request-state message)
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
(ns status-im.ui.screens.activity-center.notification.contact-verification.style
|
|
||||||
(:require [quo2.foundations.colors :as colors]))
|
|
||||||
|
|
||||||
(def context-tag-text
|
|
||||||
{:color colors/white})
|
|
||||||
|
|
||||||
(def user-avatar-tag-text
|
|
||||||
{:color colors/white})
|
|
||||||
|
|
||||||
(def user-avatar-tag
|
|
||||||
{:background-color colors/white-opa-10})
|
|
|
@ -3,9 +3,7 @@
|
||||||
[quo2.core :as quo2]
|
[quo2.core :as quo2]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.multiaccounts.core :as multiaccounts]
|
[status-im.ui.screens.activity-center.notification.common.view :as common]
|
||||||
[status-im.ui.screens.activity-center.notification.contact-verification.style :as style]
|
|
||||||
[status-im.ui.screens.activity-center.utils :as activity-center.utils]
|
|
||||||
[status-im.utils.datetime :as datetime]
|
[status-im.utils.datetime :as datetime]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -17,24 +15,16 @@
|
||||||
|
|
||||||
(defn- context-tags
|
(defn- context-tags
|
||||||
[challenger? {:keys [author contact-verification-status]}]
|
[challenger? {:keys [author contact-verification-status]}]
|
||||||
(let [contact (rf/sub [:contacts/contact-by-identity author])]
|
[[common/user-avatar-tag author]
|
||||||
[[quo2/user-avatar-tag
|
(if challenger?
|
||||||
{:color :purple
|
(when (or (= contact-verification-status constants/contact-verification-status-accepted)
|
||||||
:override-theme :dark
|
(= contact-verification-status constants/contact-verification-status-trusted)
|
||||||
:size :small
|
(= contact-verification-status constants/contact-verification-status-untrustworthy))
|
||||||
:style style/user-avatar-tag
|
(str (str/lower-case (i18n/label :t/replied)) ":"))
|
||||||
:text-style style/user-avatar-tag-text}
|
(when (or (= contact-verification-status constants/contact-verification-status-accepted)
|
||||||
(activity-center.utils/contact-name contact)
|
(= contact-verification-status constants/contact-verification-status-pending)
|
||||||
(multiaccounts/displayed-photo contact)]
|
(= contact-verification-status constants/contact-verification-status-declined))
|
||||||
(if challenger?
|
(str (i18n/label :t/identity-verification-request-sent) ":")))])
|
||||||
(when (or (= contact-verification-status constants/contact-verification-status-accepted)
|
|
||||||
(= contact-verification-status constants/contact-verification-status-trusted)
|
|
||||||
(= contact-verification-status constants/contact-verification-status-untrustworthy))
|
|
||||||
(str (str/lower-case (i18n/label :t/replied)) ":"))
|
|
||||||
(when (or (= contact-verification-status constants/contact-verification-status-accepted)
|
|
||||||
(= contact-verification-status constants/contact-verification-status-pending)
|
|
||||||
(= contact-verification-status constants/contact-verification-status-declined))
|
|
||||||
(str (i18n/label :t/identity-verification-request-sent) ":")))]))
|
|
||||||
|
|
||||||
(defn- activity-message
|
(defn- activity-message
|
||||||
[challenger? {:keys [contact-verification-status message reply-message]}]
|
[challenger? {:keys [contact-verification-status message reply-message]}]
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
:unread? (not (:read notification))
|
:unread? (not (:read notification))
|
||||||
:context [[common/user-avatar-tag author]
|
:context [[common/user-avatar-tag author]
|
||||||
[quo2/text {:style style/tag-text} (str/lower-case (i18n/label :t/on))]
|
[quo2/text {:style style/tag-text} (str/lower-case (i18n/label :t/on))]
|
||||||
;; TODO (@smohamedjavid): The `group-avatar-tag` component
|
;; TODO (@smohamedjavid): The `group-avatar-tag` component
|
||||||
;; does NOT support displaying channel name along with community/chat name.
|
;; does NOT support displaying channel name along with community/chat name.
|
||||||
;; Need to update the component to support it.
|
;; Need to update the component to support it.
|
||||||
[quo2/group-avatar-tag chat-name {:size :small
|
[quo2/group-avatar-tag chat-name {:size :small
|
||||||
:override-theme :dark
|
:override-theme :dark
|
||||||
:color colors/primary-50
|
:color colors/primary-50
|
||||||
|
|
Loading…
Reference in New Issue