Compare commits

...
20 changed files with 180 additions and 163 deletions
+11 -11
View File
@@ -30,18 +30,18 @@
(when on-press
{:on-press on-press}))
[rn/view
{:style {:flex-direction :row
:flex-grow 0
:flex-shrink 1
:padding-horizontal 20
:align-items :center}}
{:style (cond-> {:flex-direction :row
:flex-grow 0
:flex-shrink 1
:align-items :center}
icon (assoc :padding-horizontal 20))}
[rn/view
{:style {:width 20
:height 20
:align-items :center
:justify-content :center
:margin-right 12}}
[icons/icon icon {:color icon-color}]]
{:style (cond-> {:width 20
:height 20
:align-items :center
:justify-content :center}
icon (assoc :margin-right 12))}
(when icon [icons/icon icon {:color icon-color}])]
[rn/view
[text/text
{:weight :medium
+22 -64
View File
@@ -4,7 +4,6 @@
[quo.react-native :as rn]
[re-frame.core :as re-frame]
[utils.re-frame :as rf]
[status-im.utils.platform :as platform]
[taoensso.timbre :as log]
[status-im.native-module.core :as status]))
@@ -91,38 +90,29 @@
(assoc-in [:chats/mentions chat-id :mentions] state)
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
(rf/defn on-text-input
{:events [:mention/on-text-input]}
[{:keys [db]} {:keys [previous-text start end] :as args}]
(let [previous-text
;; NOTE(rasom): on iOS `previous-text` contains entire input's text. To
;; get only removed part of text we have cut it.
(if platform/android?
previous-text
(subs previous-text start end))
chat-id (:current-chat-id db)
state (merge args {:previous-text previous-text})
state (set/rename-keys state
{:previous-text :PreviousText
:new-text :NewText
:start :Start
:end :End})
params [chat-id state]
method "wakuext_chatMentionOnTextInput"]
(log/debug "[mentions] on-text-input" {:params params})
(rf/defn on-change-text
{:events [:mention/on-change-text]}
[{:keys [db]} text]
(let [chat-id (:current-chat-id db)
params [chat-id text]
method "wakuext_chatMentionOnChangeText"]
(log/debug "[mentions] on-change-text" {:params params})
{:json-rpc/call [{:method method
:params [chat-id state]
:on-success #(rf/dispatch [:mention/on-text-input-success %])
:params params
:on-success #(rf/dispatch [:mention/on-change-text-success %])
:on-error #(rf/dispatch [:mention/on-error
{:method method
:params params} %])}]}))
(rf/defn on-text-input-success
{:events [:mention/on-text-input-success]}
(rf/defn on-change-text-success
{:events [:mention/on-change-text-success]}
[{:keys [db]} result]
(log/debug "[mentions] on-text-input-success" {:result result})
(let [{:keys [state chat-id]} (transfer-mention-result result)]
{:db (assoc-in db [:chats/mentions chat-id :mentions] state)}))
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
{:db (-> db
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
(assoc-in [:chats/mentions chat-id :mentions] state)
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
(rf/defn recheck-at-idxs
[{:keys [db]} public-key]
@@ -175,16 +165,6 @@
;; programmatic change. By calling `reset-text-input-cursor` we force the
;; keyboard's cursor position to be changed before the next input.
(reset-text-input-cursor text-input-ref cursor)
;; NOTE(roman): on-text-input event is not dispatched when we change input
;; programmatically, so we have to call `on-text-input` manually
(on-text-input
(let [match-len (count match)
start (inc at-sign-idx)
end (+ start match-len)]
{:new-text match
:previous-text searched-text
:start start
:end end}))
(recheck-at-idxs public-key))))
(rf/defn clear-suggestions
@@ -220,7 +200,7 @@
(when text
(log/debug "[mentions] check-selection" {:params params})
{:json-rpc/call [{:method method
:params [chat-id text start end]
:params params
:on-success #(rf/dispatch [:mention/on-handle-selection-change-success %])
:on-error #(rf/dispatch [:mention/on-error
{:method method
@@ -230,8 +210,11 @@
{:events [:mention/on-handle-selection-change-success]}
[{:keys [db]} result]
(log/debug "[mentions] on-check-selection-success" {:result result})
(let [{:keys [state chat-id]} (transfer-mention-result result)]
{:db (assoc-in db [:chats/mentions chat-id :mentions] (rename-state state))}))
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
{:db (-> db
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
(assoc-in [:chats/mentions chat-id :mentions] state)
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
(re-frame/reg-fx
::reset-text-input-cursor
@@ -240,28 +223,3 @@
(status/reset-keyboard-input
(rn/find-node-handle (react/current-ref ref))
cursor))))
(rf/defn calculate-suggestions
{:events [:mention/calculate-suggestions]}
[{:keys [db]}]
(let [chat-id (:current-chat-id db)
text (get-in db [:chat/inputs chat-id :input-text])
params [chat-id text]
method "wakuext_chatMentionCalculateSuggestions"]
(log/debug "[mentions] calculate-suggestions" {:params params})
{:json-rpc/call [{:method method
:params [chat-id text]
:on-success #(rf/dispatch [:mention/on-calculate-suggestions-success %])
:on-error #(rf/dispatch [:mention/on-error
{:method method
:params params} %])}]}))
(rf/defn on-calculate-suggestions-success
{:events [:mention/on-calculate-suggestions-success]}
[{:keys [db]} result]
(log/debug "[mentions] on-calculate-suggestions-success" {:result result})
(let [{:keys [state chat-id mentionable-users input-segments]} (transfer-mention-result result)]
{:db (-> db
(assoc-in [:chats/mention-suggestions chat-id] mentionable-users)
(assoc-in [:chats/mentions chat-id :mentions] state)
(assoc-in [:chat/inputs-with-mentions chat-id] input-segments))}))
+1 -1
View File
@@ -87,7 +87,7 @@
:identicon (.-identicon chat)
:muted (.-muted chat)
:joined (.-joined chat)
:muted-till (.-mutetill chat)
:chat-id (.-id chat)
:community-id (.-communityId chat)
:synced-from (.-syncedFrom chat)
+3 -2
View File
@@ -12,7 +12,8 @@
status-im2.navigation.core
status-im2.subs.root ; so integration tests can run independently
[taoensso.timbre :as log]
[utils.security.core :as security]))
[utils.security.core :as security]
[status-im2.constants :as constants]))
(def password "testabc")
@@ -295,7 +296,7 @@
(rf/dispatch-sync [:chat/navigate-to-chat chat-id])
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
(is @(rf/subscribe [:chats/chat chat-id]))
(rf/dispatch-sync [:chat.ui/mute chat-id true])
(rf/dispatch-sync [:chat.ui/mute chat-id true constants/mute-till-unmuted])
(rf-test/wait-for
[:chat/mute-successfully]
(is @(rf/subscribe [:chats/muted chat-id]))
@@ -198,11 +198,7 @@
(when platform/android?
(reset! last-text-change (js/Date.now)))
(on-text-change text chat-id)
;; NOTE(rasom): on iOS `on-change` is dispatched after `on-text-input`,
;; that's why mention suggestions are calculated on `on-change`
(when platform/ios?
(re-frame/dispatch [:mention/calculate-suggestions]))))
(on-text-change text chat-id)))
(rf/defn set-input-text
"Set input text for current-chat. Takes db and input text and cofx
@@ -220,26 +216,10 @@
(defn on-text-input
[chat-id args]
(let [native-event (.-nativeEvent ^js args)
text (.-text ^js native-event)
previous-text (.-previousText ^js native-event)
range (.-range ^js native-event)
start (.-start ^js range)
end (.-end ^js range)]
(let [native-event (.-nativeEvent ^js args)
text (.-text ^js native-event)]
(when (and (not (get @mentions-enabled chat-id)) (string/index-of text "@"))
(swap! mentions-enabled assoc chat-id true))
(re-frame/dispatch
[:mention/on-text-input
{:new-text text
:previous-text previous-text
:start start
:end end}])
;; NOTE(rasom): on Android `on-text-input` is dispatched after
;; `on-change`, that's why mention suggestions are calculated
;; on `on-change`
(when platform/android?
(re-frame/dispatch [:mention/calculate-suggestions]))))
(swap! mentions-enabled assoc chat-id true))))
(defn text-input
[{:keys [set-active-panel refs chat-id sending-image]}]
@@ -13,7 +13,8 @@
[status-im.ui.components.toolbar :as toolbar]
[status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.profile.components.sheets :as sheets]
[utils.re-frame :as rf]))
[utils.re-frame :as rf]
[status-im2.constants :as constants]))
(defn actions
[{:keys [public-key added? blocked? ens-name mutual?] :as contact} muted?]
@@ -43,7 +44,9 @@
:selected muted?
:disabled blocked?
:action (when-not blocked?
#(re-frame/dispatch [:chat.ui/mute public-key (not muted?)]))}]
#(re-frame/dispatch [:chat.ui/mute public-key (not muted?)
(when-not muted?
constants/mute-till-unmuted)]))}]
[{:label (i18n/label (if blocked? :t/unblock :t/block))
:negative true
:selected blocked?
@@ -141,33 +141,15 @@
(reset! last-text-change (js/Date.now)))
(on-text-change text chat-id)
;; NOTE(rasom): on iOS `on-change` is dispatched after `on-text-input`,
;; that's why mention suggestions are calculated on `on-change`
(when platform/ios?
(rf/dispatch [:mention/calculate-suggestions]))))
(rf/dispatch [:mention/on-change-text text])))
(defn on-text-input
[chat-id args]
(let [native-event (.-nativeEvent ^js args)
text (.-text ^js native-event)
previous-text (.-previousText ^js native-event)
range (.-range ^js native-event)
start (.-start ^js range)
end (.-end ^js range)]
(let [native-event (.-nativeEvent ^js args)
text (.-text ^js native-event)]
(when (and (not (get @mentions-enabled? chat-id)) (string/index-of text "@"))
(swap! mentions-enabled? assoc chat-id true))
(rf/dispatch
[:mention/on-text-input
{:new-text text
:previous-text previous-text
:start start
:end end}])
;; NOTE(rasom): on Android `on-text-input` is dispatched after
;; `on-change`, that's why mention suggestions are calculated
;; on `on-change`
(when platform/android?
(rf/dispatch [:mention/calculate-suggestions]))))
(swap! mentions-enabled? assoc chat-id true))))
(defn text-input-style
[chat-id]
+1 -1
View File
@@ -51,7 +51,7 @@
(defn mute-chat-action
[chat-id]
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true]))
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true constants/mute-till-unmuted]))
(defn unmute-chat-action
[chat-id]
@@ -0,0 +1,8 @@
(ns status-im2.common.mute-chat-drawer.style
(:require [quo2.foundations.colors :as colors]))
(defn header-text
[]
{:margin-left 20
:margin-bottom 10
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)})
@@ -0,0 +1,65 @@
(ns status-im2.common.mute-chat-drawer.view
(:require [utils.i18n :as i18n]
[quo2.core :as quo]
[react-native.core :as rn]
[status-im2.constants :as constants]
[utils.re-frame :as rf]
[status-im2.common.mute-chat-drawer.style :as style]))
(defn hide-sheet-and-dispatch
[event]
(rf/dispatch [:bottom-sheet/hide])
(rf/dispatch event))
(defn mute-chat-drawer
[chat-id accessibility-label]
[rn/view {:accessibility-label accessibility-label}
[quo/text
{:weight :medium
:size :paragraph-2
:style (style/header-text)} (i18n/label :t/mute-channel)]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-15-mins)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
constants/mute-for-15-mins-type]))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-hour)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
constants/mute-for-1-hour-type]))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-8-hours)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
constants/mute-for-8-hours-type]))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-week)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
constants/mute-for-1-week]))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-till-unmute)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
constants/mute-till-unmuted]))}]])
+6
View File
@@ -36,6 +36,12 @@
(def ^:const activity-center-membership-status-accepted 2)
(def ^:const activity-center-membership-status-declined 3)
(def ^:const mute-for-15-mins-type 1)
(def ^:const mute-for-1-hour-type 2)
(def ^:const mute-for-8-hours-type 3)
(def ^:const mute-for-1-week 4)
(def ^:const mute-till-unmuted 5)
(def ^:const activity-center-mark-all-as-read-undo-time-limit-ms 4000)
(def ^:const activity-center-max-unread-count 99)
+17 -13
View File
@@ -64,13 +64,15 @@
(defn map-chats
[{:keys [db] :as cofx}]
(fn [val]
(assoc
(merge
(or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))
val)
:invitation-admin
(:invitation-admin val))))
(let [chat (or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))]
(assoc
(merge
(cond-> chat
(comp not :muted) (dissoc chat :muted-till))
val)
:invitation-admin
(:invitation-admin val)))))
(rf/defn leave-removed-chat
[{{:keys [view-id current-chat-id chats]} :db
@@ -292,18 +294,20 @@
(rf/defn mute-chat-toggled-successfully
{:events [:chat/mute-successfully]}
[_ chat-id]
(log/debug "muted chat successfully" chat-id))
[{:keys [db]} chat-id muted-till]
(log/debug "muted chat successfully" chat-id " for" muted-till)
{:db (assoc-in db [:chats chat-id :muted-till] muted-till)})
(rf/defn mute-chat
{:events [:chat.ui/mute]}
[{:keys [db]} chat-id muted?]
(let [method (if muted? "wakuext_muteChat" "wakuext_unmuteChat")]
[{:keys [db]} chat-id muted? mute-type]
(let [method (if muted? "wakuext_muteChatV2" "wakuext_unmuteChat")
params (if muted? [{:chatId chat-id :mutedType mute-type}] [chat-id])]
{:db (assoc-in db [:chats chat-id :muted] muted?)
:json-rpc/call [{:method method
:params [chat-id]
:params params
:on-error #(rf/dispatch [:chat/mute-failed chat-id muted? %])
:on-success #(rf/dispatch [:chat/mute-successfully chat-id])}]}))
:on-success #(rf/dispatch [:chat/mute-successfully chat-id %])}]}))
(rf/defn show-clear-history-confirmation
{:events [:chat.ui/show-clear-history-confirmation]}
@@ -8,7 +8,8 @@
[status-im2.common.contact-list-item.view :as contact-list-item]
[status-im2.common.home.actions.view :as actions]
[utils.re-frame :as rf]
[reagent.core :as reagent]))
[reagent.core :as reagent]
[status-im2.constants :as constants]))
(defn back-button
[]
@@ -191,7 +192,8 @@
[rn/touchable-opacity
{:style (style/action-container color)
:accessibility-label :toggle-mute
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)])}
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)
(when-not muted constants/mute-till-unmuted)])}
[quo/icon (if muted :i/muted :i/activity-center)
{:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}]
[quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium}
@@ -118,7 +118,7 @@
(defn chat-list-item
[{:keys [chat-id group-chat color name unviewed-messages-count unviewed-mentions-count
timestamp last-message]
timestamp last-message muted]
:as item}]
(let [display-name (if group-chat
name
@@ -143,8 +143,9 @@
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}}
(get-in last-message [:content :text])]
[render-subheader (get-in last-message [:content :parsed-text])])]
(if (> unviewed-mentions-count 0)
[quo/info-count {:style {:top 16}}
unviewed-mentions-count]
(when (> unviewed-messages-count 0)
[rn/view {:style (style/count-container)}]))]))
(when-not muted
(if (> unviewed-mentions-count 0)
[quo/info-count {:style {:top 16}}
unviewed-mentions-count]
(when (> unviewed-messages-count 0)
[rn/view {:style (style/count-container)}])))]))
+1 -1
View File
@@ -25,7 +25,7 @@
(re-frame/reg-fx
:shell/navigate-from-shell-fx
(fn [stack-id]
(js/setTimeout #(animation/bottom-tab-on-press stack-id) 500)))
(animation/bottom-tab-on-press stack-id)))
(re-frame/reg-fx
:shell/reset-bottom-tabs
+9 -7
View File
@@ -156,17 +156,19 @@
(fn [chats]
(let [{:keys [chats-stack community-stack]}
(reduce
(fn [acc [_ {:keys [unviewed-messages-count unviewed-mentions-count chat-type]}]]
(fn [acc [_ {:keys [unviewed-messages-count unviewed-mentions-count chat-type muted]}]]
(case chat-type
constants/community-chat-type
(-> acc
(update-in [:community-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:community-stack :unviewed-mentions-count] + unviewed-mentions-count))
(when-not muted
(-> acc
(update-in [:community-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:community-stack :unviewed-mentions-count] + unviewed-mentions-count)))
(constants/private-group-chat-type constants/one-to-one-chat-type)
(-> acc
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-mentions-count))
(when-not muted
(-> acc
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-mentions-count)))
acc))
{:chats-stack {:unviewed-messages-count 0 :unviewed-mentions-count 0}
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.144.0",
"commit-sha1": "ba1ba1ac0203948339be5877ea6e970efb7b8ee0",
"src-sha256": "0r2gxivnx201zfnm69g2mk1izcjid4lf9s4ln721kwrnc1v288sf"
"version": "fix/15616",
"commit-sha1": "2eccfda1c9495a3a6ecfd96f24efefff1b53461f",
"src-sha256": "0dhibgmfix23nmmg5nhyhg6qr069575mi1hp4gqd4rp54wygigvv"
}
@@ -332,7 +332,6 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase):
self.errors.verify_no_errors()
@marks.testrail_id(702957)
@marks.xfail(reason="Blocked by 15500")
def test_activity_center_mentions(self):
self.home_1.jump_to_communities_home()
self.home_2.jump_to_card_by_text('# %s' % self.channel_name)
+1 -1
View File
@@ -811,7 +811,7 @@ class ChatView(BaseView):
self.set_community_image_button = Button(self.driver, translation_id='community-thumbnail-image',
suffix='/following-sibling::android.view.ViewGroup')
self.confirm_create_in_community_button = Button(self.driver, translation_id="create")
self.mentions_list = BaseElement(self.driver, accessibility_id="mentions-list")
self.mentions_list = BaseElement(self.driver, accessibility_id="user-list")
# New UI
self.pinned_messages_count = Button(self.driver,
+7 -1
View File
@@ -2064,5 +2064,11 @@
"enable-biometrics": "Enable biometrics",
"use-biometrics": "Use biometrics to fill in your password",
"name-must-have-at-least-characters": "Name must have at least {{min-chars}} characters",
"name-is-not-valid": "Name is not valid"
"name-is-not-valid": "Name is not valid",
"mute-for-15-mins": "For 15 min",
"mute-for-1-hour": "For 1 hour",
"mute-for-8-hours": "For 8 hours",
"mute-for-1-week": "For 7 days",
"mute-till-unmute": "Until you turn it back on",
"mute-channel": "Mute channel"
}