Skip to content

Commit 59323e5

Browse files
committed
[#22404] [News Feed] Implement News AC component
1 parent 13959f6 commit 59323e5

File tree

11 files changed

+134
-7
lines changed

11 files changed

+134
-7
lines changed

src/legacy/status_im/data_store/activities.cljs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@
6464
:communityId :community-id
6565
:installationId :installation-id
6666
:membershipStatus :membership-status
67-
:albumMessages :album-messages})
67+
:albumMessages :album-messages
68+
:newsImageUrl :news-image-url
69+
:newsTitle :news-title
70+
:newsDescription :news-description
71+
:newsContent :news-content
72+
:newsLink :news-link
73+
:newsLinkLabel :news-link-label})
6874
(update :last-message #(when % (messages/<-rpc %)))
6975
(update :message #(when % (messages/<-rpc %)))
7076
(update :reply-message #(when % (messages/<-rpc %)))

src/status_im/contexts/settings/privacy_and_security/view.cljs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
(let [customization-color (rf/sub [:profile/customization-color])
3030

3131
preview-privacy? (rf/sub [:profile/preview-privacy?])
32+
news-feed-enabled? (rf/sub [:profile/news-feed-enabled?])
3233
see-profile-pictures-from (rf/sub [:profile/pictures-visibility])
3334
show-profile-pictures-to (rf/sub [:multiaccount/profile-pictures-show-to])
3435

@@ -38,6 +39,14 @@
3839
(not preview-privacy?)]))
3940
[preview-privacy?])
4041

42+
toggle-news-feed
43+
(rn/use-callback (fn []
44+
(rf/dispatch [:profile.settings/profile-update :news-feed-enabled?
45+
(not news-feed-enabled?)])
46+
(rf/dispatch [:profile.settings/profile-update :news-rss-enabled?
47+
(not news-feed-enabled?)]))
48+
[news-feed-enabled?])
49+
4150
open-see-profile-pictures-from-options
4251
(rn/use-callback (fn []
4352
(rf/dispatch
@@ -89,6 +98,15 @@
8998
:blur? true
9099
:action :arrow
91100
:action-props {:on-change #(rf/dispatch [:open-modal
92-
:screen/settings.share-usage-data])}}]
101+
:screen/settings.share-usage-data])}}
102+
{:title (i18n/label :t/status-news-rss)
103+
:description :text
104+
:description-props {:text (i18n/label :t/rss-privacy-warning)}
105+
:blur? true
106+
:action :selector
107+
:action-props {:on-change toggle-news-feed
108+
:checked? news-feed-enabled?
109+
:id :news-feed
110+
:customization-color customization-color}}]
93111
:blur? true
94112
:list-type :settings}]]))
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
(ns status-im.contexts.shell.activity-center.notification.news.view
2+
(:require [clojure.string :as string]
3+
[promesa.core :as promesa]
4+
[quo.core :as quo]
5+
[react-native.core :as rn]
6+
[react-native.gesture :as gesture]
7+
[status-im.contexts.shell.activity-center.notification.common.view :as common]
8+
[utils.datetime :as datetime]
9+
[utils.i18n :as i18n]
10+
[utils.re-frame :as rf]))
11+
12+
(defn auto-resized-image
13+
[url]
14+
(let [[height set-height] (rn/use-state nil)
15+
window-width (- (:width (rn/get-window)) 40)]
16+
(rn/use-effect #(-> (rn/image-get-size url)
17+
(promesa/then (fn [[w h]]
18+
(let [scale (/ window-width w)
19+
new-height (* h scale)]
20+
(set-height new-height))))))
21+
(if height
22+
[rn/image
23+
{:resize-mode :contain
24+
:style {:width window-width
25+
:height height
26+
:align-self :center
27+
:border-radius 12}
28+
:source url}]
29+
[rn/view {:style {:height 200 :align-items :center :justify-content :center}}
30+
[rn/activity-indicator]])))
31+
32+
(defn sheet
33+
[{:keys [news-image-url news-title news-content news-link news-link-label]} timestamp]
34+
(let [customization-color (rf/sub [:profile/customization-color])]
35+
[:<>
36+
[quo/drawer-top {:title news-title :description timestamp}]
37+
[rn/scroll-view {:style {:flex 1}}
38+
(when (not (string/blank? news-image-url))
39+
[auto-resized-image news-image-url])
40+
[quo/text
41+
{:style {:padding-horizontal 20
42+
:padding-vertical 8}}
43+
news-content]]
44+
(when (and (not (string/blank? news-link)) (not (string/blank? news-link-label)))
45+
[quo/bottom-actions
46+
{:button-one-label news-link-label
47+
:button-one-props {:customization-color customization-color
48+
:icon-right :i/external
49+
:on-press (fn []
50+
(rf/dispatch [:browser.ui/open-url news-link])
51+
(rf/dispatch [:hide-bottom-sheet]))}}])]))
52+
53+
(defn view
54+
[{:keys [notification extra-fn]}]
55+
(let [customization-color (rf/sub [:profile/customization-color])
56+
{:keys [news-title
57+
news-description
58+
timestamp]} notification
59+
timestamp (datetime/timestamp->relative timestamp)
60+
on-press (rn/use-callback
61+
#(rf/dispatch [:show-bottom-sheet
62+
{:theme :dark
63+
:content (fn []
64+
[sheet notification timestamp])}]))]
65+
[common/swipeable
66+
{:left-button common/swipe-button-read-or-unread
67+
:left-on-press common/swipe-on-press-toggle-read
68+
:right-button common/swipe-button-delete
69+
:right-on-press common/swipe-on-press-delete
70+
:extra-fn extra-fn}
71+
[gesture/touchable-without-feedback
72+
{:on-press on-press}
73+
[quo/activity-log
74+
{:title news-title
75+
:customization-color customization-color
76+
:icon :i/status-logo-bw
77+
:timestamp timestamp
78+
:context [[quo/text {} news-description]]
79+
:items [{:type :button
80+
:subtype :primary
81+
:key :button-reply
82+
:customization-color customization-color
83+
:label (i18n/label :t/read-more)
84+
:accessibility-label :read-more
85+
:on-press on-press}]}]]]))

