diff --git a/src/status_im/ui/screens/chat/components/messages_skeleton.cljs b/src/quo2/components/loaders/skeleton.cljs similarity index 93% rename from src/status_im/ui/screens/chat/components/messages_skeleton.cljs rename to src/quo2/components/loaders/skeleton.cljs index ba7fdc450e..1a6b0029c6 100644 --- a/src/status_im/ui/screens/chat/components/messages_skeleton.cljs +++ b/src/quo2/components/loaders/skeleton.cljs @@ -1,6 +1,6 @@ -(ns status-im.ui.screens.chat.components.messages-skeleton - (:require [status-im.ui.components.react :as react] - [react-native.core :as rn] +(ns quo2.components.loaders.skeleton + (:require [react-native.core :as rn] + [react-native.masked-view :as masked-view] [reagent.core :as reagent] [react-native.reanimated :as reanimated] [quo2.foundations.colors :as colors])) @@ -34,7 +34,7 @@ {:width window-width :height "100%"})] (reanimated/animate-shared-value-with-repeat translate-x window-width 1000 :linear (- 1) false) - [react/masked-view + [masked-view/masked-view {:style {:height message-skeleton-height} :maskElement (reagent/as-element [rn/view {:style {:height message-skeleton-height @@ -67,11 +67,11 @@ :end {:x 1 :y 0} :style animated-gradient-style}]]]))]) -(defn messages-skeleton [parent-height] +(defn skeleton [parent-height] (let [number-of-skeletons (int (Math/floor (/ parent-height message-skeleton-height)))] [rn/view {:style {:background-color (colors/theme-colors colors/white colors/neutral-90) :flex 1}} (for [n (range number-of-skeletons)] - [message-skeleton {:key n}])])) \ No newline at end of file + [message-skeleton {:key n}])])) diff --git a/src/quo2/core.cljs b/src/quo2/core.cljs index e079c3a8c2..44bc7099b9 100644 --- a/src/quo2/core.cljs +++ b/src/quo2/core.cljs @@ -40,7 +40,8 @@ quo2.components.tags.status-tags quo2.components.navigation.page-nav quo2.components.selectors.disclaimer - quo2.components.selectors.selectors)) + quo2.components.selectors.selectors + quo2.components.loaders.skeleton)) (def button quo2.components.buttons.button/button) (def dynamic-button quo2.components.buttons.dynamic-button/dynamic-button) @@ -68,6 +69,8 @@ (def page-nav quo2.components.navigation.page-nav/page-nav) (def disclaimer quo2.components.selectors.disclaimer/disclaimer) (def checkbox quo2.components.selectors.selectors/checkbox) +(def skeleton quo2.components.loaders.skeleton/skeleton) + ;;;; AVATAR (def account-avatar quo2.components.avatars.account-avatar/account-avatar) (def channel-avatar quo2.components.avatars.channel-avatar/channel-avatar) @@ -88,10 +91,7 @@ (def discover-card quo2.components.community.discover-card/discover-card) (def token-gating quo2.components.community.token-gating/token-gating) - ;;;; DIVIDERS - - (def divider-label quo2.components.dividers.divider-label/divider-label) (def new-messages quo2.components.dividers.new-messages/new-messages) diff --git a/src/react_native/platform.cljs b/src/react_native/platform.cljs index a3543ab37c..cfe7df6216 100644 --- a/src/react_native/platform.cljs +++ b/src/react_native/platform.cljs @@ -5,5 +5,9 @@ (def os (when platform (.-OS ^js platform))) +(def version (when platform (.-Version ^js platform))) + (def android? (= os "android")) (def ios? (= os "ios")) + +(def low-device? (and android? (< version 29))) diff --git a/src/status_im/bottom_sheet/core.cljs b/src/status_im/bottom_sheet/core.cljs index 10fc193309..588b8ed9b8 100644 --- a/src/status_im/bottom_sheet/core.cljs +++ b/src/status_im/bottom_sheet/core.cljs @@ -21,4 +21,4 @@ {:events [:bottom-sheet/hide]} [{:keys [db]}] {:hide-bottom-sheet nil - :db (assoc db :bottom-sheet/show? false)}) \ No newline at end of file + :db (assoc db :bottom-sheet/show? false)}) diff --git a/src/status_im/chat/models/delete_message.cljs b/src/status_im/chat/models/delete_message.cljs index 976be11803..7bebc4a5b3 100644 --- a/src/status_im/chat/models/delete_message.cljs +++ b/src/status_im/chat/models/delete_message.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.models.delete-message (:require [re-frame.core :as re-frame] [status-im.chat.models.message-list :as message-list] - [status-im.chat.models.pin-message :as models.pin-message] [status-im.ethereum.json-rpc :as json-rpc] [status-im.utils.datetime :as datetime] [status-im.utils.fx :as fx] @@ -81,7 +80,7 @@ :on-error #(log/error "failed to delete message " {:message-id message-id :error %}) :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]} :dispatch (and (get-in db [:pin-messages chat-id message-id]) - [::models.pin-message/send-pin-message {:chat-id chat-id :message-id message-id :pinned false}])))) + [:pin-message/send-pin-message {:chat-id chat-id :message-id message-id :pinned false}])))) (defn- filter-pending-send-messages "traverse all messages find not yet synced deleted? messages" diff --git a/src/status_im/chat/models/loading.cljs b/src/status_im/chat/models/loading.cljs index 87c74724f8..ca1bb0c1dd 100644 --- a/src/status_im/chat/models/loading.cljs +++ b/src/status_im/chat/models/loading.cljs @@ -7,7 +7,6 @@ [status-im.chat.models.message-list :as message-list] [taoensso.timbre :as log] [status-im.ethereum.json-rpc :as json-rpc] - [status-im.chat.models.pin-message :as models.pin-message] [status-im.notifications-center.core :as notification-center])) (defn cursor->clock-value @@ -176,5 +175,5 @@ {:db (assoc-in db [:pagination-info chat-id :messages-initialized?] now) :utils/dispatch-later [{:ms 50 :dispatch [:chat.ui/mark-all-read-pressed chat-id]} (when-not (get-in cofx [:db :chats chat-id :public?]) - {:ms 100 :dispatch [::models.pin-message/load-pin-messages chat-id]})]} + {:ms 100 :dispatch [:pin-message/load-pin-messages chat-id]})]} (load-more-messages chat-id true)))) diff --git a/src/status_im/transport/message/core.cljs b/src/status_im/transport/message/core.cljs index 722eecfb4e..64171f9697 100644 --- a/src/status_im/transport/message/core.cljs +++ b/src/status_im/transport/message/core.cljs @@ -2,7 +2,7 @@ status-im.transport.message.core (:require [status-im.activity-center.core :as activity-center] [status-im.chat.models.message :as models.message] - [status-im.chat.models.pin-message :as models.pin-message] + [status-im2.contexts.chat.messages.pin.events :as messages.pin] [status-im.chat.models :as models.chat] [status-im.chat.models.reactions :as models.reactions] [status-im2.setup.config :as config] @@ -117,7 +117,7 @@ (js-delete response-js "pinMessages") (fx/merge cofx (process-next response-js sync-handler) - (models.pin-message/receive-signal (map data-store.messages/<-rpc pin-messages)))) + (messages.pin/receive-signal (map data-store.messages/<-rpc pin-messages)))) (seq removed-chats) (let [removed-chats-clj (types/js->clj removed-chats)] diff --git a/src/status_im/ui/screens/bottom_sheets/views.cljs b/src/status_im/ui/screens/bottom_sheets/views.cljs index b7cd6202b2..a3782688a1 100644 --- a/src/status_im/ui/screens/bottom_sheets/views.cljs +++ b/src/status_im/ui/screens/bottom_sheets/views.cljs @@ -7,7 +7,8 @@ [status-im.ui.screens.keycard.views :as keycard] [status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings] [status-im.ui.screens.multiaccounts.key-storage.views :as key-storage] - [status-im.ui.screens.multiaccounts.recover.views :as recover.views])) + [status-im.ui.screens.multiaccounts.recover.views :as recover.views] + [status-im2.contexts.chat.messages.pin.list.view :as pin.list])) (defn bottom-sheet [] (let [{:keys [show? view options]} @(re-frame/subscribe [:bottom-sheet]) @@ -41,7 +42,10 @@ (merge recover.views/bottom-sheet) (= view :migrate-account-password) - (merge key-storage/migrate-account-password))] + (merge key-storage/migrate-account-password) + + (= view :pinned-messages-list) + (merge {:content pin.list/pinned-messages-list}))] [quo/bottom-sheet opts (when content [content (when options options)])])) diff --git a/src/status_im/ui/screens/chat/message/gap.cljs b/src/status_im/ui/screens/chat/message/gap.cljs index 50c4b811b6..68db77a5ad 100644 --- a/src/status_im/ui/screens/chat/message/gap.cljs +++ b/src/status_im/ui/screens/chat/message/gap.cljs @@ -4,8 +4,8 @@ [re-frame.core :as re-frame] [status-im.i18n.i18n :as i18n] [status-im.utils.datetime :as datetime] - [status-im.ui.screens.chat.components.messages-skeleton :as messages-skeleton] - [status-im.ui.screens.chat.styles.input.gap :as style])) + [status-im.ui.screens.chat.styles.input.gap :as style] + [quo2.core :as quo2])) (defn on-press [chat-id gap-ids] @@ -29,7 +29,7 @@ :style {:height (if in-progress? window-height 48)}} [react/view {:style style/label-container} (if in-progress? - [messages-skeleton/messages-skeleton window-height] + [quo2/skeleton window-height] [react/nested-text {:style (style/gap-text (and connected? use-status-nodes?))} (i18n/label (if first-gap? :t/load-more-messages :t/fetch-messages)) diff --git a/src/status_im/ui/screens/chat/message/message.cljs b/src/status_im/ui/screens/chat/message/message.cljs index d488a737cd..2b87924bde 100644 --- a/src/status_im/ui/screens/chat/message/message.cljs +++ b/src/status_im/ui/screens/chat/message/message.cljs @@ -25,7 +25,6 @@ [status-im.ui.screens.communities.icon :as communities.icon] [status-im.ui.components.animation :as animation] [status-im.chat.models.images :as images] - [status-im.chat.models.pin-message :as models.pin-message] [status-im.ui.components.fast-image :as fast-image]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) @@ -428,8 +427,8 @@ (if (and (not pinned) (> (count pinned-messages) 2)) (do (js/setTimeout (fn [] (re-frame/dispatch [:dismiss-keyboard])) 500) - (re-frame/dispatch [::models.pin-message/show-pin-limit-modal chat-id])) - (re-frame/dispatch [::models.pin-message/send-pin-message (assoc message :pinned (not pinned))])))) + (re-frame/dispatch [:pin-message/show-pin-limit-modal chat-id])) + (re-frame/dispatch [:pin-message/send-pin-message (assoc message :pinned (not pinned))])))) (defn on-long-press-fn [on-long-press {:keys [pinned message-pin-enabled outgoing edit-enabled show-input?] :as message} content] (on-long-press diff --git a/src/status_im/ui/screens/chat/message/pinned_message.cljs b/src/status_im/ui/screens/chat/message/pinned_message.cljs index d2a3d59c5f..2850f9ff43 100644 --- a/src/status_im/ui/screens/chat/message/pinned_message.cljs +++ b/src/status_im/ui/screens/chat/message/pinned_message.cljs @@ -5,7 +5,6 @@ [status-im.ui.components.react :as react] [quo.core :as quo] [reagent.core :as reagent] - [status-im.chat.models.pin-message :as models.pin-message] [status-im.ui.components.list.views :as list] [status-im.utils.handlers :refer [ (count pinned-messages) 2)) (do (js/setTimeout (fn [] (re-frame/dispatch [:dismiss-keyboard])) 500) - (re-frame/dispatch [::models.pin-message/show-pin-limit-modal chat-id])) - (re-frame/dispatch [::models.pin-message/send-pin-message (assoc message :pinned (not pinned))])))) + (re-frame/dispatch [:pin-message/show-pin-limit-modal chat-id])) + (re-frame/dispatch [:pin-message/send-pin-message (assoc message :pinned (not pinned))])))) (defn on-long-press-fn [on-long-press {:keys [pinned message-pin-enabled outgoing edit-enabled show-input? community? can-delete-message-for-everyone?] :as message} content] (on-long-press @@ -779,61 +775,9 @@ :timestamp-str (time/timestamp->time whisper-timestamp) :edit-enabled edit-enabled)]) -(def list-key-fn #(or (:message-id %) (:value %))) - -(defn pinned-messages-list [chat-id] - (let [pinned-messages (vec (vals (rf/sub [:chats/pinned chat-id]))) - current-chat (rf/sub [:chats/current-chat]) - community (rf/sub [:communities/community (:community-id current-chat)])] - [rn/view {:accessibility-label :pinned-messages-list} - [quo2/text {:size :heading-1 - :weight :semi-bold - :style {:margin-horizontal 20}} - (i18n/label :t/pinned-messages)] - (when community - [rn/view {:style {:flex-direction :row - :background-color (colors/theme-colors colors/neutral-10 colors/neutral-80) - :border-radius 20 - :align-items :center - :align-self :flex-start - :margin-horizontal 20 - :padding 4 - :margin-top 8}} - [chat-icon/chat-icon-view-toolbar chat-id (:group-chat current-chat) (:chat-name current-chat) (:color current-chat) (:emoji current-chat) 22] - [rn/text {:style {:margin-left 6 :margin-right 4 :color (colors/theme-colors colors/neutral-100 colors/white)}} (:name community)] - [icons/icon - :i/chevron-right - {:color (colors/theme-colors colors/neutral-50 colors/neutral-40) - :width 12 - :height 12}] - [rn/text {:style {:margin-left 4 - :margin-right 8 - :color (colors/theme-colors colors/neutral-100 colors/white)}} (str "# " (:chat-name current-chat))]]) - (if (> (count pinned-messages) 0) - [list/flat-list - {:data pinned-messages - :render-fn message-render-fn - :key-fn list-key-fn - :separator [rn/view {:background-color (colors/theme-colors colors/neutral-10 colors/neutral-80) :height 1 :margin-top 8}]}] - [rn/view {:style {:justify-content :center - :align-items :center - :margin-top 20}} - [rn/view {:style {:width 120 - :height 120 - :justify-content :center - :align-items :center - :border-width 1}} [icons/icon :i/placeholder]] - [quo2/text {:weight :semi-bold - :style {:margin-top 20}} - (i18n/label :t/no-pinned-messages)] - [quo2/text {:size :paragraph-2} - (i18n/label (if community :t/no-pinned-messages-community-desc :t/no-pinned-messages-desc))]])])) - (defn pin-system-message [{:keys [from in-popover? timestamp-str chat-id] :as message} {:keys [modal close-modal]}] (let [response-to (:response-to (:content message))] - [rn/touchable-opacity {:on-press (fn [] - (rf/dispatch [:bottom-sheet/show-sheet - {:content #(pinned-messages-list chat-id)}])) + [rn/touchable-opacity {:on-press #(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id]) :active-opacity 1 :style (merge {:flex-direction :row :margin-vertical 8} (style/message-wrapper message))} [rn/view {:style {:width photos.style/default-size @@ -870,36 +814,3 @@ [rn/view (style/message-view message) [rn/view (style/message-view-content) [render-parsed-text message (:parsed-text content)]]]]])) - -(defn pinned-banner [chat-id] - (let [pinned-messages (rf/sub [:chats/pinned chat-id]) - latest-pin-text (get-in (last (vals pinned-messages)) [:content :text]) - pins-count (count (seq pinned-messages))] - (when (> pins-count 0) - [rn/touchable-opacity - {:accessibility-label :pinned-banner - :style {:height 50 - :background-color colors/primary-50-opa-20 - :flex-direction :row - :align-items :center - :padding-horizontal 20 - :padding-vertical 10} - :active-opacity 1 - :on-press (fn [] - (re-frame/dispatch [:bottom-sheet/show-sheet - {:content #(pinned-messages-list chat-id)}]))} - [pin-icon (colors/theme-colors colors/neutral-100 colors/white) 20] - [rn/text {:number-of-lines 1 - :style (merge typography/paragraph-2 {:margin-left 10 - :margin-right 50 - :color (colors/theme-colors colors/neutral-100 colors/white)})} latest-pin-text] - [rn/view {:accessibility-label :pins-count - :style {:position :absolute - :right 22 - :height 20 - :width 20 - :border-radius 8 - :justify-content :center - :align-items :center - :background-color colors/neutral-80-opa-5}} - [rn/text {:style (merge typography/label typography/font-medium {:color (colors/theme-colors colors/neutral-100 colors/white)})} pins-count]]]))) diff --git a/src/status_im/ui2/screens/chat/messages/pinned_message.cljs b/src/status_im/ui2/screens/chat/messages/pinned_message.cljs deleted file mode 100644 index e9349d679b..0000000000 --- a/src/status_im/ui2/screens/chat/messages/pinned_message.cljs +++ /dev/null @@ -1,51 +0,0 @@ -(ns status-im.ui2.screens.chat.messages.pinned-message - (:require [status-im.i18n.i18n :as i18n] - [quo.react :as react] - [react-native.reanimated :as reanimated] - [quo.react-native :as rn] - [quo2.foundations.typography :as typography] - [quo2.foundations.colors :as colors] - [status-im.chat.models.pin-message :as models.pin-message] - [status-im.utils.handlers :refer [evt]] - [status-im.ui2.screens.chat.messages.style :as style] - [quo2.components.icon :as icons])) - -(defn pin-limit-popover [chat-id pinned-messages-list] - [:f> - (fn [] - (let [width (evt [::models.pin-message/hide-pin-limit-modal chat-id]) - (>evt [:bottom-sheet/show-sheet - {:content #(pinned-messages-list chat-id)}])) - :style (style/view-pinned-messages)} - [rn/text {:style (merge typography/paragraph-2 typography/font-medium {:color colors/white})} (i18n/label :t/view-pinned-messages)]]] - [rn/touchable-opacity {:accessibility-label :close-pin-limit-popover - :active-opacity 1 - :on-press #(>evt [::models.pin-message/hide-pin-limit-modal chat-id]) - :style {:position :absolute - :top 16 - :right 16}} - [icons/icon :i/close {:color (colors/theme-colors colors/white colors/neutral-100) - :height 8 - :width 8}]]]))]) diff --git a/src/status_im/ui2/screens/chat/messages/style.cljs b/src/status_im/ui2/screens/chat/pin_limit_popover/style.cljs similarity index 90% rename from src/status_im/ui2/screens/chat/messages/style.cljs rename to src/status_im/ui2/screens/chat/pin_limit_popover/style.cljs index 392db19695..6e2a31a392 100644 --- a/src/status_im/ui2/screens/chat/messages/style.cljs +++ b/src/status_im/ui2/screens/chat/pin_limit_popover/style.cljs @@ -1,4 +1,4 @@ -(ns status-im.ui2.screens.chat.messages.style +(ns status-im.ui2.screens.chat.pin-limit-popover.style (:require [quo2.foundations.colors :as colors])) (defn pin-popover [width] @@ -18,7 +18,7 @@ :justify-content :center :align-items :center}) -(defn pin-alert-circle [] +(def pin-alert-circle {:width 18 :height 18 :border-radius 9 @@ -27,7 +27,7 @@ :justify-content :center :align-items :center}) -(defn view-pinned-messages [] +(def view-pinned-messages {:background-color colors/primary-60 :border-radius 8 :justify-content :center diff --git a/src/status_im/ui2/screens/chat/pin_limit_popover/view.cljs b/src/status_im/ui2/screens/chat/pin_limit_popover/view.cljs new file mode 100644 index 0000000000..89363c2d27 --- /dev/null +++ b/src/status_im/ui2/screens/chat/pin_limit_popover/view.cljs @@ -0,0 +1,51 @@ +(ns status-im.ui2.screens.chat.pin-limit-popover.view + (:require [i18n.i18n :as i18n] + [quo2.foundations.colors :as colors] + [react-native.reanimated :as reanimated] + [react-native.core :as rn] + [quo2.core :as quo] + [utils.re-frame :as rf] + [status-im.ui2.screens.chat.pin-limit-popover.style :as style] + ;; TODO move to status-im2 + [quo.react :as react])) + +;; TODO (flexsurfer) this should be an in-app notification component in quo2 https://github.com/status-im/status-mobile/issues/14527 +(defn pin-limit-popover [chat-id] + [:f> + (fn [] + (let [width (rf/sub [:dimensions/window-width]) + show-pin-limit-modal? (rf/sub [:chats/pin-modal chat-id]) + opacity-animation (reanimated/use-shared-value 0) + z-index-animation (reanimated/use-shared-value -1)] + (react/effect! #(do + (reanimated/set-shared-value opacity-animation (reanimated/with-timing (if show-pin-limit-modal? 1 0))) + (reanimated/set-shared-value z-index-animation (reanimated/with-timing (if show-pin-limit-modal? 10 -1))))) + [reanimated/view {:style (reanimated/apply-animations-to-style + {:opacity opacity-animation + :z-index z-index-animation} + (style/pin-popover width)) + :accessibility-label :pin-limit-popover} + [rn/view {:style (style/pin-alert-container)} + [rn/view {:style style/pin-alert-circle} + [rn/text {:style {:color colors/danger-50}} "!"]]] + [rn/view {:style {:margin-left 8}} + [quo/text {:weight :semi-bold :color (colors/theme-colors colors/white colors/neutral-100)} (i18n/label :t/cannot-pin-title)] + [quo/text {:size :paragraph-2 :color (colors/theme-colors colors/white colors/neutral-100)} (i18n/label :t/cannot-pin-desc)] + [rn/touchable-opacity + {:accessibility-label :view-pinned-messages + :active-opacity 1 + :on-press (fn [] + (rf/dispatch [:pin-message/hide-pin-limit-modal chat-id]) + (rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id])) + :style style/view-pinned-messages} + [quo/text {:size :paragraph-2 :weight :medium :color colors/white} (i18n/label :t/view-pinned-messages)]]] + [rn/touchable-opacity {:accessibility-label :close-pin-limit-popover + :active-opacity 1 + :on-press #(rf/dispatch [:pin-message/hide-pin-limit-modal chat-id]) + :style {:position :absolute + :top 16 + :right 16}} + [quo/icon :i/close {:color (colors/theme-colors colors/white colors/neutral-100) + :size 8}]]]))]) + + diff --git a/src/status_im/ui2/screens/chat/pinned_banner/view.cljs b/src/status_im/ui2/screens/chat/pinned_banner/view.cljs new file mode 100644 index 0000000000..f3ad7cfa37 --- /dev/null +++ b/src/status_im/ui2/screens/chat/pinned_banner/view.cljs @@ -0,0 +1,32 @@ +(ns status-im.ui2.screens.chat.pinned-banner.view + (:require [react-native.core :as rn] + [quo2.foundations.colors :as colors] + [quo2.core :as quo])) + +;; TODO (flexsurfer) this should be a banner component in quo2 https://github.com/status-im/status-mobile/issues/14528 +(defn pinned-banner [{:keys [latest-pin-text pins-count on-press]}] + [rn/touchable-opacity + {:accessibility-label :pinned-banner + :style {:height 50 + :background-color colors/primary-50-opa-20 + :flex-direction :row + :align-items :center + :padding-horizontal 20 + :padding-vertical 10} + :active-opacity 1 + :on-press on-press} + [quo/icon :i/pin {:size 20}] + [quo/text {:number-of-lines 1 + :size :paragraph-2 + :style {:margin-left 10 :margin-right 50}} + latest-pin-text] + [rn/view {:accessibility-label :pins-count + :style {:position :absolute + :right 22 + :height 20 + :width 20 + :border-radius 8 + :justify-content :center + :align-items :center + :background-color colors/neutral-80-opa-5}} + [quo/text {:size :label :weight :medium} pins-count]]]) diff --git a/src/status_im2/common/constants.cljs b/src/status_im2/common/constants.cljs new file mode 100644 index 0000000000..4e93348788 --- /dev/null +++ b/src/status_im2/common/constants.cljs @@ -0,0 +1,194 @@ +(ns status-im2.common.constants) + +(def ^:const ms-in-bg-for-require-bioauth 5000) + +(def ^:const content-type-text 1) +(def ^:const content-type-sticker 2) +(def ^:const content-type-status 3) +(def ^:const content-type-emoji 4) +(def ^:const content-type-command 5) +(def ^:const content-type-system-text 6) +(def ^:const content-type-image 7) +(def ^:const content-type-audio 8) +(def ^:const content-type-community 9) +(def ^:const content-type-gap 10) +(def ^:const content-type-contact-request 11) ;; TODO: temp, will be removed + +(def ^:const contact-request-state-none 0) +(def ^:const contact-request-state-mutual 1) +(def ^:const contact-request-state-sent 2) +(def ^:const contact-request-state-received 3) +(def ^:const contact-request-state-dismissed 4) + +(def ^:const contact-verification-status-unknown 0) +(def ^:const contact-verification-status-pending 1) +(def ^:const contact-verification-status-accepted 2) +(def ^:const contact-verification-status-declined 3) +(def ^:const contact-verification-status-cancelled 4) +(def ^:const contact-verification-status-trusted 5) +(def ^:const contact-verification-status-untrustworthy 6) + +(def ^:const emoji-reaction-love 1) +(def ^:const emoji-reaction-thumbs-up 2) +(def ^:const emoji-reaction-thumbs-down 3) +(def ^:const emoji-reaction-laugh 4) +(def ^:const emoji-reaction-sad 5) +(def ^:const emoji-reaction-angry 6) + +(def ^:const one-to-one-chat-type 1) +(def ^:const public-chat-type 2) +(def ^:const private-group-chat-type 3) +(def ^:const profile-chat-type 4) +(def ^:const timeline-chat-type 5) +(def ^:const community-chat-type 6) + +(def ^:const contact-request-message-state-none 0) +(def ^:const contact-request-message-state-pending 1) +(def ^:const contact-request-message-state-accepted 2) +(def ^:const contact-request-message-state-declined 3) + +(def request-to-join-pending-state 1) + +(def reactions {emoji-reaction-love :i/love + emoji-reaction-thumbs-up :i/thumbs-up + emoji-reaction-thumbs-down :i/thumbs-down + emoji-reaction-laugh :i/laugh + emoji-reaction-sad :i/sad + emoji-reaction-angry :i/angry}) + +(def ^:const invitation-state-unknown 0) +(def ^:const invitation-state-requested 1) +(def ^:const invitation-state-rejected 2) +(def ^:const invitation-state-approved 3) +(def ^:const invitation-state-granted 4) +(def ^:const invitation-state-removed 5) + +(def ^:const message-type-one-to-one 1) +(def ^:const message-type-public-group 2) +(def ^:const message-type-private-group 3) +(def ^:const message-type-private-group-system-message 4) +(def ^:const message-type-community-chat 5) +(def ^:const message-type-gap 6) + +(def ^:const command-state-request-address-for-transaction 1) +(def ^:const command-state-request-address-for-transaction-declined 2) +(def ^:const command-state-request-address-for-transaction-accepted 3) +(def ^:const command-state-request-transaction 4) +(def ^:const command-state-request-transaction-declined 5) +(def ^:const command-state-transaction-pending 6) +(def ^:const command-state-transaction-sent 7) + +(def ^:const profile-pictures-show-to-contacts-only 1) +(def ^:const profile-pictures-show-to-everyone 2) +(def ^:const profile-pictures-show-to-none 3) + +(def ^:const profile-pictures-visibility-contacts-only 1) +(def ^:const profile-pictures-visibility-everyone 2) +(def ^:const profile-pictures-visibility-none 3) + +(def ^:const min-password-length 6) +(def ^:const max-group-chat-participants 20) +(def ^:const default-number-of-messages 20) +(def ^:const default-number-of-pin-messages 3) + +(def ^:const mailserver-password "status-offline-inbox") + +(def ^:const send-transaction-failed-parse-response 1) +(def ^:const send-transaction-failed-parse-params 2) +(def ^:const send-transaction-no-account-selected 3) +(def ^:const send-transaction-invalid-tx-sender 4) +(def ^:const send-transaction-err-decrypt 5) + +(def ^:const web3-send-transaction "eth_sendTransaction") +(def ^:const web3-personal-sign "personal_sign") +(def ^:const web3-eth-sign "eth_sign") +(def ^:const web3-sign-typed-data "eth_signTypedData") +(def ^:const web3-sign-typed-data-v3 "eth_signTypedData_v3") +(def ^:const web3-sign-typed-data-v4 "eth_signTypedData_v4") + +(def ^:const web3-keycard-sign-typed-data "keycard_signTypedData") + +(def ^:const status-create-address "status_createaddress") + +(def ^:const community-no-membership-access 1) +(def ^:const community-invitation-only-access 2) +(def ^:const community-on-request-access 3) + +;; Community rules for joining +(def ^:const community-rule-ens-only "ens-only") + +(def ^:const community-channel-access-no-membership 1) +(def ^:const community-channel-access-invitation-only 2) +(def ^:const community-channel-access-on-request 3) + +; BIP44 Wallet Root Key, the extended key from which any wallet can be derived +(def ^:const path-wallet-root "m/44'/60'/0'/0") +; EIP1581 Root Key, the extended key from which any whisper key/encryption key can be derived +(def ^:const path-eip1581 "m/43'/60'/1581'") +; BIP44-0 Wallet key, the default wallet key +(def ^:const path-default-wallet (str path-wallet-root "/0")) +; EIP1581 Chat Key 0, the default whisper key +(def ^:const path-whisper (str path-eip1581 "/0'/0")) + +(def ^:const path-default-wallet-keyword (keyword path-default-wallet)) +(def ^:const path-whisper-keyword (keyword path-whisper)) +(def ^:const path-wallet-root-keyword (keyword path-wallet-root)) +(def ^:const path-eip1581-keyword (keyword path-eip1581)) + +(def ^:const method-id-transfer "0xa9059cbb") +(def ^:const method-id-approve "0x095ea7b3") +(def ^:const method-id-approve-and-call "0xcae9ca51") + +(def regx-emoji #"^((?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])+$") +(def regx-bold #"\*[^*]+\*") +(def regx-italic #"~[^~]+~") +(def regx-backquote #"`[^`]+`") +(def regx-universal-link #"((^https?://join.status.im/)|(^status-im://))[\x00-\x7F]+$") +(def regx-community-universal-link #"((^https?://join.status.im/)|(^status-im://))c/([\x00-\x7F]+)$") +(def regx-deep-link #"((^ethereum:.*)|(^status-im://[\x00-\x7F]+$))") + +(def ^:const dapp-permission-contact-code "contact-code") +(def ^:const dapp-permission-web3 "web3") +(def ^:const dapp-permission-qr-code "qr-code") +(def ^:const api-response "api-response") +(def ^:const api-request "api-request") +(def ^:const history-state-changed "history-state-changed") +(def ^:const web3-send-async-read-only "web3-send-async-read-only") +(def ^:const web3-send-async-callback "web3-send-async-callback") +(def ^:const scan-qr-code "scan-qr-code") + +(def ^:const faq "https://status.im/faq/") +(def ^:const faq-keycard (str faq "#keycard")) +(def ^:const keycard-integration-link "https://status.im/keycard-integration") + +(def ^:const status-community-id "0x039b2da47552aa117a96ea8f1d4d108ba66637c7517a3c94a57b99dbb8a002eda2") + +(def ^:const timeline-chat-id "@timeline70bd746ddcc12beb96b2c9d572d0784ab137ffc774f5383e50585a932080b57cca0484b259e61cecbaa33a4c98a300a") + +(def ^:const two-mins (* 2 60)) +(def ^:const one-day (* 60 60 24)) +(def ^:const three-days (* one-day 3)) +(def ^:const one-week (* one-day 7)) +(def ^:const one-month (* one-day 31)) + +(def ^:const privacy-policy-link "https://status.im/privacy-policy/") +(def ^:const terms-of-service-link "https://status.im/terms-of-use") +(def ^:const docs-link "https://status.im/docs/") +(def ^:const principles-link "https://our.status.im/our-principles/") + +(def ^:const visibility-status-unknown 0) +(def ^:const visibility-status-automatic 1) +(def ^:const visibility-status-dnd 2) +(def ^:const visibility-status-always-online 3) +(def ^:const visibility-status-inactive 4) + +(def ^:const wallet-connect-version-1 1) +(def ^:const wallet-connect-version-2 2) + +(def ^:const sticker-pack-status-installed 1) +(def ^:const sticker-pack-status-pending 2) +(def ^:const sticker-pack-status-owned 3) + +(def ^:const community-member-role-all 1) +(def ^:const community-member-role-manage-users 2) +(def ^:const community-member-role-moderator 3) diff --git a/src/status_im2/common/home/actions/view.cljs b/src/status_im2/common/home/actions/view.cljs index 7b7adb5892..ebdec47403 100644 --- a/src/status_im2/common/home/actions/view.cljs +++ b/src/status_im2/common/home/actions/view.cljs @@ -4,10 +4,9 @@ [quo2.components.drawers.action-drawers :as drawer] [status-im2.common.confirmation-drawer.view :as confirmation-drawer] - ;;TODO move to status-im2 - [status-im.constants :as constants] - [status-im.chat.models :as chat.models] - [status-im.chat.models.pin-message :as models.pin-message])) + ;;TODO move to status-im2 + [status-im2.common.constants :as constants] + [status-im.chat.models :as chat.models])) (defn- entry [{:keys [icon label on-press danger? sub-label chevron? add-divider?]}] {:pre [(keyword? icon) @@ -29,7 +28,7 @@ (defn show-profile-action [chat-id] (hide-sheet-and-dispatch [:chat.ui/show-profile chat-id]) - (rf/dispatch [::models.pin-message/load-pin-messages chat-id])) + (rf/dispatch [:pin-message/load-pin-messages chat-id])) (defn mark-all-read-action [chat-id] (hide-sheet-and-dispatch [:chat/mark-all-as-read chat-id])) diff --git a/src/status_im/ui2/screens/chat/messages/view.cljs b/src/status_im2/contexts/chat/messages/list/view.cljs similarity index 68% rename from src/status_im/ui2/screens/chat/messages/view.cljs rename to src/status_im2/contexts/chat/messages/list/view.cljs index 3020b02f17..2154d6d60f 100644 --- a/src/status_im/ui2/screens/chat/messages/view.cljs +++ b/src/status_im2/contexts/chat/messages/list/view.cljs @@ -1,32 +1,26 @@ -(ns status-im.ui2.screens.chat.messages.view +(ns status-im2.contexts.chat.messages.list.view (:require [reagent.core :as reagent] - [quo.react-native :as rn] [quo2.foundations.colors :as colors] - [status-im.constants :as constants] - [status-im.utils.handlers :refer [evt]] - [status-im.ui.components.list.views :as list] + [react-native.core :as rn] + [quo2.core :as quo] + [utils.re-frame :as rf] + [react-native.platform :as platform] + [oops.core :as oops] + [react-native.background-timer :as background-timer] + [status-im2.common.constants :as constants] + + ;;TODO move to status-im2 [status-im.ui2.screens.chat.messages.message :as message] [status-im.ui.screens.chat.group :as chat.group] [status-im.ui.screens.chat.message.datemark :as message-datemark] [status-im.ui.screens.chat.message.gap :as gap] - [status-im.ui.screens.chat.components.messages-skeleton :as messages-skeleton] - [status-im.utils.utils :as utils] - [status-im.utils.platform :as platform] [status-im.ui.screens.chat.state :as state] - [status-im.ui.components.icons.icons :as icons])) + [quo.react-native :as quo.react])) -(defonce ^:const threshold-percentage-to-show-floating-scroll-down-button 75) - -(defonce show-floating-scroll-down-button (reagent/atom false)) (defonce messages-list-ref (atom nil)) -(def messages-view-height (reagent/atom 0)) - -(defn on-messages-view-layout [^js ev] - (reset! messages-view-height (-> ev .-nativeEvent .-layout .-height))) - -(def list-key-fn #(or (:message-id %) (:value %))) -(def list-ref #(reset! messages-list-ref %)) +(defonce list-key-fn #(or (:message-id %) (:value %))) +(defonce list-ref #(reset! messages-list-ref %)) (defn scroll-to-bottom [] (some-> ^js @messages-list-ref (.scrollToOffset #js {:y 0 :animated true}))) @@ -43,73 +37,31 @@ :justify-content :center :border-radius (/ 24 2) :background-color (colors/theme-colors colors/neutral-80-opa-70 colors/white-opa-70)}} - ;;TODO icon from quo2 should be used instead! - [icons/icon - :main-icons/arrow-down {:color (colors/theme-colors colors/white colors/neutral-100) - :width 12 - :height 12}]]]) + [quo/icon :i/arrow-down {:color (colors/theme-colors colors/white colors/neutral-100) + :size 12}]]]) -(defn on-scroll [^js ev] - (let [y (-> ev .-nativeEvent .-contentOffset .-y) - layout-height (-> ev .-nativeEvent .-layoutMeasurement .-height) - threshold-height (* (/ layout-height 100) threshold-percentage-to-show-floating-scroll-down-button) +(defonce ^:const threshold-percentage-to-show-floating-scroll-down-button 75) +(defonce show-floating-scroll-down-button (reagent/atom false)) + +(defn on-scroll [evt] + (let [y (oops/oget evt "nativeEvent.contentOffset.y") + layout-height (oops/oget evt "nativeEvent.layoutMeasurement.height") + threshold-height (* (/ layout-height 100) threshold-percentage-to-show-floating-scroll-down-button) reached-threshold? (> y threshold-height)] (when (not= reached-threshold? @show-floating-scroll-down-button) - (rn/configure-next (:ease-in-ease-out rn/layout-animation-presets)) + (quo.react/configure-next (:ease-in-ease-out quo.react/layout-animation-presets)) (reset! show-floating-scroll-down-button reached-threshold?)))) -(defn chat-intro-header-container - [] - ;;not implemented - [rn/view]) - -(defn list-footer [{:keys [chat-id] :as chat}] - (let [loading-messages? (evt [:chat.ui/load-more-messages-for-current-chat]) - (utils/set-timeout #(>evt [:chat.ui/load-more-messages-for-current-chat]) - (if platform/low-device? 700 200)))) + (rf/dispatch [:chat.ui/load-more-messages-for-current-chat]) + (background-timer/set-timeout #(rf/dispatch [:chat.ui/load-more-messages-for-current-chat]) + (if platform/low-device? 700 200)))) (defn get-render-data [{:keys [group-chat chat-id public? community-id admins space-keeper show-input? edit-enabled in-pinned-view?]}] - (let [current-public-key ( - ;;do not use anonymous functions for handlers - [list/flat-list + ;;DO NOT use anonymous functions for handlers + [rn/flat-list (merge pan-responder {:key-fn list-key-fn :ref list-ref :header [list-header chat] :footer [list-footer chat] - :data (when-not should-send-contact-request? - messages) + :data (when-not should-send-contact-request? messages) :render-data (get-render-data {:group-chat group-chat :chat-id chat-id :public? public? @@ -181,17 +174,17 @@ :render-fn render-fn :on-viewable-items-changed on-viewable-items-changed :on-end-reached list-on-end-reached - :on-scroll-to-index-failed identity ;;don't remove this + :on-scroll-to-index-failed identity ;;don't remove this :content-container-style {:padding-top (+ bottom-space 16) :padding-bottom 16} - :scroll-indicator-insets {:top bottom-space} ;;ios only + :scroll-indicator-insets {:top bottom-space} ;;ios only :keyboard-dismiss-mode :interactive :keyboard-should-persist-taps :handled :onMomentumScrollBegin state/start-scrolling :onMomentumScrollEnd state/stop-scrolling :scrollEventThrottle 16 :on-scroll on-scroll - ;;TODO https://github.com/facebook/react-native/issues/30034 + ;;TODO https://github.com/facebook/react-native/issues/30034 :inverted (when platform/ios? true) :style (when platform/android? {:scaleY -1}) :on-layout on-messages-view-layout})] diff --git a/src/status_im2/contexts/chat/messages/pin/banner/view.cljs b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs new file mode 100644 index 0000000000..62956fe2bf --- /dev/null +++ b/src/status_im2/contexts/chat/messages/pin/banner/view.cljs @@ -0,0 +1,14 @@ +(ns status-im2.contexts.chat.messages.pin.banner.view + (:require [status-im.ui2.screens.chat.pinned-banner.view :as pinned-banner] + [utils.re-frame :as rf])) + +(defn banner [chat-id] + (let [pinned-messages (rf/sub [:chats/pinned chat-id]) + latest-pin-text (get-in (last (vals pinned-messages)) [:content :text]) + pins-count (count (seq pinned-messages))] + (when (> pins-count 0) + ;; TODO (flexsurfer) this should be banner component in quo2 + [pinned-banner/pinned-banner + {:latest-pin-text latest-pin-text + :pins-count pins-count + :on-press #(rf/dispatch [:bottom-sheet/show-sheet :pinned-messages-list chat-id])}]))) diff --git a/src/status_im/chat/models/pin_message.cljs b/src/status_im2/contexts/chat/messages/pin/events.cljs similarity index 82% rename from src/status_im/chat/models/pin_message.cljs rename to src/status_im2/contexts/chat/messages/pin/events.cljs index 4f324cb642..066f1c3e1e 100644 --- a/src/status_im/chat/models/pin_message.cljs +++ b/src/status_im2/contexts/chat/messages/pin/events.cljs @@ -1,4 +1,4 @@ -(ns status-im.chat.models.pin-message +(ns status-im2.contexts.chat.messages.pin.events (:require [status-im.chat.models.message-list :as message-list] [status-im.constants :as constants] [status-im.data-store.pin-messages :as data-store.pin-messages] @@ -8,20 +8,19 @@ [re-frame.core :as re-frame])) (fx/defn handle-failed-loading-pin-messages - {:events [::failed-loading-pin-messages]} + {:events [:pin-message/failed-loading-pin-messages]} [{:keys [db]} current-chat-id _ err] (log/error "failed loading pin messages" current-chat-id err) (when current-chat-id {:db (assoc-in db [:pagination-info current-chat-id :loading-pin-messages?] false)})) (fx/defn pin-messages-loaded - {:events [::pin-messages-loaded]} + {:events [:pin-message/pin-messages-loaded]} [{db :db} chat-id {:keys [cursor pinned-messages]}] (let [all-messages (reduce (fn [acc {:keys [message-id] :as message}] (assoc acc message-id message)) {} - pinned-messages) - messages-id-list (map :message-id pinned-messages)] + pinned-messages)] {:db (-> db (assoc-in [:pagination-info chat-id :loading-pin-messages?] false) (assoc-in [:pin-messages chat-id] all-messages) @@ -30,7 +29,7 @@ (empty? cursor)))})) (fx/defn receive-signal - [{:keys [db] :as cofx} pin-messages] + [{:keys [db]} pin-messages] (let [{:keys [chat-id]} (first pin-messages)] (when (= chat-id (db :current-chat-id)) (let [{:keys [chat-id]} (first pin-messages) @@ -55,23 +54,9 @@ (assoc-in [:pin-message-lists chat-id] (message-list/add-many nil (vals all-messages))))})))) -(fx/defn load-more-pin-messages - [{:keys [db]} chat-id first-request] - (let [not-all-loaded? (not (get-in db [:pagination-info chat-id :all-loaded?])) - not-loading-pin-messages? (not (get-in db [:pagination-info chat-id :loading-pin-messages?]))] - (when not-loading-pin-messages? - (fx/merge - {:db (assoc-in db [:pagination-info chat-id :loading-pin-messages?] true)} - (data-store.pin-messages/pinned-message-by-chat-id-rpc - chat-id - nil - constants/default-number-of-pin-messages - #(re-frame/dispatch [::pin-messages-loaded chat-id %]) - #(re-frame/dispatch [::failed-loading-pin-messages chat-id %])))))) - (fx/defn send-pin-message "Pin message, rebuild pinned messages list" - {:events [::send-pin-message]} + {:events [:pin-message/send-pin-message]} [{:keys [db] :as cofx} {:keys [chat-id message-id pinned] :as pin-message}] (let [current-public-key (get-in db [:multiaccount :public-key]) message (merge pin-message {:pinned-by current-public-key}) @@ -97,19 +82,25 @@ :ens-name preferred-name}]))))) (fx/defn load-pin-messages - {:events [::load-pin-messages]} - [{:keys [db] :as cofx} chat-id] - (load-more-pin-messages cofx chat-id true)) + {:events [:pin-message/load-pin-messages]} + [{:keys [db]} chat-id] + (let [not-loading-pin-messages? (not (get-in db [:pagination-info chat-id :loading-pin-messages?]))] + (when not-loading-pin-messages? + (fx/merge + {:db (assoc-in db [:pagination-info chat-id :loading-pin-messages?] true)} + (data-store.pin-messages/pinned-message-by-chat-id-rpc + chat-id + nil + constants/default-number-of-pin-messages + #(re-frame/dispatch [:pin-message/pin-messages-loaded chat-id %]) + #(re-frame/dispatch [:pin-message/failed-loading-pin-messages chat-id %])))))) (fx/defn show-pin-limit-modal - {:events [::show-pin-limit-modal]} - [{:keys [db] :as cofx} chat-id] - (fx/merge - {:db (assoc-in db [:pin-modal chat-id] true)})) + {:events [:pin-message/show-pin-limit-modal]} + [{:keys [db]} chat-id] + {:db (assoc-in db [:pin-modal chat-id] true)}) (fx/defn hide-pin-limit-modal - {:events [::hide-pin-limit-modal]} - [{:keys [db] :as cofx} chat-id] - (fx/merge - {:db (assoc-in db [:pin-modal chat-id] false)})) - + {:events [:pin-message/hide-pin-limit-modal]} + [{:keys [db]} chat-id] + {:db (assoc-in db [:pin-modal chat-id] false)}) diff --git a/src/status_im2/contexts/chat/messages/pin/list/view.cljs b/src/status_im2/contexts/chat/messages/pin/list/view.cljs new file mode 100644 index 0000000000..a423ca22f4 --- /dev/null +++ b/src/status_im2/contexts/chat/messages/pin/list/view.cljs @@ -0,0 +1,59 @@ +(ns status-im2.contexts.chat.messages.pin.list.view + (:require [utils.re-frame :as rf] + [react-native.core :as rn] + [quo2.core :as quo] + [i18n.i18n :as i18n] + [quo2.foundations.colors :as colors] + + ;; TODO move to status-im2 + [status-im.ui2.screens.chat.messages.message :as old-message])) + +(def list-key-fn #(or (:message-id %) (:value %))) + +(defn pinned-messages-list [chat-id] + (let [pinned-messages (vec (vals (rf/sub [:chats/pinned chat-id]))) + current-chat (rf/sub [:chats/current-chat]) + community (rf/sub [:communities/community (:community-id current-chat)])] + [rn/view {:accessibility-label :pinned-messages-list} + ;; TODO (flexsurfer) this should be a component in quo2 https://github.com/status-im/status-mobile/issues/14529 + [:<> + [quo/text {:size :heading-1 + :weight :semi-bold + :style {:margin-horizontal 20}} + (i18n/label :t/pinned-messages)] + (when community + [rn/view {:style {:flex-direction :row + :background-color (colors/theme-colors colors/neutral-10 colors/neutral-80) + :border-radius 20 + :align-items :center + :align-self :flex-start + :margin-horizontal 20 + :padding 4 + :margin-top 8}} + [rn/text {:style {:margin-left 6 :margin-right 4}} (:name community)] + [quo/icon + :i/chevron-right + {:color (colors/theme-colors colors/neutral-50 colors/neutral-40) + :size 12}] + [rn/text {:style {:margin-left 4 + :margin-right 8}} + (str "# " (:chat-name current-chat))]])] + (if (> (count pinned-messages) 0) + [rn/flat-list + {:data pinned-messages + :render-fn old-message/message-render-fn + :key-fn list-key-fn + :separator quo/separator}] + [rn/view {:style {:justify-content :center + :align-items :center + :margin-top 20}} + [rn/view {:style {:width 120 + :height 120 + :justify-content :center + :align-items :center + :border-width 1}} [quo/icon :i/placeholder]] + [quo/text {:weight :semi-bold + :style {:margin-top 20}} + (i18n/label :t/no-pinned-messages)] + [quo/text {:size :paragraph-2} + (i18n/label (if community :t/no-pinned-messages-community-desc :t/no-pinned-messages-desc))]])])) diff --git a/src/status_im2/contexts/chat/messages/view.cljs b/src/status_im2/contexts/chat/messages/view.cljs index 52481a59d2..3678aedd78 100644 --- a/src/status_im2/contexts/chat/messages/view.cljs +++ b/src/status_im2/contexts/chat/messages/view.cljs @@ -6,14 +6,14 @@ [utils.re-frame :as rf] [utils.debounce :as debounce] [quo2.core :as quo] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im2.navigation.state :as navigation.state] + [status-im2.contexts.chat.messages.list.view :as messages.list] + [status-im2.contexts.chat.messages.pin.banner.view :as pin.banner] ;;TODO move to status-im2 - [status-im.ui2.screens.chat.composer.view :as composer] - [status-im.ui2.screens.chat.messages.view :as messages] - [status-im.ui2.screens.chat.messages.pinned-message :as pinned-message] - [status-im.ui2.screens.chat.messages.message :as message])) + [status-im.ui2.screens.chat.pin-limit-popover.view :as pin-limit-popover] + [status-im.ui2.screens.chat.composer.view :as composer])) (defn navigate-back-handler [] (when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat)) @@ -52,7 +52,7 @@ :accessibility-label :back-button} :right-section-buttons - [{:on-press #() ;; TODO not implemented + [{:on-press #() ;; TODO not implemented :icon :i/options :accessibility-label :options-button}]}])) @@ -62,10 +62,11 @@ mutual-contact-requests-enabled? (rf/sub [:mutual-contact-requests/enabled?])] [rn/keyboard-avoiding-view {:style {:flex 1}} [page-nav] - [pinned-message/pin-limit-popover chat-id message/pinned-messages-list] - [message/pinned-banner chat-id] + ;; TODO (flexsurfer) this should be in-app notification component in quo2 https://github.com/status-im/status-mobile/issues/14527 + [pin-limit-popover/pin-limit-popover chat-id] + [pin.banner/banner chat-id] ;;MESSAGES LIST - [messages/messages-view + [messages.list/messages-list {:chat chat :mutual-contact-requests-enabled? mutual-contact-requests-enabled? :show-input? show-input? diff --git a/src/status_im2/contexts/communities/overview/view.cljs b/src/status_im2/contexts/communities/overview/view.cljs index f6e3434650..9d6ddfdd73 100644 --- a/src/status_im2/contexts/communities/overview/view.cljs +++ b/src/status_im2/contexts/communities/overview/view.cljs @@ -14,7 +14,7 @@ [react-native.platform :as platform] [status-im2.contexts.communities.requests.actions.view :as requests.actions] [status-im2.contexts.communities.home.actions.view :as home.actions] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im.react-native.resources :as resources] [status-im.utils.utils :as utils])) diff --git a/src/status_im2/contexts/quo_preview/community/community_card_view.cljs b/src/status_im2/contexts/quo_preview/community/community_card_view.cljs index 29253335d1..91e934dcd1 100644 --- a/src/status_im2/contexts/quo_preview/community/community_card_view.cljs +++ b/src/status_im2/contexts/quo_preview/community/community_card_view.cljs @@ -2,7 +2,7 @@ (:require [react-native.core :as rn] [status-im2.contexts.quo-preview.preview :as preview] [reagent.core :as reagent] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [quo2.foundations.colors :as colors] [quo.design-system.colors :as quo.colors] [quo2.components.community.community-card-view :as community-card-view] diff --git a/src/status_im2/contexts/quo_preview/posts_and_attachments/messages_skeleton.cljs b/src/status_im2/contexts/quo_preview/posts_and_attachments/messages_skeleton.cljs index c7efd8b035..2549aeead8 100644 --- a/src/status_im2/contexts/quo_preview/posts_and_attachments/messages_skeleton.cljs +++ b/src/status_im2/contexts/quo_preview/posts_and_attachments/messages_skeleton.cljs @@ -1,11 +1,11 @@ (ns status-im2.contexts.quo-preview.posts-and-attachments.messages-skeleton (:require [quo.react-native :as rn] [quo2.foundations.colors :as colors] - [status-im.ui.screens.chat.components.messages-skeleton :as messages-skeleton])) + [quo2.core :as quo])) (defn preview-messages-skeleton [] [rn/view {:background-color (colors/theme-colors colors/white colors/neutral-90) :flex 1} - [messages-skeleton/messages-skeleton]]) \ No newline at end of file + [quo/skeleton]]) diff --git a/src/status_im2/contexts/shell/cards/view.cljs b/src/status_im2/contexts/shell/cards/view.cljs index 284284501e..caafc8d24b 100644 --- a/src/status_im2/contexts/shell/cards/view.cljs +++ b/src/status_im2/contexts/shell/cards/view.cljs @@ -10,7 +10,7 @@ (defn content-container [{:keys [content-type data new-notifications? color-50]}] [rn/view {:style (style/content-container new-notifications?)} - ;; TODO - Use status-im.constants for content type + ;; TODO - Use status-im2.common.constants for content type (case content-type :text [quo/text style/last-message-text-props data] :photo [quo/preview-list {:type :photo diff --git a/src/status_im2/contexts/shell/events.cljs b/src/status_im2/contexts/shell/events.cljs index c92f215ee4..45751d7bba 100644 --- a/src/status_im2/contexts/shell/events.cljs +++ b/src/status_im2/contexts/shell/events.cljs @@ -2,7 +2,7 @@ (:require [utils.re-frame :as rf] [re-frame.core :as re-frame] [status-im2.navigation.events :as navigation] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im2.contexts.shell.animation :as animation] [status-im2.contexts.shell.constants :as shell.constants])) diff --git a/src/status_im2/subs/activity_center.cljs b/src/status_im2/subs/activity_center.cljs index 0d947fbce1..b649d9fdfb 100644 --- a/src/status_im2/subs/activity_center.cljs +++ b/src/status_im2/subs/activity_center.cljs @@ -2,7 +2,7 @@ (:require [re-frame.core :as re-frame] [status-im.utils.datetime :as datetime] [status-im.multiaccounts.core :as multiaccounts] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im.activity-center.notification-types :as types] [clojure.string :as string])) diff --git a/src/status_im2/subs/chat/chats.cljs b/src/status_im2/subs/chat/chats.cljs index f381f8afac..ce041fd3eb 100644 --- a/src/status_im2/subs/chat/chats.cljs +++ b/src/status_im2/subs/chat/chats.cljs @@ -1,7 +1,7 @@ (ns status-im2.subs.chat.chats (:require [re-frame.core :as re-frame] [clojure.string :as string] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [quo.design-system.colors :as colors] [status-im.chat.models :as chat.models] [status-im.communities.core :as communities] diff --git a/src/status_im2/subs/chat/messages.cljs b/src/status_im2/subs/chat/messages.cljs index 8d1e169983..1b18326408 100644 --- a/src/status_im2/subs/chat/messages.cljs +++ b/src/status_im2/subs/chat/messages.cljs @@ -3,7 +3,7 @@ [status-im.chat.db :as chat.db] [status-im.chat.models.message-list :as models.message-list] [status-im.chat.models.reactions :as models.reactions] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im.utils.datetime :as datetime])) (re-frame/reg-sub diff --git a/src/status_im2/subs/communities.cljs b/src/status_im2/subs/communities.cljs index 8b8f5b6e8f..6e39df06f8 100644 --- a/src/status_im2/subs/communities.cljs +++ b/src/status_im2/subs/communities.cljs @@ -3,7 +3,7 @@ [clojure.string :as string] [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] - [status-im.constants :as constants])) + [status-im2.common.constants :as constants])) (re-frame/reg-sub :communities diff --git a/src/status_im2/subs/general.cljs b/src/status_im2/subs/general.cljs index a316ad48ad..d099fb6bfd 100644 --- a/src/status_im2/subs/general.cljs +++ b/src/status_im2/subs/general.cljs @@ -1,7 +1,7 @@ (ns status-im2.subs.general (:require [re-frame.core :as re-frame] [status-im.utils.build :as build] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im.multiaccounts.model :as multiaccounts.model] [status-im.ethereum.core :as ethereum] [status-im.ethereum.tokens :as tokens] diff --git a/src/status_im2/subs/onboarding.cljs b/src/status_im2/subs/onboarding.cljs index 146d16dc5a..d1c16ff484 100644 --- a/src/status_im2/subs/onboarding.cljs +++ b/src/status_im2/subs/onboarding.cljs @@ -1,6 +1,6 @@ (ns status-im2.subs.onboarding (:require [re-frame.core :as re-frame] - [status-im.constants :as constants] + [status-im2.common.constants :as constants] [status-im.multiaccounts.recover.core :as recover])) (re-frame/reg-sub @@ -58,4 +58,4 @@ (re-frame/reg-sub :intro-wizard/acc-to-login-keycard-pairing - login-ma-keycard-pairing) \ No newline at end of file + login-ma-keycard-pairing) diff --git a/src/status_im2/subs/shell.cljs b/src/status_im2/subs/shell.cljs index 0b4063920e..4fed7b2c65 100644 --- a/src/status_im2/subs/shell.cljs +++ b/src/status_im2/subs/shell.cljs @@ -1,6 +1,6 @@ (ns status-im2.subs.shell (:require [re-frame.core :as re-frame] - [status-im.constants :as status-constants] + [status-im2.common.constants :as status-constants] [status-im.react-native.resources :as resources])) (defn get-card-content [chat] diff --git a/src/status_im2/subs/stickers.cljs b/src/status_im2/subs/stickers.cljs index 8c116504c0..6e4c18038e 100644 --- a/src/status_im2/subs/stickers.cljs +++ b/src/status_im2/subs/stickers.cljs @@ -1,6 +1,6 @@ (ns status-im2.subs.stickers (:require [re-frame.core :as re-frame] - [status-im.constants :as constants])) + [status-im2.common.constants :as constants])) (re-frame/reg-sub :stickers/installed-packs @@ -24,4 +24,4 @@ :<- [:get-screen-params] :<- [:stickers/all-packs] (fn [[{:keys [id]} packs]] - (first (filter #(= (:id %) id) packs)))) \ No newline at end of file + (first (filter #(= (:id %) id) packs))))