Fix recent album not showing count (#17498)
This commit is contained in:
parent
ca2b3abb1c
commit
8296bda85b
|
@ -33,7 +33,8 @@
|
||||||
android:name=".MainApplication"
|
android:name=".MainApplication"
|
||||||
android:largeHeap="true"
|
android:largeHeap="true"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:extractNativeLibs="true">
|
android:extractNativeLibs="true"
|
||||||
|
android:requestLegacyExternalStorage="true">
|
||||||
<!-- After upgrading Android Gradle Plugin to 4.2.0 and above we must get rid of `extractNativeLibs="true"`
|
<!-- After upgrading Android Gradle Plugin to 4.2.0 and above we must get rid of `extractNativeLibs="true"`
|
||||||
and use`useLegacyPackaging` flag in our app's `build.gradle`-->
|
and use`useLegacyPackaging` flag in our app's `build.gradle`-->
|
||||||
<meta-data android:name="commitHash" android:value="${commitHash}"/>
|
<meta-data android:name="commitHash" android:value="${commitHash}"/>
|
||||||
|
|
|
@ -247,7 +247,7 @@ PODS:
|
||||||
- React-Core
|
- React-Core
|
||||||
- react-native-blur (4.3.3):
|
- react-native-blur (4.3.3):
|
||||||
- React-Core
|
- React-Core
|
||||||
- react-native-cameraroll (4.0.4):
|
- react-native-cameraroll (5.10.0):
|
||||||
- React-Core
|
- React-Core
|
||||||
- react-native-config (1.5.0):
|
- react-native-config (1.5.0):
|
||||||
- react-native-config/App (= 1.5.0)
|
- react-native-config/App (= 1.5.0)
|
||||||
|
@ -468,7 +468,7 @@ DEPENDENCIES:
|
||||||
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
|
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
|
||||||
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
|
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
|
||||||
- "react-native-blur (from `../node_modules/@react-native-community/blur`)"
|
- "react-native-blur (from `../node_modules/@react-native-community/blur`)"
|
||||||
- "react-native-cameraroll (from `../node_modules/@react-native-community/cameraroll`)"
|
- "react-native-cameraroll (from `../node_modules/@react-native-camera-roll/camera-roll`)"
|
||||||
- react-native-config (from `../node_modules/react-native-config`)
|
- react-native-config (from `../node_modules/react-native-config`)
|
||||||
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
|
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
|
||||||
- react-native-lottie-splash-screen (from `../node_modules/react-native-lottie-splash-screen`)
|
- react-native-lottie-splash-screen (from `../node_modules/react-native-lottie-splash-screen`)
|
||||||
|
@ -584,7 +584,7 @@ EXTERNAL SOURCES:
|
||||||
react-native-blur:
|
react-native-blur:
|
||||||
:path: "../node_modules/@react-native-community/blur"
|
:path: "../node_modules/@react-native-community/blur"
|
||||||
react-native-cameraroll:
|
react-native-cameraroll:
|
||||||
:path: "../node_modules/@react-native-community/cameraroll"
|
:path: "../node_modules/@react-native-camera-roll/camera-roll"
|
||||||
react-native-config:
|
react-native-config:
|
||||||
:path: "../node_modules/react-native-config"
|
:path: "../node_modules/react-native-config"
|
||||||
react-native-image-resizer:
|
react-native-image-resizer:
|
||||||
|
@ -723,7 +723,7 @@ SPEC CHECKSUMS:
|
||||||
react-native-background-timer: 1f7d560647b40e6a60b01c452ba29c54bf581fc4
|
react-native-background-timer: 1f7d560647b40e6a60b01c452ba29c54bf581fc4
|
||||||
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
|
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
|
||||||
react-native-blur: c6d0a1dc2b4b519f7afe3b14d8151998632b6d18
|
react-native-blur: c6d0a1dc2b4b519f7afe3b14d8151998632b6d18
|
||||||
react-native-cameraroll: 88f4e62d9ecd0e1f253abe4f685474f2ea14bfa2
|
react-native-cameraroll: 4701ae7c3dbcd3f5e9e150ca17f250a276154b35
|
||||||
react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
|
react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
|
||||||
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
|
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
|
||||||
react-native-lottie-splash-screen: 068688c15dd478301fda00f8d87d7fb7d5b9a93e
|
react-native-lottie-splash-screen: 068688c15dd478301fda00f8d87d7fb7d5b9a93e
|
||||||
|
@ -777,6 +777,6 @@ SPEC CHECKSUMS:
|
||||||
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
|
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
|
||||||
Yoga: d24d6184b6b85f742536bd93bd07d69d7b9bb4c1
|
Yoga: d24d6184b6b85f742536bd93bd07d69d7b9bb4c1
|
||||||
|
|
||||||
PODFILE CHECKSUM: 259dd9b0a973943f02a5912c799a4db3ed475b66
|
PODFILE CHECKSUM: 6a5f0e6776ce4ef6193032d077947117ace77a87
|
||||||
|
|
||||||
COCOAPODS: 1.12.0
|
COCOAPODS: 1.12.0
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
"@babel/preset-typescript": "^7.17.12",
|
||||||
"@react-native-async-storage/async-storage": "^1.17.9",
|
"@react-native-async-storage/async-storage": "^1.17.9",
|
||||||
|
"@react-native-camera-roll/camera-roll": "git+https://github.com/status-im/react-native-camera-roll.git#refs/tags/v5.1.1.1",
|
||||||
"@react-native-community/audio-toolkit": "git+https://github.com/tbenr/react-native-audio-toolkit.git#refs/tags/v2.0.3-status-v6",
|
"@react-native-community/audio-toolkit": "git+https://github.com/tbenr/react-native-audio-toolkit.git#refs/tags/v2.0.3-status-v6",
|
||||||
"@react-native-community/blur": "git+https://github.com/status-im/react-native-blur#refs/tags/v4.3.3-status",
|
"@react-native-community/blur": "git+https://github.com/status-im/react-native-blur#refs/tags/v4.3.3-status",
|
||||||
"@react-native-community/cameraroll": "git+https://github.com/status-im/react-native-cameraroll.git#refs/tags/v4.0.4-status.0",
|
|
||||||
"@react-native-community/clipboard": "^1.2.2",
|
"@react-native-community/clipboard": "^1.2.2",
|
||||||
"@react-native-community/hooks": "^3.0.0",
|
"@react-native-community/hooks": "^3.0.0",
|
||||||
"@react-native-community/masked-view": "^0.1.6",
|
"@react-native-community/masked-view": "^0.1.6",
|
||||||
|
|
BIN
package.json.gpg
BIN
package.json.gpg
Binary file not shown.
|
@ -346,7 +346,8 @@
|
||||||
(clj->js {:BlurView {}}))
|
(clj->js {:BlurView {}}))
|
||||||
|
|
||||||
(def react-native-camera-roll
|
(def react-native-camera-roll
|
||||||
(clj->js {:default #js {}}))
|
(clj->js {:default #js {}
|
||||||
|
:CameraRoll #js {}}))
|
||||||
|
|
||||||
(def react-native-orientation-locker
|
(def react-native-orientation-locker
|
||||||
(clj->js {:default #js {}
|
(clj->js {:default #js {}
|
||||||
|
@ -410,7 +411,7 @@
|
||||||
"react-native-navigation" react-native-navigation
|
"react-native-navigation" react-native-navigation
|
||||||
"@react-native-community/push-notification-ios" push-notification-ios
|
"@react-native-community/push-notification-ios" push-notification-ios
|
||||||
"@react-native-community/blur" react-native-blur
|
"@react-native-community/blur" react-native-blur
|
||||||
"@react-native-community/cameraroll" react-native-camera-roll
|
"@react-native-camera-roll/camera-roll" react-native-camera-roll
|
||||||
"react-native-camera-kit" react-native-camera-kit
|
"react-native-camera-kit" react-native-camera-kit
|
||||||
"react-native-permissions" react-native-permissions
|
"react-native-permissions" react-native-permissions
|
||||||
"rn-emoji-keyboard" rn-emoji-keyboard
|
"rn-emoji-keyboard" rn-emoji-keyboard
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(ns react-native.cameraroll
|
(ns react-native.cameraroll
|
||||||
(:require
|
(:require
|
||||||
["@react-native-community/cameraroll" :as CameraRoll]
|
["@react-native-camera-roll/camera-roll" :refer [CameraRoll]]
|
||||||
[react-native.fs :as fs]
|
[react-native.fs :as fs]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.transforms :as transforms]))
|
[utils.transforms :as transforms]))
|
||||||
|
@ -22,3 +22,9 @@
|
||||||
(-> (.save CameraRoll (clj->js path))
|
(-> (.save CameraRoll (clj->js path))
|
||||||
(.then #(fs/unlink path))
|
(.then #(fs/unlink path))
|
||||||
(.catch #(fs/unlink path))))
|
(.catch #(fs/unlink path))))
|
||||||
|
|
||||||
|
(defn get-photos-count-ios
|
||||||
|
[cb]
|
||||||
|
(-> (.getPhotosCountiOS CameraRoll)
|
||||||
|
(.then #(cb %))
|
||||||
|
(.catch #(js/console.error %))))
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[react-native.gesture :as gesture]
|
[react-native.gesture :as gesture]
|
||||||
|
[react-native.platform :as platform]
|
||||||
[react-native.reanimated :as reanimated]
|
[react-native.reanimated :as reanimated]
|
||||||
[status-im2.contexts.chat.photo-selector.album-selector.style :as style]
|
[status-im2.contexts.chat.photo-selector.album-selector.style :as style]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
@ -61,15 +62,25 @@
|
||||||
|
|
||||||
(defn- f-album-selector
|
(defn- f-album-selector
|
||||||
[{:keys [scroll-enabled on-scroll]} album? selected-album top]
|
[{:keys [scroll-enabled on-scroll]} album? selected-album top]
|
||||||
(let [albums (rf/sub [:camera-roll/albums])
|
(let [albums (rf/sub [:camera-roll/albums])
|
||||||
albums-sections [{:title no-title :data (:smart-albums albums)}
|
total-photos-count-android (rf/sub [:camera-roll/total-photos-count-android])
|
||||||
{:title (i18n/label :t/my-albums) :data (:my-albums albums)}]
|
total-photos-count-ios (rf/sub [:camera-roll/total-photos-count-ios])
|
||||||
window-height (:height (rn/get-window))]
|
albums-sections [{:title no-title
|
||||||
|
:data [(assoc (:smart-album albums)
|
||||||
|
:count
|
||||||
|
(if platform/ios?
|
||||||
|
total-photos-count-ios
|
||||||
|
total-photos-count-android))]}
|
||||||
|
{:title (i18n/label :t/my-albums)
|
||||||
|
:data (:my-albums albums)}]
|
||||||
|
window-height (:height (rn/get-window))]
|
||||||
[reanimated/view {:style (style/selector-container top)}
|
[reanimated/view {:style (style/selector-container top)}
|
||||||
[gesture/section-list
|
[gesture/section-list
|
||||||
{:data albums-sections
|
{:data albums-sections
|
||||||
:sections albums-sections
|
:sections albums-sections
|
||||||
:render-data {:album? album? :selected-album selected-album :top top}
|
:render-data {:album? album?
|
||||||
|
:selected-album selected-album
|
||||||
|
:top top}
|
||||||
:render-fn render-album
|
:render-fn render-album
|
||||||
:sticky-section-headers-enabled false
|
:sticky-section-headers-enabled false
|
||||||
:render-section-header-fn section-header
|
:render-section-header-fn section-header
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[react-native.image-resizer :as image-resizer]
|
[react-native.image-resizer :as image-resizer]
|
||||||
[react-native.permissions :as permissions]
|
[react-native.permissions :as permissions]
|
||||||
|
[react-native.platform :as platform]
|
||||||
[status-im2.constants :as constants]
|
[status-im2.constants :as constants]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
@ -56,25 +57,25 @@
|
||||||
|
|
||||||
(defn get-albums
|
(defn get-albums
|
||||||
[callback]
|
[callback]
|
||||||
(let [albums (atom {:smart-albums []
|
(let [albums (atom {:smart-album []
|
||||||
:my-albums []})]
|
:my-albums []})]
|
||||||
;; Get the "recent" album first
|
;; Get the "recent" album first
|
||||||
(cameraroll/get-photos
|
(cameraroll/get-photos
|
||||||
{:first 1 :groupTypes "All"}
|
{:first 1 :groupTypes "All" :assetType "Photos"}
|
||||||
(fn [res-recent]
|
(fn [res-recent]
|
||||||
(swap! albums assoc
|
(swap! albums assoc
|
||||||
:smart-albums
|
:smart-album
|
||||||
[{:title (i18n/label :t/recent)
|
{:title (i18n/label :t/recent)
|
||||||
:uri (get-in (first (:edges res-recent)) [:node :image :uri])}])
|
:uri (get-in (first (:edges res-recent)) [:node :image :uri])})
|
||||||
;; Get albums, then loop over albums and get each one's cover (first photo)
|
;; Get albums, then loop over albums and get each one's cover (first photo)
|
||||||
(cameraroll/get-albums
|
(cameraroll/get-albums
|
||||||
{:assetType :Photos}
|
{:assetType "Photos"}
|
||||||
(fn [res-albums]
|
(fn [res-albums]
|
||||||
(let [response-count (count res-albums)]
|
(let [response-count (count res-albums)]
|
||||||
(if (pos? response-count)
|
(if (pos? response-count)
|
||||||
(doseq [album res-albums]
|
(doseq [album res-albums]
|
||||||
(cameraroll/get-photos
|
(cameraroll/get-photos
|
||||||
{:first 1 :groupTypes "Albums" :groupName (:title album)}
|
{:first 1 :groupTypes "Albums" :groupName (:title album) :assetType "Photos"}
|
||||||
(fn [res]
|
(fn [res]
|
||||||
(let [uri (get-in (first (:edges res)) [:node :image :uri])]
|
(let [uri (get-in (first (:edges res)) [:node :image :uri])]
|
||||||
(swap! albums update :my-albums conj (merge album {:uri uri}))
|
(swap! albums update :my-albums conj (merge album {:uri uri}))
|
||||||
|
@ -83,21 +84,42 @@
|
||||||
(callback @albums))))))
|
(callback @albums))))))
|
||||||
(callback @albums)))))))))
|
(callback @albums)))))))))
|
||||||
|
|
||||||
|
(defn get-photos-count-ios-fx
|
||||||
|
[cb]
|
||||||
|
(cameraroll/get-photos-count-ios cb))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:camera-roll-get-albums
|
:camera-roll-get-albums
|
||||||
(fn []
|
(fn []
|
||||||
(get-albums #(re-frame/dispatch [:on-camera-roll-get-albums %]))))
|
(get-albums #(re-frame/dispatch [:on-camera-roll-get-albums %]))))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
:camera-roll-get-photos-count-ios
|
||||||
|
(fn []
|
||||||
|
(when platform/ios?
|
||||||
|
(get-photos-count-ios-fx #(re-frame/dispatch [:on-camera-roll-get-images-count-ios %])))))
|
||||||
|
|
||||||
(rf/defn on-camera-roll-get-albums
|
(rf/defn on-camera-roll-get-albums
|
||||||
{:events [:on-camera-roll-get-albums]}
|
{:events [:on-camera-roll-get-albums]}
|
||||||
[{:keys [db]} albums]
|
[{:keys [db]} albums]
|
||||||
{:db (assoc db :camera-roll/albums albums)})
|
{:db (assoc db :camera-roll/albums albums)
|
||||||
|
:dispatch [:photo-selector/camera-roll-get-ios-photo-count]})
|
||||||
|
|
||||||
|
(rf/defn get-photos-count-ios
|
||||||
|
{:events [:on-camera-roll-get-images-count-ios]}
|
||||||
|
[{:keys [db]} count]
|
||||||
|
{:db (assoc db :camera-roll/ios-images-count count)})
|
||||||
|
|
||||||
(rf/defn camera-roll-get-albums
|
(rf/defn camera-roll-get-albums
|
||||||
{:events [:photo-selector/camera-roll-get-albums]}
|
{:events [:photo-selector/camera-roll-get-albums]}
|
||||||
[_]
|
[_]
|
||||||
{:camera-roll-get-albums nil})
|
{:camera-roll-get-albums nil})
|
||||||
|
|
||||||
|
(rf/defn camera-roll-get-ios-photo-count
|
||||||
|
{:events [:photo-selector/camera-roll-get-ios-photo-count]}
|
||||||
|
[_]
|
||||||
|
{:camera-roll-get-photos-count-ios nil})
|
||||||
|
|
||||||
(rf/defn camera-roll-select-album
|
(rf/defn camera-roll-select-album
|
||||||
{:events [:chat.ui/camera-roll-select-album]}
|
{:events [:chat.ui/camera-roll-select-album]}
|
||||||
[{:keys [db]} album]
|
[{:keys [db]} album]
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
[album-selector/album-selector sheet album? selected-album top])
|
[album-selector/album-selector sheet album? selected-album top])
|
||||||
[:<>
|
[:<>
|
||||||
[gesture/flat-list
|
[gesture/flat-list
|
||||||
{:key-fn identity
|
{:key-fn #(hash (:uri %))
|
||||||
:render-fn render-image
|
:render-fn render-image
|
||||||
:render-data {:window-width window-width :selected selected-images}
|
:render-data {:window-width window-width :selected selected-images}
|
||||||
:data camera-roll-photos
|
:data camera-roll-photos
|
||||||
|
|
|
@ -454,3 +454,18 @@
|
||||||
[(re-frame/subscribe [:chats/chat (str community-id channel-id)])])
|
[(re-frame/subscribe [:chats/chat (str community-id channel-id)])])
|
||||||
(fn [[chat]]
|
(fn [[chat]]
|
||||||
(:muted? chat)))
|
(:muted? chat)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:camera-roll/total-photos-count-android
|
||||||
|
(fn [{:keys [camera-roll/albums]}]
|
||||||
|
(->> albums
|
||||||
|
:my-albums
|
||||||
|
(reduce
|
||||||
|
(fn [total-album-count current-album]
|
||||||
|
(+ total-album-count (:count current-album)))
|
||||||
|
0))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:camera-roll/total-photos-count-ios
|
||||||
|
(fn [{:keys [camera-roll/ios-images-count]}]
|
||||||
|
ios-images-count))
|
||||||
|
|
|
@ -2188,6 +2188,10 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
merge-options "^3.0.4"
|
merge-options "^3.0.4"
|
||||||
|
|
||||||
|
"@react-native-camera-roll/camera-roll@git+https://github.com/status-im/react-native-camera-roll.git#refs/tags/v5.1.1.1":
|
||||||
|
version "5.10.0"
|
||||||
|
resolved "git+https://github.com/status-im/react-native-camera-roll.git#174f8c6ad88e5bad9d9bd207f42173e567ec3138"
|
||||||
|
|
||||||
"@react-native-community/audio-toolkit@git+https://github.com/tbenr/react-native-audio-toolkit.git#refs/tags/v2.0.3-status-v6":
|
"@react-native-community/audio-toolkit@git+https://github.com/tbenr/react-native-audio-toolkit.git#refs/tags/v2.0.3-status-v6":
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "git+https://github.com/tbenr/react-native-audio-toolkit.git#7ae9055cf6169b30f5089bda7bfcfc1c40a715e5"
|
resolved "git+https://github.com/tbenr/react-native-audio-toolkit.git#7ae9055cf6169b30f5089bda7bfcfc1c40a715e5"
|
||||||
|
@ -2200,10 +2204,6 @@
|
||||||
version "4.3.3"
|
version "4.3.3"
|
||||||
resolved "git+https://github.com/status-im/react-native-blur#c140cc8e7d54e3318af0a7c149b5d64b54de3419"
|
resolved "git+https://github.com/status-im/react-native-blur#c140cc8e7d54e3318af0a7c149b5d64b54de3419"
|
||||||
|
|
||||||
"@react-native-community/cameraroll@git+https://github.com/status-im/react-native-cameraroll.git#refs/tags/v4.0.4-status.0":
|
|
||||||
version "4.0.4"
|
|
||||||
resolved "git+https://github.com/status-im/react-native-cameraroll.git#337c5a515e9b0f0728882f73568075553415f523"
|
|
||||||
|
|
||||||
"@react-native-community/cli-clean@^8.0.4":
|
"@react-native-community/cli-clean@^8.0.4":
|
||||||
version "8.0.4"
|
version "8.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-8.0.4.tgz#97e16a20e207b95de12e29b03816e8f2b2c80cc7"
|
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-8.0.4.tgz#97e16a20e207b95de12e29b03816e8f2b2c80cc7"
|
||||||
|
|
Loading…
Reference in New Issue