Skip to content

Commit

Permalink
fix: 1:1 chat concerns (#17795)
Browse files Browse the repository at this point in the history
  • Loading branch information
BalogunofAfrica authored Dec 11, 2023
1 parent 72f518d commit f155d95
Show file tree
Hide file tree
Showing 69 changed files with 163 additions and 154 deletions.
7 changes: 3 additions & 4 deletions src/status_im2/common/confirmation_drawer/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
:border-radius 20
:align-items :center
:align-self :flex-start
:padding 4
:margin-top 8
:margin-left -4
:padding 2
:margin-top 4
:margin-bottom 16})

(def buttons-container
{:flex-direction :row
:justify-content :space-between
:margin-top 20})
:margin-top 25})
2 changes: 1 addition & 1 deletion src/status_im2/common/confirmation_drawer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
:accessibility-label accessibility-label}
[quo/text
{:weight :semi-bold
:size :heading-1} title]
:size :heading-2} title]
[rn/view {:style (style/context-container)}
[avatar group-chat color display-name photo-path]
[quo/text
Expand Down
56 changes: 28 additions & 28 deletions src/status_im2/common/home/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,20 @@
:button-text (i18n/label :t/clear-history)
:on-press #(hide-sheet-and-dispatch [:chat.ui/clear-history chat-id])}])}]))

(defn delete-chat-action
(defn close-chat-action
[{:keys [chat-id] :as item} inside-chat?]
(hide-sheet-and-dispatch
[:show-bottom-sheet
{:content (fn []
[confirmation-drawer/confirmation-drawer
{:title (i18n/label :t/delete-chat?)
:description (i18n/label :t/delete-chat-confirmation)
{:title (i18n/label :t/close-chat)
:description (i18n/label :t/close-chat-confirmation)
:context item
:accessibility-label :delete-chat-confirm
:button-text (i18n/label :t/delete-chat)
:accessibility-label :close-chat-confirm
:button-text (i18n/label :t/confirm)
:close-button-text (i18n/label :t/cancel)
:on-press (fn []
(hide-sheet-and-dispatch [:chat.ui/remove-chat chat-id])
(hide-sheet-and-dispatch [:chat.ui/close-chat chat-id])
(when inside-chat?
(rf/dispatch [:navigate-back])))}])}]))

Expand Down Expand Up @@ -130,7 +131,7 @@
(defn mute-chat-entry
[chat-id chat-type muted-till]
(let [muted? (rf/sub [:chats/muted chat-id])]
(entry {:icon (if muted? :i/muted :i/activity-center)
(entry {:icon (if muted? :i/activity-center :i/muted)
:label (i18n/label
(if muted?
:unmute-chat
Expand All @@ -146,7 +147,7 @@

(defn mark-as-read-entry
[chat-id needs-divider?]
(entry {:icon :i/correct
(entry {:icon :i/mark-as-read
:label (i18n/label :t/mark-as-read)
:on-press #(mark-all-read-action chat-id)
:danger? false
Expand All @@ -156,25 +157,26 @@
:add-divider? needs-divider?}))

(defn clear-history-entry
[chat-id]
[chat-id needs-divider?]
(entry {:icon :i/delete
:label (i18n/label :t/clear-history)
:on-press #(clear-history-action chat-id)
:danger? true
:sub-label nil
:accessibility-label :clear-history
:chevron? false
:add-divider? true}))
:add-divider? needs-divider?}))

(defn delete-chat-entry
[item inside-chat?]
(entry {:icon :i/delete
:label (i18n/label :t/delete-chat)
:on-press #(delete-chat-action item inside-chat?)
(defn close-chat-entry
[item inside-chat? needs-divider?]
(entry {:icon :i/close-circle
:label (i18n/label :t/close-chat)
:on-press #(close-chat-action item inside-chat?)
:danger? true
:accessibility-label :delete-chat
:accessibility-label :close-chat
:sub-label nil
:chevron? false}))
:chevron? false
:add-divider? needs-divider?}))

(defn leave-group-entry
[item extra-data]
Expand Down Expand Up @@ -409,22 +411,21 @@

(defn destructive-actions
[{:keys [group-chat] :as item} inside-chat?]
[(clear-history-entry item)
(if group-chat
(leave-group-entry item nil)
(delete-chat-entry item inside-chat?))])
[(when (not group-chat)
(close-chat-entry item inside-chat? (not group-chat)))
(clear-history-entry item group-chat)
(when group-chat
(leave-group-entry item nil))])

(defn notification-actions
[{:keys [chat-id group-chat public? chat-type muted-till]} inside-chat? needs-divider?]
[{:keys [chat-id public? chat-type muted-till]} inside-chat? needs-divider?]
[(mark-as-read-entry chat-id needs-divider?)
(mute-chat-entry chat-id chat-type muted-till)
(notifications-entry false)
(when inside-chat?
(fetch-messages-entry))
(when (or (not group-chat) public?)
(when public?
(show-qr-entry))
(when-not group-chat
(share-profile-entry))
(when public?
(share-group-entry))])

Expand All @@ -443,9 +444,8 @@
(defn one-to-one-actions
[{:keys [chat-id] :as item} inside-chat?]
[quo/action-drawer
[[(view-profile-entry chat-id)
(edit-nickname-entry chat-id)]
(notification-actions item inside-chat? false)
[[(view-profile-entry chat-id)]
(notification-actions item inside-chat? true)
(destructive-actions item inside-chat?)]])

(defn private-group-chat-actions
Expand Down
14 changes: 7 additions & 7 deletions src/status_im2/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
(update :chats-home-list disj chat-id)
(assoc :current-chat-id nil))
:json-rpc/call [{:method "wakuext_deactivateChat"
:params [{:id chat-id}]
:params [{:id chat-id :preserveHistory true}]
:on-success #()
:on-error #(log/error "failed to create public chat" chat-id %)}]}
(clear-history chat-id true)))
Expand Down Expand Up @@ -282,9 +282,9 @@
:on-error #(log/error "failed to clear history " chat-id %)}]}
(clear-history chat-id remove-chat?)))

(rf/defn remove-chat
"Removes chat completely from app, producing all necessary effects for that"
{:events [:chat.ui/remove-chat]}
(rf/defn close-and-remove-chat
"Closes the chat and removes it from chat list while retaining history, producing all necessary effects for that"
{:events [:chat.ui/close-chat]}
[{:keys [db now] :as cofx} chat-id]
(rf/merge cofx
{:effects/push-notifications-clear-message-notifications [chat-id]
Expand Down Expand Up @@ -383,15 +383,15 @@
(rf/dispatch [:chat.ui/clear-history chat-id false]))}})

(rf/defn show-remove-chat-confirmation
{:events [:chat.ui/show-remove-confirmation]}
{:events [:chat.ui/show-close-confirmation]}
[_ chat-id]
{:ui/show-confirmation
{:title (i18n/label :t/delete-confirmation)
:content (i18n/label :t/delete-chat-confirmation)
:content (i18n/label :t/close-chat-confirmation)
:confirm-button-text (i18n/label :t/delete)
:on-accept #(do
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:chat.ui/remove-chat chat-id]))}})
(rf/dispatch [:chat.ui/close-chat chat-id]))}})

(rf/defn navigate-to-user-pinned-messages
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
Expand Down
12 changes: 5 additions & 7 deletions src/status_im2/contexts/chat/events_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@

(deftest remove-chat-test
(let [chat-id "1"
cofx {:db {:messages {chat-id {"1" {:clock-value 1}
"2" {:clock-value 10}
"3" {:clock-value 2}}}
:chats {chat-id {:last-message {:clock-value 10}}}}}]
(testing "it deletes all the messages"
(let [actual (chat/remove-chat cofx chat-id)]
(is (= nil (get-in actual [:db :messages chat-id])))))))
cofx {:db {:current-chat-id chat-id
:chats-home-list #{chat-id}}}]
(testing "it removes the chat with given id"
(let [actual (chat/close-and-remove-chat cofx chat-id)]
(is (= nil (get-in actual [:db :chats-home-list chat-id])))))))

(deftest multi-user-chat?
(let [chat-id "1"]
Expand Down
3 changes: 1 addition & 2 deletions src/status_im2/contexts/chat/home/chat_list_item/style.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require
[quo.foundations.colors :as colors]))

(defn container
[]
(def container
{:margin-horizontal 8
:padding-vertical 8
:padding-horizontal 12
Expand Down
29 changes: 23 additions & 6 deletions src/status_im2/contexts/chat/home/chat_list_item/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
:accessibility-label :new-message-counter}
unviewed-messages-count])]))

(defn chat-list-item
(defn chat-item
[{:keys [chat-id group-chat color name last-message timestamp muted]
:as item}]
(let [[primary-name secondary-name]
Expand All @@ -223,11 +223,7 @@
(rf/sub [:contacts/contact-two-names-by-identity chat-id]))
{:keys [ens-verified added?] :as contact} (when-not group-chat
(rf/sub [:contacts/contact-by-address chat-id]))]
[rn/touchable-opacity
{:style (style/container)
:on-press (open-chat chat-id)
:on-long-press #(rf/dispatch [:show-bottom-sheet
{:content (fn [] [actions/chat-actions item false])}])}
[:<>
[avatar-view
{:contact contact
:chat-id chat-id
Expand All @@ -245,3 +241,24 @@
:time-str (datetime/to-short-str timestamp)}]
[last-message-preview group-chat last-message muted]]
[notification item]]))

