Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed May 6, 2024
1 parent 8a24185 commit ff69484
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[status-im.contexts.wallet.account.tabs.view :as tabs]
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

Expand Down Expand Up @@ -56,7 +55,7 @@
:data (tabs-data watch-only?)
:on-change (rn/use-callback (fn [tab]
(when (and (= :activity tab)
(ff/enabled? :FLAG_WALLET_ACTIVITY_ENABLED))
true)
(rf/dispatch [:wallet/fetch-activities]))
(reset! selected-tab tab)))
:scrollable? true
Expand Down
12 changes: 7 additions & 5 deletions src/status_im/contexts/wallet/common/activity_tab/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@
{:title (i18n/label :t/no-activity)
:description (i18n/label :t/empty-tab-description)
:image (resources/get-themed-image :no-activity theme)}]
[rn/flat-list
{:data activity-list
:style {:flex 1}
:content-container-style {:padding-bottom jump-to.constants/floating-shell-button-height}
:render-fn activity-item}])))
[rn/section-list
{:sections activity-list
:sticky-section-headers-enabled false
:style {:flex 1}
:content-container-style {:padding-bottom jump-to.constants/floating-shell-button-height}
:render-fn activity-item
:render-section-header-fn (fn [{:keys [title]}] [quo/divider-date title])}])))
2 changes: 0 additions & 2 deletions src/status_im/contexts/wallet/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,5 @@
:default-active selected-tab
:data tabs-data
:on-change (fn [tab]
(when (= :activity tab)
(rf/dispatch [:wallet/fetch-activities]))
(set-selected-tab tab))}]
[tabs/view {:selected-tab selected-tab}]]))
16 changes: 11 additions & 5 deletions src/status_im/subs/wallet/activities.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns status-im.subs.wallet.activities
(:require [re-frame.core :as rf]))
(:require
[re-frame.core :as rf]
[utils.datetime :as datetime]))

(rf/reg-sub
:wallet/all-activities
Expand All @@ -11,7 +13,11 @@
:<- [:wallet/all-activities]
:<- [:wallet/current-viewing-account-address]
(fn [[activities current-viewing-account-address]]
(filter (fn [{:keys [sender recipient]}]
(or (= sender current-viewing-account-address)
(= recipient current-viewing-account-address)))
activities)))
(let [relevant-activities (filter (fn [{:keys [sender recipient]}]
(or (= sender current-viewing-account-address)
(= recipient current-viewing-account-address)))
activities)
grouped-by-day (group-by (fn [{:keys [timestamp]}]
(datetime/timestamp->relative-short-date (* timestamp 1000)))
relevant-activities)]
(map (fn [[date acts]] {:title date :data acts}) grouped-by-day))))
11 changes: 11 additions & 0 deletions src/utils/datetime.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@
(previous-years? datetime)
(.format ^js (date-fmt) datetime))))

(defn full-date->short-date
[s]
(let [words (string/split s #"\s+")]
(string/join " " (take (- (count words) 2) words))))

(defn timestamp->relative-short-date
[ms]
(->> ms
timestamp->relative
full-date->short-date))

(defn timestamp->mini-date
[ms]
(.format ^js (short-date-fmt)
Expand Down

0 comments on commit ff69484

Please sign in to comment.