diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 90fb912bb9..730b1b4252 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -82,7 +82,8 @@ :output-dir "target/test" :optimizations :simple :target :node-test - :ns-regexp "status-im.chat.models-test$" + ;; When running tests without a REPL you can uncomment the below line to `make test-watch` a specific file + ;:ns-regexp "status-im.chat.models-test$" :main status-im.test-runner/main ;; set :ui-driven to true to let shadow-cljs inject node-repl :ui-driven true diff --git a/src/status_im/chat/models/images.cljs b/src/status_im/chat/models/images.cljs index f0a2069872..98985c6aef 100644 --- a/src/status_im/chat/models/images.cljs +++ b/src/status_im/chat/models/images.cljs @@ -107,32 +107,10 @@ (-> (if end-cursor (.getPhotos CameraRoll #js {:first num :after end-cursor :assetType "Photos" :groupTypes "All"}) (.getPhotos CameraRoll #js {:first num :assetType "Photos" :groupTypes "All"})) - (.then #(re-frame/dispatch [:on-camera-roll-get-photos (:edges (types/js->clj %)) (:page_info (types/js->clj %)) end-cursor])) + (.then #(let [response (types/js->clj %)] + (re-frame/dispatch [:on-camera-roll-get-photos (:edges response) (:page_info response) end-cursor]))) (.catch #(log/warn "could not get camera roll photos"))))}))) -;(re-frame/reg-fx -; :camera-roll/get-photos -; (fn [{:keys [num end-cursor on-success on-failure]}] -; (-> (permissions/request-permissions -; {:permissions [:read-external-storage] -; :on-allowed (fn [] -; (-> (if end-cursor -; (.getPhotos CameraRoll #js {:first num -; :after end-cursor -; :assetType "Photos" -; :groupTypes "All"}) -; (.getPhotos CameraRoll #js {:first num -; :assetType "Photos" -; :groupTypes "All"}))))}) -; (.then (fn [^js js-result] -; (when on-success -; (let [result (types/js->clj js-result)] -; (re-frame/dispatch (conj on-success {:edges (:edges result) -; :page-info (:page_info result)})))))) -; (.catch (fn [error] -; (when on-failure -; (re-frame/dispatch (conj on-failure error)))) )))) - (fx/defn image-captured {:events [:chat.ui/image-captured]} [{:keys [db]} chat-id uri] @@ -150,17 +128,17 @@ (fx/defn camera-roll-loading-more {:events [:chat.ui/camera-roll-loading-more]} [{:keys [db]} is-loading] - {:db (assoc db :camera-roll-loading-more is-loading)}) + {:db (assoc db :camera-roll/loading-more is-loading)}) (fx/defn on-camera-roll-get-photos {:events [:on-camera-roll-get-photos]} [{:keys [db] :as cofx} photos page-info end-cursor] - (let [photos_x (when end-cursor (:camera-roll-photos db))] + (let [photos_x (when end-cursor (:camera-roll/photos db))] {:db (-> db - (assoc :camera-roll-photos (concat photos_x (map #(get-in % [:node :image :uri]) photos))) - (assoc :camera-roll-end-cursor (:end_cursor page-info)) - (assoc :camera-roll-has-next-page (:has_next_page page-info)) - (assoc :camera-roll-loading-more false))})) + (assoc :camera-roll/photos (concat photos_x (map #(get-in % [:node :image :uri]) photos))) + (assoc :camera-roll/end-cursor (:end_cursor page-info)) + (assoc :camera-roll/has-next-page (:has_next_page page-info)) + (assoc :camera-roll/loading-more false))})) (fx/defn clear-sending-images {:events [:chat.ui/clear-sending-images]} diff --git a/src/status_im/chat/models_test.cljs b/src/status_im/chat/models_test.cljs index 519997b83b..5bc72ec997 100644 --- a/src/status_im/chat/models_test.cljs +++ b/src/status_im/chat/models_test.cljs @@ -93,7 +93,7 @@ (let [res (chat/navigate-to-chat-nav2 {:db db} chat-id false)] (is (nil? (get-in res [:db :pagination-info chat-id :all-loaded?]))))))) -(deftest camera-roll-loading-more - (let [cofx {:db {:camera-roll-loading-more false}}] - (is (= {:db {:camera-roll-loading-more true}} +(deftest camera-roll-loading-more-test + (let [cofx {:db {:camera-roll/loading-more false}}] + (is (= {:db {:camera-roll/loading-more true}} (images/camera-roll-loading-more cofx true))))) diff --git a/src/status_im/ui/screens/chat/image/views.cljs b/src/status_im/ui/screens/chat/image/views.cljs index e747c7fb68..7e5febe102 100644 --- a/src/status_im/ui/screens/chat/image/views.cljs +++ b/src/status_im/ui/screens/chat/image/views.cljs @@ -80,7 +80,7 @@ [quo/radio {:value true}]])]])) (defview photos [] - (letsubs [camera-roll-photos [:camera-roll-photos] + (letsubs [camera-roll-photos [:camera-roll/photos] selected [:chats/sending-image] panel-height (reagent/atom nil)] [react/view {:style {:flex 1 diff --git a/src/status_im/ui/screens/status/new/views.cljs b/src/status_im/ui/screens/status/new/views.cljs index 30ea132533..2934b51aae 100644 --- a/src/status_im/ui/screens/status/new/views.cljs +++ b/src/status_im/ui/screens/status/new/views.cljs @@ -33,7 +33,7 @@ :source {:uri uri}}]]) (defview photos [] - (letsubs [camera-roll-photos [:camera-roll-photos]] + (letsubs [camera-roll-photos [:camera-roll/photos]] {:component-did-mount #(re-frame/dispatch [:chat.ui/camera-roll-get-photos 20])} [react/scroll-view {:horizontal true :style {:max-height 88} diff --git a/src/status_im/ui2/screens/chat/photo_selector/view.cljs b/src/status_im/ui2/screens/chat/photo_selector/view.cljs index e4d868b494..e5abda0830 100644 --- a/src/status_im/ui2/screens/chat/photo_selector/view.cljs +++ b/src/status_im/ui2/screens/chat/photo_selector/view.cljs @@ -55,8 +55,8 @@ [info-count/info-count (+ (utils/first-index #(= item %) @selected) 1) (style/image-count)])]) (defn on-end-reached [end-cursor] - (let [loading? (rf/sub [:camera-roll-loading-more]) - has-next-page? (rf/sub [:camera-roll-has-next-page])] + (let [loading? (rf/sub [:camera-roll/loading-more]) + has-next-page? (rf/sub [:camera-roll/has-next-page])] (when (and (not loading?) has-next-page?) (rf/dispatch [:chat.ui/camera-roll-loading-more true]) (rf/dispatch [:chat.ui/camera-roll-get-photos 20 end-cursor])))) @@ -67,8 +67,8 @@ (fn [] (let [{window-height :height window-width :width} (rn/use-window-dimensions) safe-area (safe-area/use-safe-area) - camera-roll-photos (rf/sub [:camera-roll-photos]) - end-cursor (rf/sub [:camera-roll-end-cursor])] + camera-roll-photos (rf/sub [:camera-roll/photos]) + end-cursor (rf/sub [:camera-roll/end-cursor])] [rn/view {:style {:height (- window-height (:top safe-area))}} [rn/touchable-opacity {:on-press #(js/alert "Camera: not implemented") diff --git a/src/status_im2/setup/dev.cljs b/src/status_im2/setup/dev.cljs index 14e181b00d..c8fbbc37cf 100644 --- a/src/status_im2/setup/dev.cljs +++ b/src/status_im2/setup/dev.cljs @@ -5,12 +5,12 @@ ["react-native" :refer (DevSettings LogBox)])) ;; Ignore all logs, because there are lots of temporary warnings when developing and hot reloading -;(.ignoreAllLogs LogBox) +(.ignoreAllLogs LogBox) ;; Only ignore warnings/errors that cannot be fixed for the time being. ;; When you add a warning to be ignored explain below why it is ignored and how it can be fixed. ;; When a warning is fixed make sure to remove it from here. -(.ignoreLogs ^js LogBox (clj->js ["undefined is not an object (evaluating 'e.message')" +#_(.ignoreLogs ^js LogBox (clj->js ["undefined is not an object (evaluating 'e.message')" "Cannot read property 'message' of undefined" "InternalError Metro has encountered an error" "undefined Unable to resolve module `parse-svg-path`" diff --git a/src/status_im2/subs/root.cljs b/src/status_im2/subs/root.cljs index ee5813ae51..c93498c534 100644 --- a/src/status_im2/subs/root.cljs +++ b/src/status_im2/subs/root.cljs @@ -99,10 +99,10 @@ (reg-root-key-sub :selected-participants :selected-participants) (reg-root-key-sub :chat/inputs :chat/inputs) (reg-root-key-sub :chat/memberships :chat/memberships) -(reg-root-key-sub :camera-roll-photos :camera-roll-photos) -(reg-root-key-sub :camera-roll-end-cursor :camera-roll-end-cursor) -(reg-root-key-sub :camera-roll-has-next-page :camera-roll-has-next-page) -(reg-root-key-sub :camera-roll-loading-more :camera-roll-loading-more) +(reg-root-key-sub :camera-roll/photos :camera-roll/photos) +(reg-root-key-sub :camera-roll/end-cursor :camera-roll/end-cursor) +(reg-root-key-sub :camera-roll/has-next-page :camera-roll/has-next-page) +(reg-root-key-sub :camera-roll/loading-more :camera-roll/loading-more) (reg-root-key-sub :group-chat/invitations :group-chat/invitations) (reg-root-key-sub :chats/mention-suggestions :chats/mention-suggestions) (reg-root-key-sub :chat/inputs-with-mentions :chat/inputs-with-mentions)