From 59323e5b02997aa3e797a87b6f27b402f7c1149b Mon Sep 17 00:00:00 2001 From: andrey Date: Mon, 7 Apr 2025 14:20:23 +0200 Subject: [PATCH 1/2] [#22404] [News Feed] Implement News AC component --- ...{status@2x-1.png => status-logo-bw@2x.png} | Bin ...{status@3x-1.png => status-logo-bw@3x.png} | Bin .../status_im/data_store/activities.cljs | 8 +- .../settings/privacy_and_security/view.cljs | 20 ++++- .../notification/news/view.cljs | 85 ++++++++++++++++++ .../activity_center/notification_types.cljs | 4 +- .../shell/activity_center/tabs/view.cljs | 5 ++ .../contexts/shell/activity_center/view.cljs | 5 +- src/status_im/subs/profile.cljs | 5 ++ status-go-version.json | 6 +- translations/en.json | 3 + 11 files changed, 134 insertions(+), 7 deletions(-) rename resources/images/icons2/20x20/{status@2x-1.png => status-logo-bw@2x.png} (100%) rename resources/images/icons2/20x20/{status@3x-1.png => status-logo-bw@3x.png} (100%) create mode 100644 src/status_im/contexts/shell/activity_center/notification/news/view.cljs diff --git a/resources/images/icons2/20x20/status@2x-1.png b/resources/images/icons2/20x20/status-logo-bw@2x.png similarity index 100% rename from resources/images/icons2/20x20/status@2x-1.png rename to resources/images/icons2/20x20/status-logo-bw@2x.png diff --git a/resources/images/icons2/20x20/status@3x-1.png b/resources/images/icons2/20x20/status-logo-bw@3x.png similarity index 100% rename from resources/images/icons2/20x20/status@3x-1.png rename to resources/images/icons2/20x20/status-logo-bw@3x.png diff --git a/src/legacy/status_im/data_store/activities.cljs b/src/legacy/status_im/data_store/activities.cljs index fe72a87bc85..a6395d25310 100644 --- a/src/legacy/status_im/data_store/activities.cljs +++ b/src/legacy/status_im/data_store/activities.cljs @@ -64,7 +64,13 @@ :communityId :community-id :installationId :installation-id :membershipStatus :membership-status - :albumMessages :album-messages}) + :albumMessages :album-messages + :newsImageUrl :news-image-url + :newsTitle :news-title + :newsDescription :news-description + :newsContent :news-content + :newsLink :news-link + :newsLinkLabel :news-link-label}) (update :last-message #(when % (messages/<-rpc %))) (update :message #(when % (messages/<-rpc %))) (update :reply-message #(when % (messages/<-rpc %))) diff --git a/src/status_im/contexts/settings/privacy_and_security/view.cljs b/src/status_im/contexts/settings/privacy_and_security/view.cljs index 79d07d77dfa..4cc42dd853c 100644 --- a/src/status_im/contexts/settings/privacy_and_security/view.cljs +++ b/src/status_im/contexts/settings/privacy_and_security/view.cljs @@ -29,6 +29,7 @@ (let [customization-color (rf/sub [:profile/customization-color]) preview-privacy? (rf/sub [:profile/preview-privacy?]) + news-feed-enabled? (rf/sub [:profile/news-feed-enabled?]) see-profile-pictures-from (rf/sub [:profile/pictures-visibility]) show-profile-pictures-to (rf/sub [:multiaccount/profile-pictures-show-to]) @@ -38,6 +39,14 @@ (not preview-privacy?)])) [preview-privacy?]) + toggle-news-feed + (rn/use-callback (fn [] + (rf/dispatch [:profile.settings/profile-update :news-feed-enabled? + (not news-feed-enabled?)]) + (rf/dispatch [:profile.settings/profile-update :news-rss-enabled? + (not news-feed-enabled?)])) + [news-feed-enabled?]) + open-see-profile-pictures-from-options (rn/use-callback (fn [] (rf/dispatch @@ -89,6 +98,15 @@ :blur? true :action :arrow :action-props {:on-change #(rf/dispatch [:open-modal - :screen/settings.share-usage-data])}}] + :screen/settings.share-usage-data])}} + {:title (i18n/label :t/status-news-rss) + :description :text + :description-props {:text (i18n/label :t/rss-privacy-warning)} + :blur? true + :action :selector + :action-props {:on-change toggle-news-feed + :checked? news-feed-enabled? + :id :news-feed + :customization-color customization-color}}] :blur? true :list-type :settings}]])) diff --git a/src/status_im/contexts/shell/activity_center/notification/news/view.cljs b/src/status_im/contexts/shell/activity_center/notification/news/view.cljs new file mode 100644 index 00000000000..969caa63ad6 --- /dev/null +++ b/src/status_im/contexts/shell/activity_center/notification/news/view.cljs @@ -0,0 +1,85 @@ +(ns status-im.contexts.shell.activity-center.notification.news.view + (:require [clojure.string :as string] + [promesa.core :as promesa] + [quo.core :as quo] + [react-native.core :as rn] + [react-native.gesture :as gesture] + [status-im.contexts.shell.activity-center.notification.common.view :as common] + [utils.datetime :as datetime] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) + +(defn auto-resized-image + [url] + (let [[height set-height] (rn/use-state nil) + window-width (- (:width (rn/get-window)) 40)] + (rn/use-effect #(-> (rn/image-get-size url) + (promesa/then (fn [[w h]] + (let [scale (/ window-width w) + new-height (* h scale)] + (set-height new-height)))))) + (if height + [rn/image + {:resize-mode :contain + :style {:width window-width + :height height + :align-self :center + :border-radius 12} + :source url}] + [rn/view {:style {:height 200 :align-items :center :justify-content :center}} + [rn/activity-indicator]]))) + +(defn sheet + [{:keys [news-image-url news-title news-content news-link news-link-label]} timestamp] + (let [customization-color (rf/sub [:profile/customization-color])] + [:<> + [quo/drawer-top {:title news-title :description timestamp}] + [rn/scroll-view {:style {:flex 1}} + (when (not (string/blank? news-image-url)) + [auto-resized-image news-image-url]) + [quo/text + {:style {:padding-horizontal 20 + :padding-vertical 8}} + news-content]] + (when (and (not (string/blank? news-link)) (not (string/blank? news-link-label))) + [quo/bottom-actions + {:button-one-label news-link-label + :button-one-props {:customization-color customization-color + :icon-right :i/external + :on-press (fn [] + (rf/dispatch [:browser.ui/open-url news-link]) + (rf/dispatch [:hide-bottom-sheet]))}}])])) + +(defn view + [{:keys [notification extra-fn]}] + (let [customization-color (rf/sub [:profile/customization-color]) + {:keys [news-title + news-description + timestamp]} notification + timestamp (datetime/timestamp->relative timestamp) + on-press (rn/use-callback + #(rf/dispatch [:show-bottom-sheet + {:theme :dark + :content (fn [] + [sheet notification timestamp])}]))] + [common/swipeable + {:left-button common/swipe-button-read-or-unread + :left-on-press common/swipe-on-press-toggle-read + :right-button common/swipe-button-delete + :right-on-press common/swipe-on-press-delete + :extra-fn extra-fn} + [gesture/touchable-without-feedback + {:on-press on-press} + [quo/activity-log + {:title news-title + :customization-color customization-color + :icon :i/status-logo-bw + :timestamp timestamp + :context [[quo/text {} news-description]] + :items [{:type :button + :subtype :primary + :key :button-reply + :customization-color customization-color + :label (i18n/label :t/read-more) + :accessibility-label :read-more + :on-press on-press}]}]]])) diff --git a/src/status_im/contexts/shell/activity_center/notification_types.cljs b/src/status_im/contexts/shell/activity_center/notification_types.cljs index 7e3159edfd9..ded40a0a547 100644 --- a/src/status_im/contexts/shell/activity_center/notification_types.cljs +++ b/src/status_im/contexts/shell/activity_center/notification_types.cljs @@ -12,6 +12,7 @@ (def ^:const contact-verification 10) (def ^:const new-installation-received 23) (def ^:const new-installation-created 24) +(def ^:const news-feed 29) (def ^:const all-supported #{one-to-one-chat @@ -24,7 +25,8 @@ community-kicked contact-verification new-installation-received - new-installation-created}) + new-installation-created + news-feed}) ;; TODO: Replace with correct enum values once status-go implements them. (def ^:const tx 66612) diff --git a/src/status_im/contexts/shell/activity_center/tabs/view.cljs b/src/status_im/contexts/shell/activity_center/tabs/view.cljs index 7cb42260cb5..f412a2ef029 100644 --- a/src/status_im/contexts/shell/activity_center/tabs/view.cljs +++ b/src/status_im/contexts/shell/activity_center/tabs/view.cljs @@ -29,6 +29,11 @@ :default-active filter-type :data [{:id types/no-type :label (i18n/label :t/all)} + {:id types/news-feed + :label (i18n/label :t/news) + :accessibility-label :tab-news + :notification-dot? (when-not is-mark-all-as-read-undoable? + (contains? types-with-unread types/news-feed))} {:id types/admin :label (i18n/label :t/admin) :accessibility-label :tab-admin diff --git a/src/status_im/contexts/shell/activity_center/view.cljs b/src/status_im/contexts/shell/activity_center/view.cljs index bc5fd777730..2fe1bc69a0d 100644 --- a/src/status_im/contexts/shell/activity_center/view.cljs +++ b/src/status_im/contexts/shell/activity_center/view.cljs @@ -18,6 +18,7 @@ contact-verification] [status-im.contexts.shell.activity-center.notification.membership.view :as membership] [status-im.contexts.shell.activity-center.notification.mentions.view :as mentions] + [status-im.contexts.shell.activity-center.notification.news.view :as news] [status-im.contexts.shell.activity-center.notification.reply.view :as reply] [status-im.contexts.shell.activity-center.notification.syncing.view :as syncing] [status-im.contexts.shell.activity-center.style :as style] @@ -55,6 +56,9 @@ (= notification-type types/new-installation-created) [syncing/installation-created-view props] + (= notification-type types/news-feed) + [news/view props] + (types/membership notification-type) (condp = notification-type types/private-group-chat [membership/view props] @@ -69,7 +73,6 @@ (defn view [] (let [notifications (rf/sub [:activity-center/notifications]) - ;; We globally control the active swipeable for all notifications ;; because when a swipe left/right gesture initiates, the previously ;; active swiped notification (if any) must be removed & closed with diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index ac7beec1f8f..179e1bf0733 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -234,6 +234,11 @@ (fn [{:keys [preview-privacy?]}] (boolean preview-privacy?))) +(re-frame/reg-sub :profile/news-feed-enabled? + :<- [:profile/profile] + (fn [{:keys [news-feed-enabled?]}] + (boolean news-feed-enabled?))) + (defn- replace-multiaccount-image-uri [profile port font-file avatar-opts theme] (let [{:keys [key-uid images diff --git a/status-go-version.json b/status-go-version.json index fc8d3c4bbfa..cbcd8510819 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v10.27.0", - "commit-sha1": "f5fe88d8b31a287e66a48fe90ef613c7617279b6", - "src-sha256": "01cn2f9f3sq5dmygh4gqpip5zp9f61383xix7rfwxr2nazbqrka3" + "version": "feat/news-feed-mobile", + "commit-sha1": "6ded349455d121039625961cec23fdbb403fb175", + "src-sha256": "1rvnvmzvq9g4rnc3mvbyk63m8v6zv8bvim586p2l4x02p2ywha29" } diff --git a/translations/en.json b/translations/en.json index 352d8137d00..0cfa3b788ee 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1829,6 +1829,7 @@ "new-tab": "New tab", "new-to-status": "I’m new to Status", "new-ui": "New UI", + "news": "News", "next": "Next", "next-you-will": "Next, you will be asked to confirm the position of certain words in your recovery phrase", "NFT": "NFT", @@ -2315,6 +2316,7 @@ "rpc-usage-info": "RPC usage stats", "rpc-usage-reset": "Reset", "rpc-usage-total": "Total", + "rss-privacy-warning": "Fetches news from external sites which may expose your IP", "sa": "Sa", "safe-estimate": "Safe estimate", "sat": "Sat", @@ -2591,6 +2593,7 @@ "status-is-open-source": "Status is open-source", "status-keycard": "Status Keycard", "status-mobile-descr": "Status tends to use a lot of data when syncing chats. You can choose not to sync when on mobile network", + "status-news-rss": "Receive Status News via RSS", "status-not-sent-click": "Not confirmed. Click for options", "status-not-sent-tap": "Not confirmed. Tap for options", "status-pending": "Pending", From 09a4dfa7db8c76af05c2786d464a9242dbf0a05a Mon Sep 17 00:00:00 2001 From: andrey Date: Tue, 20 May 2025 09:37:25 +0200 Subject: [PATCH 2/2] QA --- .../activity_center/notification/news/view.cljs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/status_im/contexts/shell/activity_center/notification/news/view.cljs b/src/status_im/contexts/shell/activity_center/notification/news/view.cljs index 969caa63ad6..b1ae549bd27 100644 --- a/src/status_im/contexts/shell/activity_center/notification/news/view.cljs +++ b/src/status_im/contexts/shell/activity_center/notification/news/view.cljs @@ -55,13 +55,17 @@ (let [customization-color (rf/sub [:profile/customization-color]) {:keys [news-title news-description - timestamp]} notification + timestamp + read + id]} notification timestamp (datetime/timestamp->relative timestamp) on-press (rn/use-callback - #(rf/dispatch [:show-bottom-sheet - {:theme :dark - :content (fn [] - [sheet notification timestamp])}]))] + (fn [] + (rf/dispatch [:activity-center.notifications/mark-as-read id]) + (rf/dispatch [:show-bottom-sheet + {:theme :dark + :content (fn [] + [sheet notification timestamp])}])))] [common/swipeable {:left-button common/swipe-button-read-or-unread :left-on-press common/swipe-on-press-toggle-read @@ -75,6 +79,7 @@ :customization-color customization-color :icon :i/status-logo-bw :timestamp timestamp + :unread? (not read) :context [[quo/text {} news-description]] :items [{:type :button :subtype :primary