src/status_im/contexts/shell/activity_center/notification_types.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(def ^:const contact-verification 10)
1313
(def ^:const new-installation-received 23)
1414
(def ^:const new-installation-created 24)
15+
(def ^:const news-feed 29)
1516

1617
(def ^:const all-supported
1718
#{one-to-one-chat
@@ -24,7 +25,8 @@
2425
community-kicked
2526
contact-verification
2627
new-installation-received
27-
new-installation-created})
28+
new-installation-created
29+
news-feed})
2830

2931
;; TODO: Replace with correct enum values once status-go implements them.
3032
(def ^:const tx 66612)

src/status_im/contexts/shell/activity_center/tabs/view.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
:default-active filter-type
3030
:data [{:id types/no-type
3131
:label (i18n/label :t/all)}
32+
{:id types/news-feed
33+
:label (i18n/label :t/news)
34+
:accessibility-label :tab-news
35+
:notification-dot? (when-not is-mark-all-as-read-undoable?
36+
(contains? types-with-unread types/news-feed))}
3237
{:id types/admin
3338
:label (i18n/label :t/admin)
3439
:accessibility-label :tab-admin

src/status_im/contexts/shell/activity_center/view.cljs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
contact-verification]
1919
[status-im.contexts.shell.activity-center.notification.membership.view :as membership]
2020
[status-im.contexts.shell.activity-center.notification.mentions.view :as mentions]
21+
[status-im.contexts.shell.activity-center.notification.news.view :as news]
2122
[status-im.contexts.shell.activity-center.notification.reply.view :as reply]
2223
[status-im.contexts.shell.activity-center.notification.syncing.view :as syncing]
2324
[status-im.contexts.shell.activity-center.style :as style]
@@ -55,6 +56,9 @@
5556
(= notification-type types/new-installation-created)
5657
[syncing/installation-created-view props]
5758

59+
(= notification-type types/news-feed)
60+
[news/view props]
61+
5862
(types/membership notification-type)
5963
(condp = notification-type
6064
types/private-group-chat [membership/view props]
@@ -69,7 +73,6 @@
6973
(defn view
7074
[]
7175
(let [notifications (rf/sub [:activity-center/notifications])
72-
7376
;; We globally control the active swipeable for all notifications
7477
;; because when a swipe left/right gesture initiates, the previously
7578
;; active swiped notification (if any) must be removed & closed with

src/status_im/subs/profile.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
(fn [{:keys [preview-privacy?]}]
235235
(boolean preview-privacy?)))
236236

237+
(re-frame/reg-sub :profile/news-feed-enabled?
238+
:<- [:profile/profile]
239+
(fn [{:keys [news-feed-enabled?]}]
240+
(boolean news-feed-enabled?)))
241+
237242
(defn- replace-multiaccount-image-uri
238243
[profile port font-file avatar-opts theme]
239244
(let [{:keys [key-uid images

status-go-version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
44
"owner": "status-im",
55
"repo": "status-go",
6-
"version": "v10.27.0",
7-
"commit-sha1": "f5fe88d8b31a287e66a48fe90ef613c7617279b6",
8-
"src-sha256": "01cn2f9f3sq5dmygh4gqpip5zp9f61383xix7rfwxr2nazbqrka3"
6+
"version": "feat/news-feed-mobile",
7+
"commit-sha1": "6ded349455d121039625961cec23fdbb403fb175",
8+
"src-sha256": "1rvnvmzvq9g4rnc3mvbyk63m8v6zv8bvim586p2l4x02p2ywha29"
99
}

0 commit comments

Comments
 (0)