(defn chat-user
[item]
[rn/view
{:style (merge style/container {:margin-horizontal 0})}
[chat-item item]])

(defn chat-list-item
[{:keys [chat-id chat-type]
:as item} theme]
(let [customization-color (rf/sub [:profile/customization-color])]
[rn/touchable-highlight
{:style style/container
:on-press (open-chat chat-id)
:underlay-color (colors/resolve-color customization-color theme 5)
:on-long-press #(rf/dispatch [:show-bottom-sheet
(cond-> {:content (fn [] [actions/chat-actions item false])}
(= chat-type constants/one-to-one-chat-type)
(assoc :selected-item
(fn [] [chat-user item])))])}
[chat-item item]]))
3 changes: 2 additions & 1 deletion src/status_im2/contexts/chat/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
:on-end-reached #(re-frame/dispatch [:chat/show-more-chats])
:keyboard-should-persist-taps :always
:data items
:render-fn chat-list-item/chat-list-item
:render-fn (fn [item]
(chat-list-item/chat-list-item item theme))
:scroll-event-throttle 8
:content-container-style {:padding-bottom
jump-to.constants/floating-shell-button-height}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
[id muted? muted-till]
(let [time-string (fn [mute-title mute-duration]
(i18n/label mute-title {:duration mute-duration}))]
{:icon (if muted? :i/muted :i/activity-center)
{:icon (if muted? :i/activity-center :i/muted)
:accessibility-label (if muted? :unmute-community :mute-community)
:label (i18n/label (if muted? :t/unmute-community :t/mute-community))
:sub-label (when (and muted? (some? muted-till))
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.171.30",
"commit-sha1": "be8568e1744ee6d5afb99920e849e65e3ab67d7a",
"src-sha256": "0yq1gsyp2lbx148n31wfcbh0qs125vs4hh7qzzv972xcsqkflyjx"
"version": "v0.171.31",
"commit-sha1": "271778a1e07e585a12790b4e2226f13e36ea89f4",
"src-sha256": "1c998kyhya98a0zp795i3xrx2r08yjdaifb32ylr4snjjln6k34c"
}
2 changes: 1 addition & 1 deletion test/appium/views/chat_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def __init__(self, driver):
self.add_to_contacts = Button(self.driver, accessibility_id="add-to-contacts-button")
## Options
self.chat_options = ChatOptionsButton(self.driver)
self.delete_chat_button = Button(self.driver, translation_id="delete-chat")
self.delete_chat_button = Button(self.driver, translation_id="close-chat")
self.clear_history_button = Button(self.driver, translation_id="clear-history")
self.reply_message_button = Button(self.driver, translation_id="message-reply")
self.share_chat_button = Button(self.driver, accessibility_id="share-chat-button")
Expand Down
2 changes: 1 addition & 1 deletion test/appium/views/home_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def __init__(self, driver):

# Options on long tap
self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button")
self.delete_chat_button = Button(self.driver, translation_id="delete-chat")
self.delete_chat_button = Button(self.driver, translation_id="close-chat")
self.clear_history_button = Button(self.driver, accessibility_id="clear-history")
self.mute_chat_button = MuteButton(self.driver, accessibility_id="mute-chat")
self.mute_community_button = MuteButton(self.driver, accessibility_id="mute-community")
Expand Down
2 changes: 1 addition & 1 deletion translations/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"remove": "Verwyder",
"add-members": "Voeg lede by",
"done": "Gedoen",
"delete-chat": "Skrap klets",
"close-chat": "Skrap klets",
"new-group-chat": "Nuwe groepgeselsie",
"sign-in": "Teken aan",
"datetime-yesterday": "gister",
Expand Down
4 changes: 2 additions & 2 deletions translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@
"delete-bootnode-are-you-sure": "هل أنت متأكد أنك تريد حذف bootnode؟",
"delete-bootnode-title": "حذف عقدة البوت",
"delete-category-confirmation": "هل أنت متأكد أنك تريد حذف هذه الفئة؟",
"delete-chat": "حذف الدردشة",
"delete-chat-confirmation": "هل أنت متأكد أنك تريد حذف هذه الدردشة؟",
"close-chat": "حذف الدردشة",
"close-chat-confirmation": "هل أنت متأكد أنك تريد حذف هذه الدردشة؟",
"delete-confirmation": "حذف؟",
"delete-keys-keycard": "حذف المفاتيح من بطاقة المفتاح",
"delete-mailserver": "حذف عقدة Status",
Expand Down
4 changes: 2 additions & 2 deletions translations/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@
"delete-bootnode-are-you-sure": "আপনি কি নিশ্চিত যে আপনি এই bootnode টি মুছে ফেলতে চান?",
"delete-bootnode-title": "bootnode মুছুন",
"delete-category-confirmation": "আপনি কি এই বিভাগটি মুছে ফেলার বিষয়ে নিশ্চিত?\n",
"delete-chat": "চ্যাট মুছুন",
"delete-chat-confirmation": "আপনি কি নিশ্চিত যে আপনি এই চ্যাটটি মুছে ফেলতে চান?",
"close-chat": "চ্যাট মুছুন",
"close-chat-confirmation": "আপনি কি নিশ্চিত যে আপনি এই চ্যাটটি মুছে ফেলতে চান?",
"delete-confirmation": "মুছে ফেলা?",
"delete-keys-keycard": "কীকার্ড থেকে কীগুলি মুছুন",
"delete-mailserver": "ইতিহাস নোড মুছে ফেলুন",
Expand Down
2 changes: 1 addition & 1 deletion translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"add-members": "Přidat členy",
"photos-access-error": "Pro udělení potřebných oprávnění k fotoaparátu přejděte do nastavení systému a ujistěte se, že je vybráno Status > Fotoaparát.",
"done": "Hotovo",
"delete-chat": "Smazat chat",
"close-chat": "Smazat chat",
"new-group-chat": "Nový skupinový chat",
"wallet": "Peněženka",
"wallet-request": "Požadavek",
Expand Down
2 changes: 1 addition & 1 deletion translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"add-members": "Tilføj medlemmere",
"photos-access-error": "Gå venligst til dine systemindstillinger og sørg for at du Status > Billeder er tilladt.",
"done": "Klar",
"delete-chat": "Fjern samtale",
"close-chat": "Fjern samtale",
"new-group-chat": "Ny gruppsamtale",
"sign-in": "Log på",
"datetime-yesterday": "i går",
Expand Down
4 changes: 2 additions & 2 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@
"delete-bootnode-are-you-sure": "Möchten Sie diesen Bootknoten wirklich löschen?",
"delete-bootnode-title": "Bootknoten löschen",
"delete-category-confirmation": "Möchten Sie diese Kategorie wirklich löschen?",
"delete-chat": "Chat löschen",
"delete-chat-confirmation": "Möchten Sie diesen Chat wirklich löschen?",
"close-chat": "Chat löschen",
"close-chat-confirmation": "Möchten Sie diesen Chat wirklich löschen?",
"delete-confirmation": "Löschen?",
"delete-keys-keycard": "Schlüssel von der Schlüsselkarte löschen",
"delete-mailserver": "Mailserver löschen",
Expand Down
4 changes: 2 additions & 2 deletions translations/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@
"delete-bootnode": "Διαγραφή bootnode",
"delete-bootnode-are-you-sure": "Είστε βέβαιοι ότι θέλετε να διαγράψετε αυτόν τον bootnode;",
"delete-bootnode-title": "Διαγραφή bootnode",
"delete-chat": "Διαγραφή συνομιλίας",
"delete-chat-confirmation": "Είστε βέβαιοι ότι θέλετε να διαγράψετε αυτήν τη συζήτηση;",
"close-chat": "Διαγραφή συνομιλίας",
"close-chat-confirmation": "Είστε βέβαιοι ότι θέλετε να διαγράψετε αυτήν τη συζήτηση;",
"delete-confirmation": "Διαγραφή;",
"delete-mailserver": "Διαγραφή κόμβου ιστορικού",
"delete-mailserver-are-you-sure": "Είστε βέβαιοι ότι θέλετε να διαγράψετε αυτόν τον κόμβο ιστορικού;",
Expand Down
Loading

0 comments on commit f155d95

Please sign in to comment.