diff --git a/env/dev/env/android_test/main.cljs b/env/dev/env/android_test/main.cljs index 8599609053..062e01f015 100644 --- a/env/dev/env/android_test/main.cljs +++ b/env/dev/env/android_test/main.cljs @@ -17,5 +17,5 @@ :heads-up-display false :jsload-callback #(swap! cnt inc)) -(core/init :test) +(core/init) ;(init-stubs) diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index d668d863f2..b671f2ef3b 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -89,12 +89,12 @@ :check-status-change (u/side-effect! (fn [{:keys [current-account-id accounts]} [_ status]] - (let [{old-status :status :as account} (get accounts current-account-id) + (let [{old-status :status} (get accounts current-account-id) status-updated? (and (not= status nil) (not= status old-status))] (when status-updated? (let [hashtags (get-hashtags status)] - (when-not (empty? hashtags) + (when (seq hashtags) (dispatch [:broadcast-status status hashtags])))))))) (register-handler diff --git a/src/status_im/accounts/login/handlers.cljs b/src/status_im/accounts/login/handlers.cljs index 581bbe22c0..6175c3fa2a 100644 --- a/src/status_im/accounts/login/handlers.cljs +++ b/src/status_im/accounts/login/handlers.cljs @@ -34,7 +34,7 @@ (register-handler :change-account (u/side-effect! - (fn [db [_ address new-account? callback]] + (fn [_ [_ address new-account? callback]] (data-store/change-account address new-account? #(callback % address new-account?))))) diff --git a/src/status_im/accounts/recover/handlers.cljs b/src/status_im/accounts/recover/handlers.cljs index c98f70c8d0..d4cc7fd866 100644 --- a/src/status_im/accounts/recover/handlers.cljs +++ b/src/status_im/accounts/recover/handlers.cljs @@ -23,18 +23,17 @@ :updates-private-key private :signed-up? true}] (log/debug "account-recovered") - (when (not (str/blank? public-key)) - (do - (dispatch [:set-in [:recover :passphrase] ""]) - (dispatch [:set-in [:recover :password] ""]) - (dispatch [:add-account account]) - (dispatch [:navigate-back]))))) + (when-not (str/blank? public-key) + (dispatch [:set-in [:recover :passphrase] ""]) + (dispatch [:set-in [:recover :password] ""]) + (dispatch [:add-account account]) + (dispatch [:navigate-back])))) (defn recover-account [_ [_ passphrase password]] (status/recover-account passphrase password - (fn [result] (account-recovered result)))) + account-recovered)) (register-handler :recover-account (u/side-effect! recover-account)) diff --git a/src/status_im/accounts/screen.cljs b/src/status_im/accounts/screen.cljs index 5600b9c58e..bf765d262a 100644 --- a/src/status_im/accounts/screen.cljs +++ b/src/status_im/accounts/screen.cljs @@ -37,11 +37,7 @@ (defn render-row [row _ _] (list-item [account-view row])) -(defn render-separator [_ row-id _] - (list-item [view {:style st/row-separator - :key row-id}])) - -(defn create-account [event] +(defn create-account [_] (dispatch-sync [:reset-app]) ; add accounts screen to history ( maybe there is a better way ? ) (dispatch [:navigate-to-clean :accounts]) diff --git a/src/status_im/accounts/views/account.cljs b/src/status_im/accounts/views/account.cljs index dbe279ec89..fab60bff61 100644 --- a/src/status_im/accounts/views/account.cljs +++ b/src/status_im/accounts/views/account.cljs @@ -1,7 +1,6 @@ (ns status-im.accounts.views.account (:require-macros [status-im.utils.views :refer [defview]]) (:require [clojure.string :as s] - [status-im.resources :as res] [status-im.components.react :refer [view text image diff --git a/src/status_im/accounts/views/qr_code.cljs b/src/status_im/accounts/views/qr_code.cljs index c6bd278733..656a55170c 100644 --- a/src/status_im/accounts/views/qr_code.cljs +++ b/src/status_im/accounts/views/qr_code.cljs @@ -11,8 +11,7 @@ [re-frame.core :refer [dispatch subscribe]] [status-im.accounts.styles :as st] [status-im.i18n :refer [label]] - [clojure.string :as s] - [reagent.core :as r])) + [clojure.string :as s])) (defview qr-code-view [] [{:keys [photo-path address name] :as contact} [:get-in [:qr-modal :contact]] diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index 05d6af3f55..81dbb8dc1f 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -123,7 +123,7 @@ :contact-list-modal contact-list)] [component])]])]))))}))) -(defn init [& [env]] +(defn init [] (status/call-module status/init-jail) (dispatch-sync [:reset-app]) (.registerComponent app-registry "StatusIm" #(r/reactify-component app-root)) diff --git a/src/status_im/android/platform.cljs b/src/status_im/android/platform.cljs index 94601fd2e7..202be5d98b 100644 --- a/src/status_im/android/platform.cljs +++ b/src/status_im/android/platform.cljs @@ -1,6 +1,5 @@ (ns status-im.android.platform (:require [status-im.components.styles :as styles] - [status-im.utils.utils :as u] [status-im.components.toolbar.styles :refer [toolbar-background2]])) (def component-styles diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index a4df2c3b46..2f6c0561b2 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -95,7 +95,7 @@ (register-handler :start-cancel-command (after #(dispatch [:set-soft-input-mode :resize])) (u/side-effect! - (fn [db _] + (fn [] (dispatch [:animate-cancel-command]) (dispatch [:cancel-command])))) @@ -254,7 +254,7 @@ (register-handler :account-generation-message (u/side-effect! (fn [_] - (when (not (messages/get-by-id sign-up-service/passphraze-message-id)) + (when-not (messages/get-by-id sign-up-service/passphraze-message-id) (sign-up-service/account-generation-message))))) (register-handler :show-mnemonic @@ -326,10 +326,9 @@ chats (->> loaded-chats (map (fn [{:keys [chat-id] :as chat}] - (let [last-message (messages/get-last-message db chat-id)] + (let [last-message (messages/get-last-message chat-id)] [chat-id (assoc chat :last-message last-message)]))) - (into (priority-map-by compare-chats)))) - ids (set (keys chats'))] + (into (priority-map-by compare-chats))))] (-> db (assoc :chats chats') @@ -450,12 +449,12 @@ (chats/save chat'))) (register-handler :update-chat! - (-> (fn [db [_ {:keys [chat-id name] :as chat}]] - (let [chat' (if name chat (dissoc chat :name))] - (if (get-in db [:chats chat-id]) - (update-in db [:chats chat-id] merge chat') - db))) - ((after update-chat!)))) + (after update-chat!) + (fn [db [_ {:keys [chat-id name] :as chat}]] + (let [chat' (if name chat (dissoc chat :name))] + (if (get-in db [:chats chat-id]) + (update-in db [:chats chat-id] merge chat') + db)))) (register-handler :upsert-chat! (fn [db [_ {:keys [chat-id] :as opts}]] @@ -571,7 +570,7 @@ (u/side-effect! send-seen!)) (defn send-clock-value-request! - [{:keys [web3 current-public-key]} [_ {:keys [message-id from] :as message}]] + [{:keys [web3 current-public-key]} [_ {:keys [message-id from]}]] (protocol/send-clock-value-request! {:web3 web3 :message {:from current-public-key :to from @@ -593,7 +592,7 @@ (let [clock-value (+ last-clock-value i 1)] (messages/update (assoc message :clock-value clock-value)) (send-clock-value! db to message-id clock-value)))) - (fn [db [_ _ i {:keys [message-id] :as message} last-clock-value]] + (fn [db [_ _ i {:keys [message-id]} last-clock-value]] (assoc-in db [:message-extras message-id :clock-value] (+ last-clock-value i 1)))) (register-handler :send-clock-value! diff --git a/src/status_im/chat/handlers/animation.cljs b/src/status_im/chat/handlers/animation.cljs index a6d6bf206d..17b1d9f885 100644 --- a/src/status_im/chat/handlers/animation.cljs +++ b/src/status_im/chat/handlers/animation.cljs @@ -6,8 +6,7 @@ minimum-command-suggestions-height response-height-normal minimum-suggestion-height]] [status-im.utils.platform :refer [platform-specific]] - [status-im.constants :refer [response-input-hiding-duration]] - [taoensso.timbre :as log])) + [status-im.constants :refer [response-input-hiding-duration]])) ;; todo magic value (def middle-height 270) diff --git a/src/status_im/chat/handlers/console.cljs b/src/status_im/chat/handlers/console.cljs index b17282beb1..858ffba427 100644 --- a/src/status_im/chat/handlers/console.cljs +++ b/src/status_im/chat/handlers/console.cljs @@ -47,15 +47,13 @@ (register-handler :console-respond-command (u/side-effect! - (fn [_ [_ {:keys [command] :as parameters}]] + (fn [_ [_ {:keys [command]}]] (let [{:keys [command handler-data]} command] (when command (let [{:keys [name]} command] (case name "js" (let [{:keys [err data messages]} handler-data - content (if err - err - data)] + content (or err data)] (doseq [message messages] (let [{:keys [message type]} message] (dispatch [:received-message diff --git a/src/status_im/chat/handlers/faucet.cljs b/src/status_im/chat/handlers/faucet.cljs index f5a45f2930..8e36a1192e 100644 --- a/src/status_im/chat/handlers/faucet.cljs +++ b/src/status_im/chat/handlers/faucet.cljs @@ -6,7 +6,6 @@ [status-im.constants :refer [console-chat-id text-content-type]] [status-im.i18n :refer [label]] - [taoensso.timbre :as log] [goog.string :as gstring] goog.string.format)) @@ -36,7 +35,7 @@ (defmulti open-faucet (fn [_ _ {:keys [type]}] type)) (defmethod open-faucet :api - [faucet-name current-address {:keys [api-url]}] + [_ current-address {:keys [api-url]}] (let [api-url (gstring/format api-url current-address)] (http-get api-url #(received-message (label :t/faucet-success)) diff --git a/src/status_im/chat/handlers/receive_message.cljs b/src/status_im/chat/handlers/receive_message.cljs index b45b680573..a33f39fbd5 100644 --- a/src/status_im/chat/handlers/receive_message.cljs +++ b/src/status_im/chat/handlers/receive_message.cljs @@ -11,7 +11,6 @@ :as c] [cljs.reader :refer [read-string]] [status-im.data-store.chats :as chats] - [taoensso.timbre :as log] [status-im.utils.scheduler :as s])) (defn check-preview [{:keys [content] :as message}] @@ -42,14 +41,14 @@ exists? (chats/exists? chat-id') active? (chats/is-active? chat-id') chat-clock-value (messages/get-last-clock-value chat-id') - clock-value (if (= clock-value 0) + clock-value (if (zero? clock-value) (inc chat-clock-value) clock-value)] (when (and (not same-message) (not= from current-identity) (or (not exists?) active?)) (let [group-chat? (not (nil? group-id)) - previous-message (messages/get-last-message db chat-id') + previous-message (messages/get-last-message chat-id') message' (assoc (->> message (cu/check-author-direction previous-message) (check-preview)) diff --git a/src/status_im/chat/handlers/requests.cljs b/src/status_im/chat/handlers/requests.cljs index 6aa15d962b..7669d36ebb 100644 --- a/src/status_im/chat/handlers/requests.cljs +++ b/src/status_im/chat/handlers/requests.cljs @@ -6,7 +6,7 @@ [taoensso.timbre :as log])) (defn store-request! - [{:keys [new-request] :as db}] + [{:keys [new-request]}] (requests/save new-request)) (defn add-request diff --git a/src/status_im/chat/handlers/send_message.cljs b/src/status_im/chat/handlers/send_message.cljs index b6ae06431a..63652b9eae 100644 --- a/src/status_im/chat/handlers/send_message.cljs +++ b/src/status_im/chat/handlers/send_message.cljs @@ -1,14 +1,12 @@ (ns status-im.chat.handlers.send-message (:require [status-im.utils.handlers :refer [register-handler] :as u] [clojure.string :as s] - [status-im.data-store.chats :as chats] [status-im.data-store.messages :as messages] [status-im.components.status :as status] [status-im.utils.random :as random] [status-im.utils.datetime :as time] [re-frame.core :refer [enrich after dispatch path]] [status-im.chat.utils :as cu] - [status-im.commands.utils :as commands-utils] [status-im.constants :refer [console-chat-id wallet-chat-id text-content-type @@ -212,7 +210,7 @@ (register-handler ::send-dapp-message (u/side-effect! - (fn [db [_ chat-id {:keys [content] :as message}]] + (fn [db [_ chat-id {:keys [content]}]] (let [data (get-in db [:local-storage chat-id]) path [:functions :message-handler] @@ -228,11 +226,9 @@ (register-handler ::received-dapp-message (u/side-effect! - (fn [{:keys [current-chat-id] :as db} [_ chat-id {:keys [returned] :as message}]] + (fn [_ [_ chat-id {:keys [returned]}]] (let [{:keys [data messages err]} returned - content (if err - err - data)] + content (or err data)] (doseq [message messages] (let [{:keys [message type]} message] (dispatch [:received-message @@ -259,7 +255,7 @@ :as db} [_ {{:keys [message-type] :as message} :message chat-id :chat-id}]] - (let [{:keys [dapp?] :as contact} (get-in db [:contacts chat-id])] + (let [{:keys [dapp?]} (get-in db [:contacts chat-id])] (if dapp? (dispatch [::send-dapp-message chat-id message]) (when message diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 97961baa86..cb3d6b064b 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -31,8 +31,7 @@ [status-im.i18n :refer [label label-pluralize]] [status-im.components.animation :as anim] [status-im.components.sync-state.offline :refer [offline-view]] - [status-im.constants :refer [content-type-status]] - [reagent.core :as r])) + [status-im.constants :refer [content-type-status]])) (defn contacts-by-identity [contacts] (->> contacts @@ -120,7 +119,7 @@ [add-contact-bar]]) (defn get-intro-status-message [all-messages] - (let [{:keys [timestamp content-type] :as last-message} (last all-messages)] + (let [{:keys [timestamp content-type]} (last all-messages)] (when (not= content-type content-type-status) {:message-id "intro-status" :content-type content-type-status diff --git a/src/status_im/chat/sign_up.cljs b/src/status_im/chat/sign_up.cljs index 960f189c94..344d5f2f15 100644 --- a/src/status_im/chat/sign_up.cljs +++ b/src/status_im/chat/sign_up.cljs @@ -47,7 +47,7 @@ (dispatch [:sign-up-confirm (second matches)]))) (defn start-listening-confirmation-code-sms [db] - (if (not (:confirmation-code-sms-listener db)) + (if-not (:confirmation-code-sms-listener db) (assoc db :confirmation-code-sms-listener (add-sms-listener handle-sms)) db)) @@ -83,11 +83,10 @@ :to "me"}]) (let [status (keyword (:status body))] (when (= :confirmed status) - (do - (dispatch [:stop-listening-confirmation-code-sms]) - (sync-contacts) - ;; TODO should be called after sync-contacts? - (dispatch [:set-signed-up true]))) + (dispatch [:stop-listening-confirmation-code-sms]) + (sync-contacts) + ;; TODO should be called after sync-contacts? + (dispatch [:set-signed-up true])) (when (= :failed status) (on-sign-up-response (label :t/incorrect-code))))) diff --git a/src/status_im/chat/styles/command_validation.cljs b/src/status_im/chat/styles/command_validation.cljs index 341d243f55..15b4cf1dfb 100644 --- a/src/status_im/chat/styles/command_validation.cljs +++ b/src/status_im/chat/styles/command_validation.cljs @@ -1,6 +1,5 @@ (ns status-im.chat.styles.command-validation - (:require [status-im.components.styles :as st] - [status-im.chat.constants :as constants])) + (:require [status-im.chat.constants :as constants])) (def messages-container {:background-color :#d50000 diff --git a/src/status_im/chat/styles/emoji.cljs b/src/status_im/chat/styles/emoji.cljs index 0c17d7236b..7c7d55c0ad 100644 --- a/src/status_im/chat/styles/emoji.cljs +++ b/src/status_im/chat/styles/emoji.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.styles.emoji (:require [status-im.components.styles :refer [color-white]] - [status-im.chat.constants :refer [emoji-container-height]] - [taoensso.timbre :as log])) + [status-im.chat.constants :refer [emoji-container-height]])) (def container-height emoji-container-height) diff --git a/src/status_im/chat/styles/message.cljs b/src/status_im/chat/styles/message.cljs index 9823cc765c..75339a514e 100644 --- a/src/status_im/chat/styles/message.cljs +++ b/src/status_im/chat/styles/message.cljs @@ -7,7 +7,6 @@ online-color text1-color text2-color]] - [status-im.utils.platform :as p] [status-im.constants :refer [text-content-type content-type-command]])) diff --git a/src/status_im/chat/styles/message_input.cljs b/src/status_im/chat/styles/message_input.cljs index 711480f515..de79cacc34 100644 --- a/src/status_im/chat/styles/message_input.cljs +++ b/src/status_im/chat/styles/message_input.cljs @@ -4,8 +4,7 @@ [status-im.chat.constants :refer [max-input-height min-input-height input-spacing-top - input-spacing-bottom]] - [status-im.utils.platform :as p])) + input-spacing-bottom]])) (def input-container {:flex-direction :column}) @@ -46,4 +45,4 @@ {:margin-top 10.5 :margin-left 12 :width 15 - :height 15}) \ No newline at end of file + :height 15}) diff --git a/src/status_im/chat/styles/plain_message.cljs b/src/status_im/chat/styles/plain_message.cljs index 4d44152937..cf4a26b090 100644 --- a/src/status_im/chat/styles/plain_message.cljs +++ b/src/status_im/chat/styles/plain_message.cljs @@ -1,10 +1,9 @@ (ns status-im.chat.styles.plain-message (:require [status-im.components.styles :refer [text1-color]] [status-im.chat.constants :refer [max-input-height - min-input-height]] - [status-im.utils.platform :as p])) + min-input-height]])) -(defn message-input-button-touchable [width content-height] +(defn message-input-button-touchable [width] {:width width :flex 1}) diff --git a/src/status_im/chat/styles/response.cljs b/src/status_im/chat/styles/response.cljs index 453bc43589..73e9b0ba3c 100644 --- a/src/status_im/chat/styles/response.cljs +++ b/src/status_im/chat/styles/response.cljs @@ -7,8 +7,7 @@ color-black]] [status-im.chat.constants :refer [input-height request-info-height - response-height-normal]] - [status-im.utils.platform :as p])) + response-height-normal]])) (def drag-container {:height 16 diff --git a/src/status_im/chat/styles/suggestions.cljs b/src/status_im/chat/styles/suggestions.cljs index 1f8c9d01df..ac7dc1e1f5 100644 --- a/src/status_im/chat/styles/suggestions.cljs +++ b/src/status_im/chat/styles/suggestions.cljs @@ -10,8 +10,7 @@ separator-color text1-color text2-color - text3-color]] - [taoensso.timbre :as log])) + text3-color]])) (def suggestion-height 60) diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index 24e97eafe9..45fbd2881f 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.subs (:require-macros [reagent.ratom :refer [reaction]]) (:require [re-frame.core :refer [register-sub dispatch subscribe path]] - [status-im.utils.platform :refer [ios?]] [status-im.models.commands :as commands] [status-im.data-store.chats :as chats] [status-im.constants :refer [response-suggesstion-resize-duration]] @@ -9,7 +8,7 @@ [status-im.chat.views.plain-message :as plain-message] [status-im.chat.views.command :as command] [status-im.constants :refer [content-type-status]] - [status-im.utils.platform :refer [platform-specific]])) + [status-im.utils.platform :refer [platform-specific ios?]])) (register-sub :chat-properties (fn [db [_ properties]] @@ -185,7 +184,7 @@ (register-sub :is-request-answered? (fn [_ [_ message-id]] (let [requests (subscribe [:get-requests])] - (reaction (not (some #(= message-id (:message-id %)) @requests)))))) + (reaction (not-any? #(= message-id (:message-id %)) @requests))))) (register-sub :validation-errors (fn [db] @@ -212,7 +211,7 @@ (let [chat-id (subscribe [:get-current-chat-id])] (reaction (min (get-in @db [:animations :to-response-height @chat-id]) - (if (> (:layout-height @db) 0) + (if (pos? (:layout-height @db)) (- (:layout-height @db) (get-in platform-specific [:component-styles :status-bar status-bar :height])) 0)))))) @@ -251,7 +250,7 @@ :else 0))))) (register-sub :max-layout-height - (fn [db [_ status-bar]] + (fn [_ [_ status-bar]] (let [layout-height (subscribe [:get :layout-height]) input-margin (subscribe [:input-margin]) status-bar-height (get-in platform-specific [:component-styles :status-bar status-bar :height])] diff --git a/src/status_im/chat/suggestions.cljs b/src/status_im/chat/suggestions.cljs index 4702e55564..15e5585625 100644 --- a/src/status_im/chat/suggestions.cljs +++ b/src/status_im/chat/suggestions.cljs @@ -1,6 +1,5 @@ (ns status-im.chat.suggestions (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] - [status-im.db :as db] [status-im.chat.constants :as chat-consts] [status-im.models.commands :refer [get-commands get-chat-command-request diff --git a/src/status_im/chat/suggestions_responder.cljs b/src/status_im/chat/suggestions_responder.cljs index 6d760c155a..c3b844fbfc 100644 --- a/src/status_im/chat/suggestions_responder.cljs +++ b/src/status_im/chat/suggestions_responder.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.suggestions-responder (:require [status-im.components.drag-drop :as drag] [status-im.components.animation :as anim] - [status-im.components.react :as react] [re-frame.core :refer [dispatch]])) ;; todo bad name. Ideas? diff --git a/src/status_im/chat/utils.cljs b/src/status_im/chat/utils.cljs index 54e7be2c32..6440e432d4 100644 --- a/src/status_im/chat/utils.cljs +++ b/src/status_im/chat/utils.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.utils (:require [status-im.constants :refer [console-chat-id - wallet-chat-id]] - [taoensso.timbre :as log])) + wallet-chat-id]])) (defn console? [s] (= console-chat-id s)) diff --git a/src/status_im/chat/views/actions.cljs b/src/status_im/chat/views/actions.cljs index 7e4ecd6664..a7907a68ca 100644 --- a/src/status_im/chat/views/actions.cljs +++ b/src/status_im/chat/views/actions.cljs @@ -23,7 +23,7 @@ [chat-icon-view-menu-item chat-id group-chat name color true]) (defn- members-text [members] - (str (s/join ", " (map #(:name %) members)) + (str (s/join ", " (map :name members)) " " (label :t/and-you))) @@ -121,8 +121,9 @@ (when-let [actions (if @group-chat (group-chat-items @members) (user-chat-items @chat-id))] - [view (-> (st/actions-wrapper status-bar-height) - (merge (get-in platform-specific [:component-styles :actions-list-view]))) + [view (merge + (st/actions-wrapper status-bar-height) + (get-in platform-specific [:component-styles :actions-list-view])) [view st/actions-separator] [view st/actions-view (for [action actions] diff --git a/src/status_im/chat/views/emoji.cljs b/src/status_im/chat/views/emoji.cljs index fb7b07c752..1388cd79b1 100644 --- a/src/status_im/chat/views/emoji.cljs +++ b/src/status_im/chat/views/emoji.cljs @@ -1,15 +1,11 @@ (ns status-im.chat.views.emoji (:require-macros [status-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch]] - [reagent.core :as r] [status-im.components.react :refer [view text icon emoji-picker]] [status-im.chat.styles.emoji :as st] - [status-im.components.animation :as anim] - [status-im.chat.suggestions-responder :as resp] - [status-im.chat.constants :as c] [status-im.i18n :refer [label]])) (defview emoji-view [] diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index b073cffebc..40e29ca4fb 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -20,7 +20,6 @@ [status-im.models.commands :refer [parse-command-message-content parse-command-request]] [status-im.resources :as res] - [status-im.utils.datetime :as time] [status-im.constants :refer [console-chat-id wallet-chat-id text-content-type @@ -34,8 +33,7 @@ get-contact-translated]] [status-im.chat.utils :as cu] [clojure.string :as str] - [status-im.chat.handlers.console :as console] - [taoensso.timbre :as log])) + [status-im.chat.handlers.console :as console])) (def window-width (:width (get-dimensions "window"))) @@ -43,9 +41,7 @@ (let [{:keys [chat-id group-chat name color]} (subscribe [:chat-properties [:chat-id :group-chat :name :color]]) members (subscribe [:current-chat-contacts])] (fn [{:keys [messages-count content datemark]}] - (let [{:keys [photo-path - status - last-online]} (if @group-chat + (let [{:keys [status]} (if @group-chat {:photo-path nil :status nil :last-online 0} @@ -189,7 +185,7 @@ [text {:key (str idx "_" string) :style style} - (subs string 1 (- (count string) 1))])) + (subs string 1 (dec (count string)))])) (re-seq regx string))) styled-text' (if (> (count general-text) (count styled-text)) @@ -335,7 +331,7 @@ (defn message-container-animation-logic [{:keys [to-value val callback]}] (fn [_] (let [to-value @to-value] - (when (< 0 to-value) + (when (pos? to-value) (anim/start (anim/timing val {:toValue to-value :duration 250}) @@ -356,7 +352,7 @@ {:component-did-update on-update :reagent-render - (fn [message & children] + (fn [_ & children] @layout-height [animated-view {:style (st/message-animated-container anim-value)} (into [view {:style (st/message-container window-width) @@ -379,7 +375,7 @@ :from from :message-id message-id}]))) :reagent-render - (fn [{:keys [outgoing group-chat clock-value] :as message}] + (fn [{:keys [outgoing group-chat] :as message}] [message-container message [view (let [incoming-group (and group-chat (not outgoing))] diff --git a/src/status_im/chat/views/message_input.cljs b/src/status_im/chat/views/message_input.cljs index 49ad30f116..74ab74cd59 100644 --- a/src/status_im/chat/views/message_input.cljs +++ b/src/status_im/chat/views/message_input.cljs @@ -28,14 +28,10 @@ :editable (not disable?) :on-submit-editing plain-message/send}) -(defn on-press-commands-handler - [{:keys [suggestions-trigger]}] - #(dispatch [:send-command!])) - -(defn command-input-options [command icon-width disable?] +(defn command-input-options [icon-width disable?] {:style (st-response/command-input icon-width disable?) :on-change-text (when-not disable? command/set-input-message) - :on-submit-editing (on-press-commands-handler command)}) + :on-submit-editing #(dispatch [:send-command!])}) (defview message-input [input-options set-layout-size] [input-message [:get-chat-input-text] @@ -59,12 +55,12 @@ :default-value (or input-message "")} input-options)]) -(defview command-input [input-options {:keys [fullscreen] :as command}] +(defview command-input [input-options {:keys [fullscreen]}] [input-command [:get-chat-command-content] icon-width [:command-icon-width] disable? [:get :disable-input]] [text-input (merge - (command-input-options command icon-width disable?) + (command-input-options icon-width disable?) {:auto-focus (not fullscreen) :blur-on-submit false :accessibility-label :input @@ -106,7 +102,7 @@ (when (or (and @command? (not (str/blank? @input-command))) @valid-plain-message?) (let [on-press (if @command? - (on-press-commands-handler @command) + #(dispatch [:send-command!]) plain-message/send)] [send-button {:on-press #(do (dispatch [:set-chat-ui-props :show-emoji? false]) (on-press %))}])) diff --git a/src/status_im/chat/views/new_message.cljs b/src/status_im/chat/views/new_message.cljs index 2b17865be2..71ddf6c7a1 100644 --- a/src/status_im/chat/views/new_message.cljs +++ b/src/status_im/chat/views/new_message.cljs @@ -7,8 +7,7 @@ [status-im.chat.views.message-input :refer [plain-message-input-view]] [status-im.chat.constants :refer [input-height]] [status-im.utils.platform :refer [platform-specific]] - [status-im.chat.styles.message :as st] - [taoensso.timbre :as log])) + [status-im.chat.styles.message :as st])) (defn get-height [event] (.-height (.-layout (.-nativeEvent event)))) @@ -34,8 +33,7 @@ type [:command-type] suggestions [:get-suggestions] message-input-height [:get-message-input-view-height]] - (let [on-top? (or (and (not (empty? suggestions)) - (not command?)) + (let [on-top? (or (and (seq suggestions) (not command?)) (not= response-height input-height)) style (get-in platform-specific [:component-styles :chat :new-message])] [view {:style (merge (st/new-message-container margin on-top?) style) diff --git a/src/status_im/chat/views/plain_message.cljs b/src/status_im/chat/views/plain_message.cljs index d744fce3eb..d8f9628786 100644 --- a/src/status_im/chat/views/plain_message.cljs +++ b/src/status_im/chat/views/plain_message.cljs @@ -38,7 +38,7 @@ :delay delay}) #(dispatch [:set :disable-input false]))))) -(defn commands-button [height on-press] +(defn commands-button [_ _] (let [command? (subscribe [:command?]) requests (subscribe [:get-requests]) suggestions (subscribe [:get-suggestions]) @@ -61,7 +61,7 @@ (dispatch [:switch-command-suggestions!]) (on-press)) :disabled @command?} - [animated-view {:style (st/message-input-button-touchable container-width height)} + [animated-view {:style (st/message-input-button-touchable container-width)} (when-not @command? [animated-view {:style (st/message-input-button buttons-scale @@ -84,7 +84,7 @@ (when (and @command? (.-finished e)) (anim/set-value width 0.1))))))) -(defn smile-button [height] +(defn smile-button [_] (let [command? (subscribe [:command?]) buttons-scale (anim/create-value (if @command? 1 0)) container-width (anim/create-value (if @command? 0.1 56)) @@ -102,6 +102,6 @@ [touchable-highlight {:on-press #(do (dispatch [:toggle-chat-ui-props :show-emoji?]) (dismiss-keyboard!)) :disabled @command?} - [animated-view {:style (st/message-input-button-touchable container-width height)} + [animated-view {:style (st/message-input-button-touchable container-width)} [animated-view {:style (st/message-input-button buttons-scale 16)} [icon :smile st/smile-icon]]]])}))) diff --git a/src/status_im/chat/views/request_message.cljs b/src/status_im/chat/views/request_message.cljs index 77acdd7b43..4e9f7be246 100644 --- a/src/status_im/chat/views/request_message.cljs +++ b/src/status_im/chat/views/request_message.cljs @@ -20,7 +20,8 @@ (defn label [command] (when command - (->> (name (:name command)) + (->> (:name command) + name (str "request-")))) (def min-scale 1) @@ -45,7 +46,7 @@ (anim/start (button-animation val min-scale loop? answered?))))) -(defn request-button [message-id command status-initialized? top-offset?] +(defn request-button [message-id _ _ top-offset?] (let [scale-anim-val (anim/create-value min-scale) answered? (subscribe [:is-request-answered? message-id]) loop? (r/atom true) @@ -71,7 +72,7 @@ [icon command-icon st/command-request-image])]]))}))) (defn message-content-command-request - [{:keys [message-id content from incoming-group]}] + [{:keys [message-id _ _ _]}] (let [top-offset (r/atom {:specified? false}) commands-atom (subscribe [:get-responses]) answered? (subscribe [:is-request-answered? message-id]) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 3ae0a3f7ad..c6b09d141d 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -22,7 +22,6 @@ [status-im.components.webview-bridge :refer [webview-bridge]] [status-im.i18n :refer [label]] [status-im.utils.datetime :as dt] - [taoensso.timbre :as log] [status-im.utils.name :refer [shortened-name]] [status-im.utils.js-resources :as js-res] [status-im.commands.utils :as cu])) @@ -62,7 +61,7 @@ layout-height :fix-response-height) command (subscribe [:get-chat-command])] - (fn [response-height] + (fn [_] (if (= :response (:type @command)) [view (merge (drag/pan-handlers pan-responder) {:style (st/request-info (:color @command))}) @@ -87,7 +86,7 @@ :duration 300})) (anim/set-value val to-value)))))) -(defn container [response-height & children] +(defn container [response-height & _] (let [;; todo to-response-height, cur-response-height must be specific ;; for each chat to-response-height (subscribe [:response-height :default]) diff --git a/src/status_im/chat/views/suggestions.cljs b/src/status_im/chat/views/suggestions.cljs index b055b8a985..007a13bd3f 100644 --- a/src/status_im/chat/views/suggestions.cljs +++ b/src/status_im/chat/views/suggestions.cljs @@ -1,6 +1,5 @@ (ns status-im.chat.views.suggestions - (:require-macros [status-im.utils.views :refer [defview]] - [clojure.string :as str]) + (:require-macros [status-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch]] [status-im.components.react :refer [view scroll-view @@ -102,7 +101,7 @@ (anim/start (anim/spring val {:toValue to-value})) (anim/set-value val to-value)))))) -(defn container [h & elements] +(defn container [h & _] (let [;; todo to-response-height, cur-response-height must be specific ;; for each chat to-response-height (subscribe [:command-suggestions-height]) diff --git a/src/status_im/chat/views/toolbar_content.cljs b/src/status_im/chat/views/toolbar_content.cljs index bcabd4ea8d..312d67ec0e 100644 --- a/src/status_im/chat/views/toolbar_content.cljs +++ b/src/status_im/chat/views/toolbar_content.cljs @@ -22,7 +22,7 @@ contact (let [last-online (get contact :last-online) last-online-date (time/to-date last-online) now-date (t/now)] - (if (and (> last-online 0) + (if (and (pos? last-online) (<= last-online-date now-date)) (time/time-ago last-online-date) (label :t/active-unknown))) diff --git a/src/status_im/chats_list/views/chat_list_item.cljs b/src/status_im/chats_list/views/chat_list_item.cljs index d2a5fff6e8..3d92393808 100644 --- a/src/status_im/chats_list/views/chat_list_item.cljs +++ b/src/status_im/chats_list/views/chat_list_item.cljs @@ -4,8 +4,7 @@ text image touchable-highlight]] - [status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]] - [taoensso.timbre :as log])) + [status-im.chats-list.views.inner-item :refer [chat-list-item-inner-view]])) (defn chat-list-item [[chat-id chat]] [touchable-highlight {:on-press #(dispatch [:navigate-to :chat chat-id])} diff --git a/src/status_im/chats_list/views/inner_item.cljs b/src/status_im/chats_list/views/inner_item.cljs index 70ab294202..19f66d437b 100644 --- a/src/status_im/chats_list/views/inner_item.cljs +++ b/src/status_im/chats_list/views/inner_item.cljs @@ -12,10 +12,9 @@ [status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.constants :refer [console-chat-id content-type-command - content-type-command-request] :as c] - [taoensso.timbre :as log])) + content-type-command-request] :as c])) -(defmulti message-content (fn [{:keys [content-type] :as message}] content-type)) +(defmulti message-content (fn [{:keys [content-type]}] content-type)) (defn command-content [{{:keys [command params]} :content}] diff --git a/src/status_im/commands/handlers/jail.cljs b/src/status_im/commands/handlers/jail.cljs index 151012900f..6ce7a405be 100644 --- a/src/status_im/commands/handlers/jail.cljs +++ b/src/status_im/commands/handlers/jail.cljs @@ -2,7 +2,6 @@ (:require [re-frame.core :refer [after dispatch subscribe trim-v debug]] [status-im.utils.handlers :as u] [status-im.utils.utils :refer [http-get show-popup]] - [status-im.components.status :as status] [status-im.utils.types :refer [json->clj]] [status-im.commands.utils :refer [generate-hiccup reg-handler]] [clojure.string :as s] @@ -58,7 +57,7 @@ (defn suggestions-events-handler! [{:keys [current-chat-id] :as db} [[n data]]] (log/debug "Suggestion event: " data) - (let [{:keys [dapp?] :as contact} (get-in db [:contacts current-chat-id]) + (let [{:keys [dapp?]} (get-in db [:contacts current-chat-id]) command? (= :command (:type (cm/get-chat-command db)))] (case (keyword n) :set-value (if command? diff --git a/src/status_im/commands/handlers/loading.cljs b/src/status_im/commands/handlers/loading.cljs index 17179b3cb7..18f1d146e7 100644 --- a/src/status_im/commands/handlers/loading.cljs +++ b/src/status_im/commands/handlers/loading.cljs @@ -10,8 +10,7 @@ [status-im.constants :refer [console-chat-id wallet-chat-id]] [taoensso.timbre :as log] [status-im.utils.homoglyph :as h] - [status-im.utils.js-resources :as js-res] - [clojure.string :as str])) + [status-im.utils.js-resources :as js-res])) (def commands-js "commands.js") @@ -28,7 +27,7 @@ (dispatch [::fetch-commands! identity]))) (defn fetch-commands! - [db [{:keys [whisper-identity dapp? dapp-url]}]] + [_ [{:keys [whisper-identity dapp? dapp-url]}]] (when true ;-let [url (get-in db [:chats identity :dapp-url])] (cond @@ -94,7 +93,7 @@ registered-only))) (remove (fn [[n]] (and - (not (= console-chat-id id)) + (not= console-chat-id id) (h/matches (name n) "password")))) (into {}))) @@ -169,12 +168,12 @@ (u/side-effect! (fn [{:keys [chats]}] (doseq [[id {:keys [name photo-path public-key add-chat? - dapp? dapp-url dapp-hash] :as contact}] js-res/default-contacts] - (let [id (clojure.core/name id)] - (when-not (chats id) + dapp? dapp-url dapp-hash]}] js-res/default-contacts] + (let [id' (clojure.core/name id)] + (when-not (chats id') (when add-chat? - (dispatch [:add-chat id {:name (:en name)}])) - (dispatch [:add-contacts [{:whisper-identity id + (dispatch [:add-chat id' {:name (:en name)}])) + (dispatch [:add-contacts [{:whisper-identity id' :name (:en name) :photo-path photo-path :public-key public-key diff --git a/src/status_im/components/carousel/carousel.cljs b/src/status_im/components/carousel/carousel.cljs index 5d6681d1b0..bef7f195d5 100644 --- a/src/status_im/components/carousel/carousel.cljs +++ b/src/status_im/components/carousel/carousel.cljs @@ -129,12 +129,6 @@ (when (pos? initial-page) (go-to-page component initial-page)))) -(defn component-will-update [component new-argv] - (log/debug "component-will-update: ")) - -(defn component-did-update [component old-argv] - (log/debug "component-did-update")) - (defn component-will-receive-props [component new-argv] (let [props (rc/extract-props new-argv)] (log/debug "component-will-receive-props: props=" props) @@ -163,7 +157,6 @@ (let [page-width (get-page-width data) page-style (get-page-style data) gap (get-gap data) - sneak (get-sneak data) count (get-count data)] (doall (map-indexed (fn [index child] (let [page-index index @@ -180,11 +173,10 @@ (let [starting-position (atom 0) component (reagent.core/current-component) state (reagent.core/state component) - sneak (get-sneak state) gap (get-gap state)] (log/debug "reagent-render: " data state) [view {:style st/scroll-view-container} - [scroll-view {:contentContainerStyle (st/content-container sneak gap) + [scroll-view {:contentContainerStyle (st/content-container gap) :automaticallyAdjustContentInsets false :bounces false :decelerationRate 0.9 @@ -197,12 +189,10 @@ :ref #(set! (.-scrollView component) %)} (get-pages component state children)]])) -(defn carousel [data children] +(defn carousel [_ _] (let [component-data {:component-did-mount component-did-mount :component-will-mount component-will-mount :component-will-receive-props component-will-receive-props - :component-will-update component-will-update - :component-did-update component-did-update :display-name "carousel" :reagent-render reagent-render}] (reagent.core/create-class component-data))) diff --git a/src/status_im/components/carousel/styles.cljs b/src/status_im/components/carousel/styles.cljs index 4c4e84cabd..81d80efeac 100644 --- a/src/status_im/components/carousel/styles.cljs +++ b/src/status_im/components/carousel/styles.cljs @@ -3,7 +3,7 @@ (def scroll-view-container {:flex 1}) -(defn content-container [sneak gap] +(defn content-container [gap] {:paddingLeft (quot gap 2) :paddingRight (quot gap 2)}) diff --git a/src/status_im/components/chat_icon/screen.cljs b/src/status_im/components/chat_icon/screen.cljs index 8e4797da40..dc79e7c218 100644 --- a/src/status_im/components/chat_icon/screen.cljs +++ b/src/status_im/components/chat_icon/screen.cljs @@ -5,7 +5,6 @@ text image icon]] - [taoensso.timbre :as log] [status-im.components.icons.custom-icons :refer [oct-icon]] [status-im.components.chat-icon.styles :as st] [status-im.components.styles :refer [default-chat-color]] @@ -159,18 +158,11 @@ :default-chat-icon (st/default-chat-icon-profile color) :default-chat-icon-text st/default-chat-icon-text}] [view (:container styles) - (if (and photo-path (not (empty? photo-path))) + (if (and photo-path (seq photo-path)) [chat-icon photo-path styles] [default-chat-icon name styles]) [contact-badge badge-type styles]])) -(defview profile-icon [] - [contact [:contact]] - (let [;; TODO: stub - type :online - color default-chat-color] - [profile-icon-view (:photo-path @contact) (:name @contact) color type])) - (defn my-profile-icon [{{:keys [photo-path name]} :account edit? :edit?}] (let [type (if edit? :edit :blank) diff --git a/src/status_im/components/drag_drop.cljs b/src/status_im/components/drag_drop.cljs index 708efdfb12..bc5f40e571 100644 --- a/src/status_im/components/drag_drop.cljs +++ b/src/status_im/components/drag_drop.cljs @@ -1,6 +1,5 @@ (ns status-im.components.drag-drop - (:require [status-im.components.react :refer [animated pan-responder]] - [status-im.components.animation :as anim])) + (:require [status-im.components.react :refer [animated pan-responder]])) (defn pan-handlers [pan-responder] (js->clj (.-panHandlers pan-responder))) diff --git a/src/status_im/components/drawer/view.cljs b/src/status_im/components/drawer/view.cljs index 4a8a7ebbb5..5f7c366931 100644 --- a/src/status_im/components/drawer/view.cljs +++ b/src/status_im/components/drawer/view.cljs @@ -15,15 +15,13 @@ [status-im.components.status-view.view :refer [status-view]] [status-im.components.drawer.styles :as st] [status-im.profile.validations :as v] - [status-im.resources :as res] [status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.utils.utils :refer [clean-text]] [status-im.i18n :refer [label]] [status-im.components.react :refer [dismiss-keyboard!]] [clojure.string :as str] [cljs.spec :as s] - [status-im.components.chat-icon.screen :as ci] - [taoensso.timbre :as log])) + [status-im.components.chat-icon.screen :as ci])) (defonce drawer-atom (atom)) @@ -58,8 +56,7 @@ status-text (r/atom nil)] (fn [] (let [{:keys [name photo-path status]} @account - {new-name :name - new-status :status} @profile] + {new-name :name} @profile] [view st/drawer-menu [touchable-without-feedback {:on-press #(dismiss-keyboard!)} [view st/drawer-menu diff --git a/src/status_im/components/selectable_field/view.cljs b/src/status_im/components/selectable_field/view.cljs index 64598295dc..cd4ef52494 100644 --- a/src/status_im/components/selectable_field/view.cljs +++ b/src/status_im/components/selectable_field/view.cljs @@ -14,7 +14,7 @@ (r/set-state component {:focused? true})) (defn- on-selection-change - [event component] + [event _] (let [selection (.-selection (.-nativeEvent event)) start (.-start selection) end (.-end selection)] diff --git a/src/status_im/components/share.cljs b/src/status_im/components/share.cljs index f10be26ffb..aca6787730 100644 --- a/src/status_im/components/share.cljs +++ b/src/status_im/components/share.cljs @@ -1,7 +1,6 @@ -(ns status-im.components.share - (:require [status-im.utils.platform :as p])) +(ns status-im.components.share) (def class (js/require "react-native-share")) (defn open [opts] - (.open class (clj->js opts))) \ No newline at end of file + (.open class (clj->js opts))) diff --git a/src/status_im/components/tabs/styles.cljs b/src/status_im/components/tabs/styles.cljs index 0040b76099..9bcf0f2866 100644 --- a/src/status_im/components/tabs/styles.cljs +++ b/src/status_im/components/tabs/styles.cljs @@ -2,7 +2,7 @@ (:require [status-im.components.styles :refer [color-white]])) (def tabs-height 56) -(def tab-height (- tabs-height 1)) +(def tab-height (dec tabs-height)) (def bottom-gradient {:position :absolute diff --git a/src/status_im/components/tabs/tabs.cljs b/src/status_im/components/tabs/tabs.cljs index 27e7310aab..192694708d 100644 --- a/src/status_im/components/tabs/tabs.cljs +++ b/src/status_im/components/tabs/tabs.cljs @@ -31,7 +31,7 @@ (anim/timing val {:toValue to-value :duration 300}))))))) -(defn tabs-container [& children] +(defn tabs-container [& _] (let [chats-scrolled? (subscribe [:get :chats-scrolled?]) tabs-bar-value (subscribe [:animations :tabs-bar-value]) shadows? (get-in platform-specific [:tabs :tab-shadows?]) @@ -52,7 +52,7 @@ :pointerEvents (if @chats-scrolled? :none :auto)}] children))}))) -(defn tabs [{:keys [tab-list selected-view-id prev-view-id swiper]}] +(defn tabs [{:keys [tab-list selected-view-id prev-view-id]}] [tabs-container [view st/tabs-inner-container (doall (map-indexed #(create-tab %1 %2 selected-view-id prev-view-id) tab-list))]]) diff --git a/src/status_im/components/text_field/view.cljs b/src/status_im/components/text_field/view.cljs index 3a9c6402f6..f586bf42d5 100644 --- a/src/status_im/components/text_field/view.cljs +++ b/src/status_im/components/text_field/view.cljs @@ -50,7 +50,7 @@ ; Invoked once before the component is mounted. The return value will be used ; as the initial value of this.state. -(defn get-initial-state [component] +(defn get-initial-state [_] {:has-focus false :float-label? false :label-top 0 @@ -62,7 +62,7 @@ ; rendering occurs. If you call setState within this method, render() will see ; the updated state and will be executed only once despite the state change. (defn component-will-mount [component] - (let [{:keys [value] :as props} (r/props component) + (let [{:keys [value]} (r/props component) data {:label-top (anim/create-value (if (s/blank? value) (:label-bottom config) (:label-top config))) @@ -73,50 +73,6 @@ ;(log/debug "component-will-mount") (r/set-state component data))) -; Invoked once, only on the client (not on the server), immediately after the -; initial rendering occurs. At this point in the lifecycle, you can access any -; refs to your children (e.g., to access the underlying DOM representation). -; The componentDidMount() method of child components is invoked before that of -; parent components. -(defn component-did-mount [component] - (let [props (r/props component)] - ;(log/debug "component-did-mount:") - )) - -; Invoked when a component is receiving new props. This method is not called for -; the initial render. Use this as an opportunity to react to a prop transition -; before render() is called by updating the state using this.setState(). -; The old props can be accessed via this.props. Calling this.setState() within -; this function will not trigger an additional render. -(defn component-will-receive-props [component new-props] - ;(log/debug "component-will-receive-props: new-props=" new-props) - ) - -; Invoked before rendering when new props or state are being received. This method -; is not called for the initial render or when forceUpdate is used. Use this as -; an opportunity to return false when you're certain that the transition to the -; new props and state will not require a component update. -; If shouldComponentUpdate returns false, then render() will be completely skipped -; until the next state change. In addition, componentWillUpdate and -; componentDidUpdate will not be called. -(defn should-component-update [component next-props next-state] - ;(log/debug "should-component-update: " next-props next-state) - true) - -; Invoked immediately before rendering when new props or state are being received. -; This method is not called for the initial render. Use this as an opportunity -; to perform preparation before an update occurs. -(defn component-will-update [component next-props next-state] - ;(log/debug "component-will-update: " next-props next-state) - ) - -; Invoked immediately after the component's updates are flushed to the DOM. -; This method is not called for the initial render. Use this as an opportunity -; to operate on the DOM when the component has been updated. -(defn component-did-update [component prev-props prev-state] - ;(log/debug "component-did-update: " prev-props prev-state) - ) - (defn on-input-focus [{:keys [component animation onFocus]}] (do (log/debug "input focused") @@ -136,10 +92,9 @@ (defn get-width [event] (.-width (.-layout (.-nativeEvent event)))) -(defn reagent-render [data children] +(defn reagent-render [_ _] (let [component (r/current-component) - {:keys [has-focus - float-label? + {:keys [float-label? label-top label-font-size line-width @@ -189,14 +144,9 @@ [animated-view {:style (st/underline focus-line-color line-width)}]] [text {:style (st/error-text error-color)} error]])) -(defn text-field [data children] +(defn text-field [_ _] (let [component-data {:get-initial-state get-initial-state :component-will-mount component-will-mount - :component-did-mount component-did-mount - :component-will-receive-props component-will-receive-props - :should-component-update should-component-update - :component-will-update component-will-update - :component-did-update component-did-update :display-name "text-field" :reagent-render reagent-render}] ;(log/debug "Creating text-field component: " data) diff --git a/src/status_im/components/toolbar/styles.cljs b/src/status_im/components/toolbar/styles.cljs index 0e4a57acc1..82a5f0db45 100644 --- a/src/status_im/components/toolbar/styles.cljs +++ b/src/status_im/components/toolbar/styles.cljs @@ -48,8 +48,7 @@ (defn toolbar-actions-container [actions-count custom] (merge {:flex-direction "row" :margin-left toolbar-icon-spacing} - (when (and (= actions-count 0) - (not custom)) + (when (and (zero? actions-count) (not custom)) {:width (+ toolbar-icon-width toolbar-icon-spacing)}))) (def toolbar-action diff --git a/src/status_im/components/toolbar/view.cljs b/src/status_im/components/toolbar/view.cljs index 3e16b1c35a..6eae85a743 100644 --- a/src/status_im/components/toolbar/view.cljs +++ b/src/status_im/components/toolbar/view.cljs @@ -25,7 +25,7 @@ [view {:style style} [view st/toolbar [view (st/toolbar-nav-actions-container actions) - (when (not hide-nav?) + (when-not hide-nav? (if nav-action [touchable-highlight {:on-press (:handler nav-action)} [view (get-in platform-specific [:component-styles :toolbar-nav-action]) @@ -57,7 +57,6 @@ (dispatch [:set-in [:toolbar-search :text] nil]))) (defn- toolbar-with-search-content [{:keys [show-search? - search-key search-placeholder title on-search-submit]}] diff --git a/src/status_im/components/webview_bridge.cljs b/src/status_im/components/webview_bridge.cljs index 2b0ae6787b..e41023aa49 100644 --- a/src/status_im/components/webview_bridge.cljs +++ b/src/status_im/components/webview_bridge.cljs @@ -1,7 +1,5 @@ (ns status-im.components.webview-bridge - (:require [status-im.utils.utils :as u] - [reagent.core :as r] - [status-im.utils.platform :as p])) + (:require [reagent.core :as r])) (def webview-bridge-class (r/adapt-react-class (.-default (js/require "react-native-webview-bridge")))) diff --git a/src/status_im/contacts/handlers.cljs b/src/status_im/contacts/handlers.cljs index 10b8a5369b..e1a959a698 100644 --- a/src/status_im/contacts/handlers.cljs +++ b/src/status_im/contacts/handlers.cljs @@ -208,15 +208,16 @@ ((after send-contact-request)))) (register-handler ::update-pending-contact - (-> add-new-contact - ((after save-contact)))) + (after save-contact) + add-new-contact) (register-handler :add-pending-contact (u/side-effect! (fn [{:keys [chats contacts]} [_ chat-id]] (let [contact (if-let [contact-info (get-in chats [chat-id :contact-info])] (read-string contact-info) - (-> (get contacts chat-id) + (-> contacts + (get chat-id) (assoc :pending false)))] (dispatch [::prepare-contact contact]) (dispatch [:update-chat! {:chat-id chat-id @@ -259,12 +260,12 @@ :last-online timestamp}])))))) (register-handler :remove-contact - (-> (u/side-effect! - (fn [_ [_ {:keys [whisper-identity] :as contact}]] - (dispatch [:update-chat! {:chat-id whisper-identity - :pending-contact? true}]) - (dispatch [:update-contact! (assoc contact :pending true)]))) - ((after stop-watching-contact)))) + (after stop-watching-contact) + (u/side-effect! + (fn [_ [_ {:keys [whisper-identity] :as contact}]] + (dispatch [:update-chat! {:chat-id whisper-identity + :pending-contact? true}]) + (dispatch [:update-contact! (assoc contact :pending true)])))) (register-handler :open-contact-menu (u/side-effect! diff --git a/src/status_im/contacts/subs.cljs b/src/status_im/contacts/subs.cljs index 0bc89845cf..e62ea1dba0 100644 --- a/src/status_im/contacts/subs.cljs +++ b/src/status_im/contacts/subs.cljs @@ -1,9 +1,7 @@ (ns status-im.contacts.subs (:require-macros [reagent.ratom :refer [reaction]]) (:require [re-frame.core :refer [register-sub subscribe]] - [clojure.string :as str] - [status-im.utils.identicon :refer [identicon]] - [taoensso.timbre :as log])) + [status-im.utils.identicon :refer [identicon]])) (register-sub :get-contacts (fn [db _] @@ -11,12 +9,12 @@ (reaction @contacts)))) (defn sort-contacts [contacts] - (->> (vals contacts) - (sort (fn [c1 c2] - (let [name1 (or (:name c1) (:address c1) (:whisper-identity c1)) - name2 (or (:name c2) (:address c2) (:whisper-identity c2))] - (compare (clojure.string/lower-case name1) - (clojure.string/lower-case name2))))))) + (sort (fn [c1 c2] + (let [name1 (or (:name c1) (:address c1) (:whisper-identity c1)) + name2 (or (:name c2) (:address c2) (:whisper-identity c2))] + (compare (clojure.string/lower-case name1) + (clojure.string/lower-case name2)))) + (vals contacts))) (register-sub :all-added-contacts (fn [db _] @@ -114,16 +112,13 @@ chat (reaction (get-in @db [:chats chat-id])) contacts (contacts-by-chat filter db chat-id)] (reaction - (when @chat - (if (:group-chat @chat) - ;; TODO return group chat icon - nil - (cond - (:photo-path @chat) - (:photo-path @chat) + (when (and @chat (not (:group-chat @chat))) + (cond + (:photo-path @chat) + (:photo-path @chat) - (pos? (count @contacts)) - (:photo-path (first @contacts)) + (pos? (count @contacts)) + (:photo-path (first @contacts)) - :else - (identicon chat-id)))))))) + :else + (identicon chat-id))))))) diff --git a/src/status_im/contacts/validations.cljs b/src/status_im/contacts/validations.cljs index ce256e057d..62bdb6a686 100644 --- a/src/status_im/contacts/validations.cljs +++ b/src/status_im/contacts/validations.cljs @@ -9,8 +9,7 @@ (defn contact-can-be-added? [identity] (if (contacts/exists? identity) - (-> (contacts/get-by-id identity) - (get :pending)) + (:pending (contacts/get-by-id identity)) true)) (defn valid-length? [identity] diff --git a/src/status_im/contacts/views/contact_inner.cljs b/src/status_im/contacts/views/contact_inner.cljs index 38af0e85c6..9e245d902b 100644 --- a/src/status_im/contacts/views/contact_inner.cljs +++ b/src/status_im/contacts/views/contact_inner.cljs @@ -1,6 +1,5 @@ (ns status-im.contacts.views.contact-inner - (:require [clojure.string :as s] - [status-im.components.react :refer [view image text]] + (:require [status-im.components.react :refer [view image text]] [status-im.components.chat-icon.screen :refer [contact-icon-contacts-tab]] [status-im.contacts.styles :as st] [status-im.utils.gfycat.core :refer [generate-gfy]] diff --git a/src/status_im/contacts/views/contact_list.cljs b/src/status_im/contacts/views/contact_list.cljs index d7477a8fe5..9e80631646 100644 --- a/src/status_im/contacts/views/contact_list.cljs +++ b/src/status_im/contacts/views/contact_list.cljs @@ -22,9 +22,7 @@ [status-im.utils.listview :as lw] [status-im.i18n :refer [label]] [status-im.utils.platform :refer [platform-specific]] - [status-im.contacts.views.contact-inner :refer [contact-inner-view]] - [reagent.core :as r] - [clojure.string :as str])) + [status-im.contacts.views.contact-inner :refer [contact-inner-view]])) (defn new-group-chat-view [] [touchable-highlight diff --git a/src/status_im/data_store/chats.cljs b/src/status_im/data_store/chats.cljs index 5845b2dc8c..58f73645b3 100644 --- a/src/status_im/data_store/chats.cljs +++ b/src/status_im/data_store/chats.cljs @@ -9,8 +9,7 @@ (defn get-all [] - (-> (data-store/get-all-active) - normalize-contacts)) + (normalize-contacts (data-store/get-all-active))) (defn get-by-id [id] diff --git a/src/status_im/data_store/contacts.cljs b/src/status_im/data_store/contacts.cljs index 1fc3d271d0..7936fc29d1 100644 --- a/src/status_im/data_store/contacts.cljs +++ b/src/status_im/data_store/contacts.cljs @@ -1,6 +1,5 @@ (ns status-im.data-store.contacts - (:require [status-im.data-store.realm.contacts :as data-store] - [taoensso.timbre :as log]) + (:require [status-im.data-store.realm.contacts :as data-store]) (:refer-clojure :exclude [exists?])) (defn get-all diff --git a/src/status_im/data_store/core.cljs b/src/status_im/data_store/core.cljs index 21a948bc3d..a79c7cb3a8 100644 --- a/src/status_im/data_store/core.cljs +++ b/src/status_im/data_store/core.cljs @@ -1,6 +1,5 @@ (ns status-im.data-store.core - (:require [taoensso.timbre :as log] - [status-im.data-store.realm.core :as data-source])) + (:require [status-im.data-store.realm.core :as data-source])) (defn init [] diff --git a/src/status_im/data_store/discover.cljs b/src/status_im/data_store/discover.cljs index 23108fd516..fbd86e49f8 100644 --- a/src/status_im/data_store/discover.cljs +++ b/src/status_im/data_store/discover.cljs @@ -4,8 +4,8 @@ (defn get-all [ordering] - (->> (data-store/get-all-as-list ordering) - (mapv #(update % :tags vals)))) + (mapv #(update % :tags vals) + (data-store/get-all-as-list ordering))) (defn save [discover] diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index d7a8b62220..381a91bb12 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -5,8 +5,7 @@ [clojure.walk :refer [stringify-keys keywordize-keys]] [status-im.commands.utils :refer [generate-hiccup]] [cljs.reader :refer [read-string]] - [status-im.constants :as c] - [taoensso.timbre :as log]) + [status-im.constants :as c]) (:refer-clojure :exclude [update])) (defn- map-to-str @@ -85,7 +84,7 @@ message)))))) (defn get-last-message - [db chat-id] + [chat-id] (if-let [{:keys [content-type] :as message} (data-store/get-last-message chat-id)] (if (command-type? content-type) (clojure.core/update message :content str-to-map) diff --git a/src/status_im/data_store/pending_messages.cljs b/src/status_im/data_store/pending_messages.cljs index 6bf7b19c09..56e0fe9d60 100644 --- a/src/status_im/data_store/pending_messages.cljs +++ b/src/status_im/data_store/pending_messages.cljs @@ -1,6 +1,5 @@ (ns status-im.data-store.pending-messages (:require [status-im.data-store.realm.pending-messages :as data-store] - [clojure.string :as str] [status-im.utils.hex :as i])) (defn- get-id @@ -45,4 +44,4 @@ (defn delete-all-by-chat-id [chat-id] - (data-store/delete-all-by-chat-id chat-id)) \ No newline at end of file + (data-store/delete-all-by-chat-id chat-id)) diff --git a/src/status_im/data_store/processed_messages.cljs b/src/status_im/data_store/processed_messages.cljs index d934614417..ce40a9bf8e 100644 --- a/src/status_im/data_store/processed_messages.cljs +++ b/src/status_im/data_store/processed_messages.cljs @@ -1,6 +1,5 @@ (ns status-im.data-store.processed-messages - (:require [status-im.data-store.realm.processed-messages :as data-store] - [taoensso.timbre :as log]) + (:require [status-im.data-store.realm.processed-messages :as data-store]) (:refer-clojure :exclude [exists?])) (defn get-filtered diff --git a/src/status_im/data_store/realm/accounts.cljs b/src/status_im/data_store/realm/accounts.cljs index 44bd4ad0a3..4551da71a7 100644 --- a/src/status_im/data_store/realm/accounts.cljs +++ b/src/status_im/data_store/realm/accounts.cljs @@ -5,8 +5,7 @@ (realm/get-all realm/base-realm :account)) (defn get-all-as-list [] - (-> (get-all) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all))) (defn get-by-address [address] (realm/get-one-by-field-clj realm/base-realm :account :address address)) @@ -18,4 +17,4 @@ (defn save-all [accounts update?] (realm/write realm/base-realm (fn [] - (mapv #(realm/create realm/base-realm :account % update?) accounts)))) \ No newline at end of file + (mapv #(realm/create realm/base-realm :account % update?) accounts)))) diff --git a/src/status_im/data_store/realm/chats.cljs b/src/status_im/data_store/realm/chats.cljs index d90b04e6e5..ec24c5b70e 100644 --- a/src/status_im/data_store/realm/chats.cljs +++ b/src/status_im/data_store/realm/chats.cljs @@ -5,13 +5,13 @@ (defn get-all [] - (-> (realm/get-all @realm/account-realm :chat) + (-> @realm/account-realm + (realm/get-all :chat) (realm/sorted :timestamp :desc))) (defn get-all-as-list [] - (-> (get-all) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all))) (defn get-all-active [] @@ -36,7 +36,8 @@ (defn get-by-id [chat-id] - (-> (realm/get-one-by-field-clj @realm/account-realm :chat :chat-id chat-id) + (-> @realm/account-realm + (realm/get-one-by-field-clj :chat :chat-id chat-id) (realm/list->array :contacts))) (defn save @@ -58,20 +59,21 @@ (defn get-contacts [chat-id] - (-> (realm/get-one-by-field @realm/account-realm :chat :chat-id chat-id) + (-> @realm/account-realm + (realm/get-one-by-field :chat :chat-id chat-id) (aget "contacts"))) (defn has-contact? [chat-id identity] (let [contacts (get-contacts chat-id) - contact (.find contacts (fn [object index collection] + contact (.find contacts (fn [object _ _] (= identity (aget object "identity"))))] (if contact true false))) (defn- save-contacts [identities contacts added-at] (doseq [contact-identity identities] - (if-let [contact (.find contacts (fn [object index collection] + (if-let [contact (.find contacts (fn [object _ _] (= contact-identity (aget object "identity"))))] (doto contact (aset "is-in-chat" true) @@ -89,7 +91,7 @@ (defn- delete-contacts [identities contacts] (doseq [contact-identity identities] - (when-let [contact (.find contacts (fn [object index collection] + (when-let [contact (.find contacts (fn [object _ _] (= contact-identity (aget object "identity"))))] (realm/delete @realm/account-realm contact)))) @@ -102,7 +104,8 @@ [chat-id property-name value] (realm/write @realm/account-realm (fn [] - (-> (realm/get-one-by-field @realm/account-realm :chat :chat-id chat-id) + (-> @realm/account-realm + (realm/get-one-by-field :chat :chat-id chat-id) (aset (name property-name) value))))) (defn get-property diff --git a/src/status_im/data_store/realm/commands.cljs b/src/status_im/data_store/realm/commands.cljs index 187da5172f..2353cbca33 100644 --- a/src/status_im/data_store/realm/commands.cljs +++ b/src/status_im/data_store/realm/commands.cljs @@ -4,7 +4,7 @@ (defn get-by-chat-id [chat-id] (realm/get-one-by-field-clj @realm/account-realm :command - :chat-id identity)) + :chat-id chat-id)) (defn save [command] diff --git a/src/status_im/data_store/realm/contacts.cljs b/src/status_im/data_store/realm/contacts.cljs index 7efe73eee4..ed51c675ed 100644 --- a/src/status_im/data_store/realm/contacts.cljs +++ b/src/status_im/data_store/realm/contacts.cljs @@ -4,13 +4,13 @@ (defn get-all [] - (-> (realm/get-all @realm/account-realm :contact) + (-> @realm/account-realm + (realm/get-all :contact) (realm/sorted :name :asc))) (defn get-all-as-list [] - (-> (get-all) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all))) (defn get-by-id [whisper-identity] diff --git a/src/status_im/data_store/realm/core.cljs b/src/status_im/data_store/realm/core.cljs index db218023a3..760ed6f2c5 100644 --- a/src/status_im/data_store/realm/core.cljs +++ b/src/status_im/data_store/realm/core.cljs @@ -1,6 +1,5 @@ (ns status-im.data-store.realm.core - (:require [status-im.utils.utils :as u] - [status-im.utils.types :refer [to-string]] + (:require [status-im.utils.types :refer [to-string]] [status-im.data-store.realm.schemas.account.core :as account] [status-im.data-store.realm.schemas.base.core :as base] [taoensso.timbre :as log] @@ -36,7 +35,6 @@ (open-realm (last schemas) file-name)) (def new-account-filename "new-account") -(def new-accout-realm-file (str new-account-filename ".realm")) (def base-realm (open-migrated-realm (.-defaultPath realm-class) base/schemas)) @@ -123,7 +121,8 @@ (.filtered results filter-query)) (defn realm-collection->list [collection] - (-> (.map collection (fn [object _ _] object)) + (-> collection + (.map (fn [object _ _] object)) (js->clj :keywordize-keys true))) (defn list->array [record list-field] @@ -137,7 +136,8 @@ (js->clj :keywordize-keys true))) (defn get-by-filter [realm schema-name filter] - (-> (.objects realm (name schema-name)) + (-> realm + (.objects (name schema-name)) (.filtered filter))) (defn- get-schema-by-name [opts] @@ -153,10 +153,9 @@ (:type field-def) field-def))) -(defmulti to-query (fn [realm schema-name operator field value] - operator)) +(defmulti to-query (fn [_ _ operator _ _] operator)) -(defmethod to-query :eq [schema schema-name operator field value] +(defmethod to-query :eq [schema schema-name _ field value] (let [value (to-string value) field-type (field-type schema schema-name field) escaped-value (when value (str/replace (str value) #"\"" "\\\"")) diff --git a/src/status_im/data_store/realm/discover.cljs b/src/status_im/data_store/realm/discover.cljs index 104477989c..14eab22977 100644 --- a/src/status_im/data_store/realm/discover.cljs +++ b/src/status_im/data_store/realm/discover.cljs @@ -5,13 +5,13 @@ (defn get-all [ordering] - (-> (realm/get-all @realm/account-realm :discover) + (-> @realm/account-realm + (realm/get-all :discover) (realm/sorted :created-at ordering))) (defn get-all-as-list [ordering] - (-> (get-all ordering) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all ordering))) (defn get-tag-by-name [tag] (log/debug "Getting tag: " tag) @@ -65,7 +65,8 @@ (let [discoveries (realm/get-all @realm/account-realm :discover) count (realm/get-count discoveries)] (if (> count critical-count) - (let [to-delete (-> (realm/sorted discoveries by ordering) + (let [to-delete (-> discoveries + (realm/sorted by ordering) (realm/page 0 to-delete-count))] (realm/write @realm/account-realm (fn [] diff --git a/src/status_im/data_store/realm/messages.cljs b/src/status_im/data_store/realm/messages.cljs index 5e53ddcb6d..dc08d1bf84 100644 --- a/src/status_im/data_store/realm/messages.cljs +++ b/src/status_im/data_store/realm/messages.cljs @@ -9,8 +9,7 @@ (defn get-all-as-list [] - (-> (get-all) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all))) (defn get-by-id [message-id] @@ -29,8 +28,7 @@ (defn get-count-by-chat-id [chat-id] - (-> (get-by-chat-id chat-id) - (realm/get-count))) + (realm/get-count (get-by-chat-id chat-id))) (defn get-by-fields [fields from number-of-messages] @@ -47,8 +45,9 @@ (defn get-unviewed [] - (-> (realm/get-by-fields @realm/account-realm :message :and {:outgoing false - :message-status nil}) + (-> @realm/account-realm + (realm/get-by-fields :message :and {:outgoing false + :message-status nil}) (realm/realm-collection->list))) (defn exists? diff --git a/src/status_im/data_store/realm/processed_messages.cljs b/src/status_im/data_store/realm/processed_messages.cljs index 917f807d29..d1245b381c 100644 --- a/src/status_im/data_store/realm/processed_messages.cljs +++ b/src/status_im/data_store/realm/processed_messages.cljs @@ -4,7 +4,8 @@ (defn get-all [] - (-> (realm/get-all @realm/account-realm :processed-message) + (-> @realm/account-realm + (realm/get-all :processed-message) (realm/sorted :ttl :asc))) (defn get-filtered @@ -13,8 +14,7 @@ (defn get-filtered-as-list [condition] - (-> (get-filtered condition) - realm/realm-collection->list)) + (realm/realm-collection->list (get-filtered condition))) (defn save [processed-message] diff --git a/src/status_im/data_store/realm/requests.cljs b/src/status_im/data_store/realm/requests.cljs index d87c1bbc77..75191f4f3e 100644 --- a/src/status_im/data_store/realm/requests.cljs +++ b/src/status_im/data_store/realm/requests.cljs @@ -7,8 +7,7 @@ (defn get-all-as-list [] - (-> (get-all) - realm/realm-collection->list)) + (realm/realm-collection->list (get-all))) (defn get-open-by-chat-id [chat-id] @@ -27,8 +26,9 @@ (defn- get-by-message-id [chat-id message-id] - (-> (realm/get-by-fields @realm/account-realm :request :and [[:chat-id chat-id] - [:message-id message-id]]) + (-> @realm/account-realm + (realm/get-by-fields :request :and [[:chat-id chat-id] + [:message-id message-id]]) (realm/single))) (defn mark-as-answered diff --git a/src/status_im/data_store/realm/schemas/account/v1/chat.cljs b/src/status_im/data_store/realm/schemas/account/v1/chat.cljs index 6223b65c64..c84f57c819 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/chat.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/chat.cljs @@ -36,5 +36,5 @@ :contact-info {:type :string :optional true}}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating chat schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/chat_contact.cljs b/src/status_im/data_store/realm/schemas/account/v1/chat_contact.cljs index 49fccbe81f..aa671873a5 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/chat_contact.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/chat_contact.cljs @@ -6,5 +6,5 @@ :is-in-chat {:type "bool" :default true}}}) -(defn migration [old-realm new-realm] - (log/debug "migrating chat-contact schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating chat-contact schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/command.cljs b/src/status_im/data_store/realm/schemas/account/v1/command.cljs index b731766c0c..cfbab8f882 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/command.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/command.cljs @@ -6,5 +6,5 @@ :properties {:chat-id "string" :file "string"}}) -(defn migration [old-realm new-realm] - (log/debug "migrating command schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating command schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/contact.cljs b/src/status_im/data_store/realm/schemas/account/v1/contact.cljs index d49edcbf74..929c807f89 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/contact.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/contact.cljs @@ -22,5 +22,5 @@ :dapp-hash {:type :int :optional true}}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating contact schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/discover.cljs b/src/status_im/data_store/realm/schemas/account/v1/discover.cljs index 7f96cc846c..e11ddaf18f 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/discover.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/discover.cljs @@ -12,5 +12,5 @@ :objectType "tag"} :created-at {:type "int" :default 0}}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating discover schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/kv_store.cljs b/src/status_im/data_store/realm/schemas/account/v1/kv_store.cljs index 011a1ac552..7b5fd9a5cc 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/kv_store.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/kv_store.cljs @@ -6,5 +6,5 @@ :properties {:key "string" :value "string"}}) -(defn migration [old-realm new-realm] - (log/debug "migrating kv-store schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating kv-store schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/message.cljs b/src/status_im/data_store/realm/schemas/account/v1/message.cljs index c724cdc9a4..46851001c2 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/message.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/message.cljs @@ -32,5 +32,5 @@ :show? {:type :bool :default true}}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating message schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/pending_message.cljs b/src/status_im/data_store/realm/schemas/account/v1/pending_message.cljs index de046ef935..bc5e7e87c5 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/pending_message.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/pending_message.cljs @@ -18,5 +18,5 @@ :attempts :int :was-sent? :bool}}) -(defn migration [old-realm new-realm] - (log/debug "migrating pending-message schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating pending-message schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/processed_message.cljs b/src/status_im/data_store/realm/schemas/account/v1/processed_message.cljs index a6ce431abf..46a5209ec2 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/processed_message.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/processed_message.cljs @@ -9,5 +9,5 @@ :optional true} :ttl :int}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating processed-message schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/request.cljs b/src/status_im/data_store/realm/schemas/account/v1/request.cljs index 832b79d9dc..f2fa9bd054 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/request.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/request.cljs @@ -9,5 +9,5 @@ :default "open"} :added :date}}) -(defn migration [old-realm new-realm] - (log/debug "migrating request schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating request schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/tag.cljs b/src/status_im/data_store/realm/schemas/account/v1/tag.cljs index 6f081b9df6..571263e3b7 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/tag.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/tag.cljs @@ -6,5 +6,5 @@ :properties {:name "string" :count {:type "int" :optional true :default 0}}}) -(defn migration [old-realm new-realm] - (log/debug "migrating tag schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating tag schema")) diff --git a/src/status_im/data_store/realm/schemas/account/v1/user_status.cljs b/src/status_im/data_store/realm/schemas/account/v1/user_status.cljs index ae388e4b56..2b8fcb2d8f 100644 --- a/src/status_im/data_store/realm/schemas/account/v1/user_status.cljs +++ b/src/status_im/data_store/realm/schemas/account/v1/user_status.cljs @@ -8,5 +8,5 @@ :default ""} :status "string"}}) -(defn migration [old-realm new-realm] - (log/debug "migrating user-status schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating user-status schema")) diff --git a/src/status_im/data_store/realm/schemas/base/v1/account.cljs b/src/status_im/data_store/realm/schemas/base/v1/account.cljs index ddd68ba18f..19d34561b6 100644 --- a/src/status_im/data_store/realm/schemas/base/v1/account.cljs +++ b/src/status_im/data_store/realm/schemas/base/v1/account.cljs @@ -19,5 +19,5 @@ :default false} :network :string}}) -(defn migration [old-realm new-realm] +(defn migration [_ _] (log/debug "migrating account schema")) diff --git a/src/status_im/data_store/realm/schemas/base/v1/kv_store.cljs b/src/status_im/data_store/realm/schemas/base/v1/kv_store.cljs index 8bc17ec68c..4830de1110 100644 --- a/src/status_im/data_store/realm/schemas/base/v1/kv_store.cljs +++ b/src/status_im/data_store/realm/schemas/base/v1/kv_store.cljs @@ -6,5 +6,5 @@ :properties {:key "string" :value "string"}}) -(defn migration [old-realm new-realm] - (log/debug "migrating kv-store schema")) \ No newline at end of file +(defn migration [_ _] + (log/debug "migrating kv-store schema")) diff --git a/src/status_im/discover/handlers.cljs b/src/status_im/discover/handlers.cljs index fc483e140f..3e2a783242 100644 --- a/src/status_im/discover/handlers.cljs +++ b/src/status_im/discover/handlers.cljs @@ -54,7 +54,7 @@ (register-handler :status-received (u/side-effect! - (fn [{:keys [discoveries] :as db} [_ {:keys [from payload]}]] + (fn [{:keys [discoveries]} [_ {:keys [from payload]}]] (when (and (not (discoveries/exists? (:message-id payload))) (not (get discoveries (:message-id payload)))) (let [{:keys [message-id status hashtags profile]} payload diff --git a/src/status_im/discover/screen.cljs b/src/status_im/discover/screen.cljs index 300d78cf43..984c0f68e4 100644 --- a/src/status_im/discover/screen.cljs +++ b/src/status_im/discover/screen.cljs @@ -1,7 +1,6 @@ (ns status-im.discover.screen (:require-macros [status-im.utils.views :refer [defview]]) (:require - [reagent.core :as r] [re-frame.core :refer [dispatch subscribe]] [clojure.string :as str] [status-im.components.react :refer [view diff --git a/src/status_im/discover/search_results.cljs b/src/status_im/discover/search_results.cljs index 5275eeeff6..773008c0fe 100644 --- a/src/status_im/discover/search_results.cljs +++ b/src/status_im/discover/search_results.cljs @@ -15,8 +15,7 @@ [status-im.utils.platform :refer [platform-specific]] [status-im.i18n :refer [label]] [status-im.discover.styles :as st] - [status-im.contacts.styles :as contacts-st] - [taoensso.timbre :as log])) + [status-im.contacts.styles :as contacts-st])) (defn render-separator [_ row-id _] (list-item [view {:style st/row-separator diff --git a/src/status_im/discover/subs.cljs b/src/status_im/discover/subs.cljs index 6849df82ec..734aa01eab 100644 --- a/src/status_im/discover/subs.cljs +++ b/src/status_im/discover/subs.cljs @@ -18,7 +18,8 @@ (defn- get-discoveries-by-tags [discoveries current-tag tags] (let [tags' (or tags [current-tag])] - (filter #(every? (->> (map :name (:tags %)) + (filter #(every? (->> (:tags %) + (map :name) (into (hash-set))) tags') (vals discoveries)))) @@ -42,13 +43,11 @@ (register-sub :get-popular-tags (fn [db [_ limit]] - (-> (take limit (:tags @db)) - (reaction)))) + (reaction (take limit (:tags @db))))) (register-sub :get-discover-search-results (fn [db _] (let [discoveries (reaction (:discoveries @db)) current-tag (reaction (:current-tag @db)) tags (reaction (:discover-search-tags @db))] - (-> (get-discoveries-by-tags @discoveries @current-tag @tags) - (reaction))))) + (reaction (get-discoveries-by-tags @discoveries @current-tag @tags))))) diff --git a/src/status_im/group_settings/handlers.cljs b/src/status_im/group_settings/handlers.cljs index de0ecaa99d..6eb4ae4289 100644 --- a/src/status_im/group_settings/handlers.cljs +++ b/src/status_im/group_settings/handlers.cljs @@ -8,7 +8,6 @@ [status-im.data-store.messages :as messages] [status-im.data-store.chats :as chats] [status-im.constants :refer [text-content-type]] - [status-im.utils.handlers :as u] [status-im.navigation.handlers :as nav])) (defmethod nav/preload-data! :group-settings @@ -32,14 +31,13 @@ (assoc-in db [:chats current-chat-id property-name] property)))) (defn prepare-chat-settings - [{:keys [current-chat-id] :as db} _] + [{:keys [current-chat-id] :as db}] (let [{:keys [name color]} (-> db (get-in [:chats current-chat-id]) (select-keys [:name :color]))] - (-> db - (assoc :new-chat-name name - :new-chat-color color - :group-settings {})))) + (assoc db :new-chat-name name + :new-chat-color color + :group-settings {}))) (register-handler :show-group-settings (after (fn [_ _] (dispatch [:navigate-to :group-settings]))) @@ -76,7 +74,7 @@ remove-identities selected-participants)) (defn remove-members-from-chat! - [{:keys [current-chat-id selected-participants] :as db} _] + [{:keys [current-chat-id selected-participants]} _] (chats/remove-contacts current-chat-id selected-participants)) (defn notify-about-removing! diff --git a/src/status_im/handlers.cljs b/src/status_im/handlers.cljs index 48337c6507..c11993f295 100644 --- a/src/status_im/handlers.cljs +++ b/src/status_im/handlers.cljs @@ -106,7 +106,7 @@ (.addEntropy (.. ecc -sjcl -random))) (dispatch [:crypt-initialized])))))))) -(defn node-started [db result] +(defn node-started [_ _] (log/debug "Started Node") (enet/get-network #(dispatch [:set :network %]))) @@ -131,7 +131,7 @@ (register-handler :status-module-initialized! (after (u/side-effect! - (fn [db] + (fn [_] (status/module-initialized!)))) (fn [db] (assoc db :status-module-initialized? true))) diff --git a/src/status_im/handlers/server.cljs b/src/status_im/handlers/server.cljs index 9703da34e6..8fddc17630 100644 --- a/src/status_im/handlers/server.cljs +++ b/src/status_im/handlers/server.cljs @@ -2,8 +2,7 @@ (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [status-im.utils.utils :refer [http-post]] [taoensso.timbre :as log] - [status-im.utils.scheduler :as sch] - [status-im.data-store.messages :as messages])) + [status-im.utils.scheduler :as sch])) (defn sign-up [db phone-number message-id handler] diff --git a/src/status_im/i18n.cljs b/src/status_im/i18n.cljs index 5070abe0e1..44207ca737 100644 --- a/src/status_im/i18n.cljs +++ b/src/status_im/i18n.cljs @@ -33,7 +33,6 @@ [status-im.translations.zh-hant :as zh-hant] [status-im.translations.zh-wuu :as zh-wuu] [status-im.translations.zh-yue :as zh-yue] - [status-im.utils.utils :as u] [status-im.utils.js-resources :refer [default-contacts]])) (def i18n (js/require "react-native-i18n")) diff --git a/src/status_im/ios/platform.cljs b/src/status_im/ios/platform.cljs index 6c49098f30..251cbd525d 100644 --- a/src/status_im/ios/platform.cljs +++ b/src/status_im/ios/platform.cljs @@ -1,6 +1,5 @@ (ns status-im.ios.platform (:require [status-im.components.styles :as styles] - [status-im.utils.utils :as u] [status-im.components.toolbar.styles :refer [toolbar-background2]])) (def component-styles diff --git a/src/status_im/models/commands.cljs b/src/status_im/models/commands.cljs index 9ac9fab2ee..e9595012e8 100644 --- a/src/status_im/models/commands.cljs +++ b/src/status_im/models/commands.cljs @@ -42,13 +42,13 @@ ([db type message-id command-key] (set-command-input db type message-id command-key nil)) ([{:keys [current-chat-id] :as db} type message-id command-key params] - (let [command (-> (get-response-or-command type db command-key) - (add-params params)) - first-parameter (get (:params command) 0) - value (:value first-parameter)] + (let [command (get-response-or-command type db command-key) + command' (add-params command params) + first-parameter (get (:params command') 0) + value (:value first-parameter)] (update-in db [:chats current-chat-id :command-input] merge {:content value - :command command + :command command' :parameter-idx 0 :params params :to-message-id message-id})))) diff --git a/src/status_im/navigation/handlers.cljs b/src/status_im/navigation/handlers.cljs index 92a9b22f79..ac1486eb6e 100644 --- a/src/status_im/navigation/handlers.cljs +++ b/src/status_im/navigation/handlers.cljs @@ -1,7 +1,6 @@ (ns status-im.navigation.handlers (:require [re-frame.core :refer [dispatch debug enrich after]] - [status-im.utils.handlers :refer [register-handler]] - [taoensso.timbre :as log])) + [status-im.utils.handlers :refer [register-handler]])) (defn push-view [db view-id] (-> db diff --git a/src/status_im/network/handlers.cljs b/src/status_im/network/handlers.cljs index d43c72a878..fd1f295ac4 100644 --- a/src/status_im/network/handlers.cljs +++ b/src/status_im/network/handlers.cljs @@ -2,8 +2,7 @@ (:require [re-frame.core :refer [dispatch debug enrich after]] [status-im.utils.handlers :refer [register-handler]] [status-im.utils.handlers :as u] - [status-im.network.net-info :as ni] - [clojure.string :as s])) + [status-im.network.net-info :as ni])) (register-handler :listen-to-network-status! (u/side-effect! diff --git a/src/status_im/participants/views/add.cljs b/src/status_im/participants/views/add.cljs index 2ed209da3e..5a43bfef47 100644 --- a/src/status_im/participants/views/add.cljs +++ b/src/status_im/participants/views/add.cljs @@ -7,10 +7,8 @@ [status-im.components.toolbar.view :refer [toolbar]] [status-im.utils.listview :refer [to-datasource]] [status-im.participants.views.contact :refer [participant-contact]] - [reagent.core :as r] [status-im.participants.styles :as st] - [status-im.i18n :refer [label]] - [status-im.components.styles :as cst])) + [status-im.i18n :refer [label]])) (defn new-participants-toolbar [] [view diff --git a/src/status_im/participants/views/contact.cljs b/src/status_im/participants/views/contact.cljs index 0311510e9b..d474fb3305 100644 --- a/src/status_im/participants/views/contact.cljs +++ b/src/status_im/participants/views/contact.cljs @@ -4,7 +4,6 @@ [status-im.components.react :refer [view]] [status-im.contacts.views.contact-inner :refer [contact-inner-view]] [status-im.components.item-checkbox :refer [item-checkbox]] - [reagent.core :as r] [status-im.participants.styles :as st])) ;; todo duplication diff --git a/src/status_im/participants/views/remove.cljs b/src/status_im/participants/views/remove.cljs index cd03d93715..d7628d33fb 100644 --- a/src/status_im/participants/views/remove.cljs +++ b/src/status_im/participants/views/remove.cljs @@ -15,8 +15,7 @@ :refer [participant-contact]] [reagent.core :as r] [status-im.participants.styles :as st] - [status-im.i18n :refer [label]] - [status-im.components.styles :as cst])) + [status-im.i18n :refer [label]])) (defn remove-participants-toolbar [] [view diff --git a/src/status_im/profile/handlers.cljs b/src/status_im/profile/handlers.cljs index a52180213d..8c75e915ac 100644 --- a/src/status_im/profile/handlers.cljs +++ b/src/status_im/profile/handlers.cljs @@ -7,9 +7,6 @@ [status-im.utils.image-processing :refer [img->base64]] [status-im.i18n :refer [label]] [status-im.utils.handlers :as u :refer [get-hashtags]] - [clojure.string :as str] - [status-im.profile.validations :as v] - [cljs.spec :as s] [taoensso.timbre :as log])) (defn message-user [identity] diff --git a/src/status_im/profile/screen.cljs b/src/status_im/profile/screen.cljs index b1e208635b..9a10baac7c 100644 --- a/src/status_im/profile/screen.cljs +++ b/src/status_im/profile/screen.cljs @@ -22,7 +22,6 @@ [status-im.components.text-field.view :refer [text-field]] [status-im.components.selectable-field.view :refer [selectable-field]] [status-im.components.status-view.view :refer [status-view]] - [status-im.components.share :as share] [status-im.utils.phone-number :refer [format-phone-number]] [status-im.utils.image-processing :refer [img->base64]] [status-im.utils.platform :refer [platform-specific]] diff --git a/src/status_im/protocol/chat.cljs b/src/status_im/protocol/chat.cljs index a126becf5e..427adacd19 100644 --- a/src/status_im/protocol/chat.cljs +++ b/src/status_im/protocol/chat.cljs @@ -1,6 +1,5 @@ (ns status-im.protocol.chat (:require [cljs.spec :as s] - [status-im.protocol.message :as m] [status-im.protocol.web3.filtering :as f] [status-im.protocol.web3.delivery :as d] [taoensso.timbre :refer-macros [debug]] @@ -46,20 +45,18 @@ [{:keys [web3 message]}] (debug :send-clock-value-request message) (d/add-pending-message! - web3 - (merge message-defaults - (-> message - (assoc - :type :clock-value-request - :requires-ack? false))))) + web3 + (merge message-defaults + (assoc message + :type :clock-value-request + :requires-ack? false)))) (defn send-clock-value! [{:keys [web3 message]}] (debug :send-clock-value message) (d/add-pending-message! - web3 - (merge message-defaults - (-> message - (assoc - :type :clock-value - :requires-ack? false))))) + web3 + (merge message-defaults + (assoc message + :type :clock-value + :requires-ack? false)))) diff --git a/src/status_im/protocol/discoveries.cljs b/src/status_im/protocol/discoveries.cljs index 2432f44988..f3a61cdfcc 100644 --- a/src/status_im/protocol/discoveries.cljs +++ b/src/status_im/protocol/discoveries.cljs @@ -47,7 +47,7 @@ (l/message-listener (dissoc options :identity)))) (defn stop-watching-user! - [{:keys [web3 identity] :as options}] + [{:keys [web3 identity]}] (f/remove-filter! web3 {:from identity @@ -115,9 +115,8 @@ (defn send-status! [{:keys [web3 message]}] (debug :broadcasting-status) - (let [message (-> message - (assoc :type :discover - :topics [(make-discover-topic (:from message))]))] + (let [message (assoc message :type :discover + :topics [(make-discover-topic (:from message))])] (d/add-pending-message! web3 message))) (defn send-discoveries-request! @@ -125,19 +124,18 @@ (debug :sending-discoveries-request) (d/add-pending-message! web3 - (-> message - (assoc :type :discoveries-request - :topics [(make-discover-topic (:from message))])))) + (assoc message :type :discoveries-request + :topics [(make-discover-topic (:from message))]))) (defn send-discoveries-response! [{:keys [web3 discoveries message]}] (debug :sending-discoveries-response) - (doseq [portion (->> (take 100 discoveries) + (doseq [portion (->> discoveries + (take 100) (partition 10 10 nil))] (d/add-pending-message! web3 - (-> message - (assoc :type :discoveries-response - :topics [(make-discover-topic (:from message))] - :message-id (random/id) - :payload {:data (into [] portion)}))))) + (assoc message :type :discoveries-response + :topics [(make-discover-topic (:from message))] + :message-id (random/id) + :payload {:data (into [] portion)})))) diff --git a/src/status_im/protocol/encryption.cljs b/src/status_im/protocol/encryption.cljs index 13043b7656..cc4791bc20 100644 --- a/src/status_im/protocol/encryption.cljs +++ b/src/status_im/protocol/encryption.cljs @@ -8,7 +8,8 @@ "Returns {:private \"private key\" :public \"public key\"" [] (let [{:keys [enc dec]} - (-> (.generate ecc (.-ENC_DEC ecc) default-curve) + (-> ecc + (.generate (.-ENC_DEC ecc) default-curve) (js->clj :keywordize-keys true))] {:private dec :public enc})) diff --git a/src/status_im/protocol/group.cljs b/src/status_im/protocol/group.cljs index 1cf9342bf0..5de076534b 100644 --- a/src/status_im/protocol/group.cljs +++ b/src/status_im/protocol/group.cljs @@ -1,6 +1,5 @@ (ns status-im.protocol.group (:require - [status-im.protocol.message :as m] [status-im.protocol.web3.delivery :as d] [status-im.protocol.web3.utils :as u] [cljs.spec :as s] diff --git a/src/status_im/protocol/handlers.cljs b/src/status_im/protocol/handlers.cljs index b16ad3c288..feb0b987fb 100644 --- a/src/status_im/protocol/handlers.cljs +++ b/src/status_im/protocol/handlers.cljs @@ -16,7 +16,8 @@ [status-im.utils.datetime :as dt] [taoensso.timbre :as log :refer-macros [debug]] [status-im.constants :as c] - [status-im.components.status :as status])) + [status-im.components.status :as status] + [clojure.string :refer [join]])) (register-handler :initialize-protocol (fn [db [_ current-account-id]] @@ -75,10 +76,11 @@ (register-handler :initialize-sync-listener (fn [{:keys [web3 sync-listener] :as db} _] (if-not sync-listener - (->> (.isSyncing (.-eth web3) - (fn [error sync] - (dispatch [:update-sync-state error sync]))) - (assoc db :sync-listener)) + (let [sync-listener (.isSyncing + (.-eth web3) + (fn [error sync] + (dispatch [:update-sync-state error sync])))] + (assoc db :sync-listener sync-listener)) db))) (register-handler :incoming-message @@ -152,13 +154,15 @@ [identity from {:keys [message-id timestamp]}] (let [remover-name (:name (contacts/get-by-id from)) removed-name (:name (contacts/get-by-id identity))] - (->> (str (or remover-name from) " " (label :t/removed) " " (or removed-name identity)) + (->> [(or remover-name from) (label :t/removed) (or removed-name identity)] + (join " ") (system-message message-id timestamp)))) (defn you-removed-from-group-message [from {:keys [message-id timestamp]}] (let [remover-name (:name (contacts/get-by-id from))] - (->> (str (or remover-name from) " " (label :t/removed-from-chat)) + (->> [(or remover-name from) (label :t/removed-from-chat)] + (join " ") (system-message message-id timestamp)))) (defn participant-left-group-message @@ -198,10 +202,9 @@ [_ {:keys [from] {:keys [group-id timestamp] :as payload} :payload}]] (when (chats/new-update? timestamp group-id) - (let [message - (-> (you-removed-from-group-message from payload) - (assoc :group-id group-id))] - (dispatch [:received-message message])) + (let [message (you-removed-from-group-message from payload) + message' (assoc message :group-id group-id)] + (dispatch [:received-message message'])) (protocol/stop-watching-group! {:web3 web3 :group-id group-id}) (dispatch [:update-chat! {:chat-id group-id @@ -281,9 +284,8 @@ (messages/update message))))))) (defn save-message-clock-value! - [{:keys [message-extras] :as db} - [_ {:keys [from] - {:keys [message-id clock-value]} :payload}]] + [{:keys [message-extras]} + [_ {{:keys [message-id clock-value]} :payload}]] (when-let [{old-clock-value :clock-value :as message} (merge (messages/get-by-id message-id) (get message-extras message-id))] @@ -330,27 +332,25 @@ (register-handler :message-clock-value-request (u/side-effect! - (fn [db [_ {:keys [from] {:keys [message-id]} :payload}]] - (let [{:keys [chat-id]} (messages/get-by-id message-id) - message-overhead (chats/get-message-overhead chat-id) - last-clock-value (messages/get-last-clock-value chat-id)] - (if (> message-overhead 0) - (let [last-outgoing (->> (messages/get-last-outgoing chat-id message-overhead) - (reverse) - (map-indexed vector))] - (chats/reset-message-overhead chat-id) - (doseq [[i message] last-outgoing] - (dispatch [:update-clock-value! from i message (+ last-clock-value 100)]))) - (dispatch [:send-clock-value! from message-id])))))) + (fn [_ [_ {:keys [from] {:keys [message-id]} :payload}]] + (let [{:keys [chat-id]} (messages/get-by-id message-id) + message-overhead (chats/get-message-overhead chat-id) + last-clock-value (messages/get-last-clock-value chat-id)] + (if (pos? message-overhead) + (let [last-outgoing (->> (messages/get-last-outgoing chat-id message-overhead) + (reverse) + (map-indexed vector))] + (chats/reset-message-overhead chat-id) + (doseq [[i message] last-outgoing] + (dispatch [:update-clock-value! from i message (+ last-clock-value 100)]))) + (dispatch [:send-clock-value! from message-id])))))) (register-handler :message-clock-value (after save-message-clock-value!) (fn [{:keys [message-extras] :as db} - [_ {:keys [from] - {:keys [message-id clock-value]} :payload}]] - (if-let [{old-clock-value :clock-value - :as message} (merge (messages/get-by-id message-id) - (get message-extras message-id))] + [_ {{:keys [message-id clock-value]} :payload}]] + (if-let [{old-clock-value :clock-value} (merge (messages/get-by-id message-id) + (get message-extras message-id))] (if (> clock-value old-clock-value) (assoc-in db [:message-extras message-id] {:clock-value clock-value :show? true}) diff --git a/src/status_im/protocol/listeners.cljs b/src/status_im/protocol/listeners.cljs index 535f520e86..dd81faf6da 100644 --- a/src/status_im/protocol/listeners.cljs +++ b/src/status_im/protocol/listeners.cljs @@ -3,7 +3,7 @@ [status-im.protocol.ack :as ack] [status-im.protocol.web3.utils :as u] [status-im.protocol.encryption :as e] - [taoensso.timbre :refer-macros [debug] :as log] + [taoensso.timbre :refer-macros [debug]] [status-im.utils.hex :as i])) (defn- parse-payload [payload] diff --git a/src/status_im/protocol/message_cache.cljs b/src/status_im/protocol/message_cache.cljs index 969ae7041b..db9a4fbdc9 100644 --- a/src/status_im/protocol/message_cache.cljs +++ b/src/status_im/protocol/message_cache.cljs @@ -6,7 +6,7 @@ (defn init! [messages] - (reset! messages-set (into #{} messages)) + (reset! messages-set (set messages)) (reset! messages-map (->> messages (map (fn [{:keys [message-id type] :as message}] [[message-id type] message])) diff --git a/src/status_im/protocol/web3/utils.cljs b/src/status_im/protocol/web3/utils.cljs index 487d763b03..8d8bdd4b29 100644 --- a/src/status_im/protocol/web3/utils.cljs +++ b/src/status_im/protocol/web3/utils.cljs @@ -4,8 +4,6 @@ (def web3 (js/require "web3")) -(def status-app-topic "status-app") - (defn from-utf8 [s] (.fromUtf8 web3.prototype s)) @@ -16,8 +14,9 @@ (.-shh web3)) (defn make-web3 [rpc-url] - (->> (web3.providers.HttpProvider. rpc-url) - (web3.))) + (->> rpc-url + web3.providers.HttpProvider. + web3.)) (defn timestamp [] (to-long (now))) diff --git a/src/status_im/transactions/handlers.cljs b/src/status_im/transactions/handlers.cljs index e270a54cd0..1c50d39096 100644 --- a/src/status_im/transactions/handlers.cljs +++ b/src/status_im/transactions/handlers.cljs @@ -69,7 +69,7 @@ (register-handler ::discard-transaction (u/side-effect! - (fn [db [_ id]] + (fn [_ [_ id]] (status/discard-transaction id)))) (register-handler ::remove-transactions diff --git a/src/status_im/transactions/subs.cljs b/src/status_im/transactions/subs.cljs index 43c1e7c8ea..ee0df27c1a 100644 --- a/src/status_im/transactions/subs.cljs +++ b/src/status_im/transactions/subs.cljs @@ -1,7 +1,6 @@ (ns status-im.transactions.subs (:require-macros [reagent.ratom :refer [reaction]]) (:require [re-frame.core :refer [register-sub subscribe]] - [clojure.string :as s] [status-im.utils.hex :as i])) (register-sub :transactions diff --git a/src/status_im/transactions/views/transaction_page.cljs b/src/status_im/transactions/views/transaction_page.cljs index 7176103083..21572a15ca 100644 --- a/src/status_im/transactions/views/transaction_page.cljs +++ b/src/status_im/transactions/views/transaction_page.cljs @@ -11,8 +11,7 @@ [status-im.components.styles :refer [icon-ok icon-close]] [status-im.transactions.styles :as st] - [status-im.i18n :refer [label label-pluralize]] - [taoensso.timbre :as log])) + [status-im.i18n :refer [label label-pluralize]])) (defn title-bar [title id] [view st/title-bar diff --git a/src/status_im/utils/crypt.cljs b/src/status_im/utils/crypt.cljs index 1e40adc8bc..87730efe8c 100644 --- a/src/status_im/utils/crypt.cljs +++ b/src/status_im/utils/crypt.cljs @@ -1,7 +1,6 @@ (ns status-im.utils.crypt (:require [goog.crypt :refer [byteArrayToHex]] - [clojure.string :as s] - [status-im.utils.utils :as u]) + [clojure.string :as s]) (:import goog.crypt.Sha256)) (def random-bytes (js/require "react-native-randombytes")) diff --git a/src/status_im/utils/datetime.cljs b/src/status_im/utils/datetime.cljs index 24d82741c9..103f81d855 100644 --- a/src/status_im/utils/datetime.cljs +++ b/src/status_im/utils/datetime.cljs @@ -35,7 +35,7 @@ :else (today-format-fn local))))) (defn day-relative [ms] - (when (> ms 0) + (when (pos? ms) (to-short-str ms #(label :t/datetime-today)))) (defn format-time-ago [diff unit] diff --git a/src/status_im/utils/ethereum_network.cljs b/src/status_im/utils/ethereum_network.cljs index 2fb3ca707c..5a73547b27 100644 --- a/src/status_im/utils/ethereum_network.cljs +++ b/src/status_im/utils/ethereum_network.cljs @@ -4,8 +4,7 @@ (def Web3 (js/require "web3")) (defn web3 [] - (->> (Web3.providers.HttpProvider. c/ethereum-rpc-url) - (Web3.))) + (Web3. (Web3.providers.HttpProvider. c/ethereum-rpc-url))) (def networks {"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" :mainnet diff --git a/src/status_im/utils/fs.cljs b/src/status_im/utils/fs.cljs index 2a24d495c7..9339bc5ed7 100644 --- a/src/status_im/utils/fs.cljs +++ b/src/status_im/utils/fs.cljs @@ -1,6 +1,4 @@ -(ns status-im.utils.fs - (:require [clojure.string :as s] - [status-im.utils.utils :as u])) +(ns status-im.utils.fs) (def fs (js/require "react-native-fs")) diff --git a/src/status_im/utils/gfycat/core.cljs b/src/status_im/utils/gfycat/core.cljs index ce261d0600..c2539aab2b 100644 --- a/src/status_im/utils/gfycat/core.cljs +++ b/src/status_im/utils/gfycat/core.cljs @@ -5,12 +5,11 @@ (defn- pick-random [vector] - (-> (rand-nth vector) - str/capitalize)) + (str/capitalize (rand-nth vector))) (defn generate-gfy [] (let [first-adjective (pick-random adjectives/data) second-adjective (pick-random adjectives/data) animal (pick-random animals/data)] - (str first-adjective " " second-adjective " " animal))) \ No newline at end of file + (str first-adjective " " second-adjective " " animal))) diff --git a/src/status_im/utils/homoglyph.cljs b/src/status_im/utils/homoglyph.cljs index 6b96d1eee0..b19e56ffbc 100644 --- a/src/status_im/utils/homoglyph.cljs +++ b/src/status_im/utils/homoglyph.cljs @@ -1,5 +1,4 @@ -(ns status-im.utils.homoglyph - (:require [status-im.utils.utils :as u])) +(ns status-im.utils.homoglyph) (def homoglyph-finder (js/require "homoglyph-finder")) diff --git a/src/status_im/utils/identicon.cljs b/src/status_im/utils/identicon.cljs index 0cbf00db2e..cc56ddbf41 100644 --- a/src/status_im/utils/identicon.cljs +++ b/src/status_im/utils/identicon.cljs @@ -1,6 +1,4 @@ -(ns status-im.utils.identicon - (:require [clojure.string :as s] - [status-im.utils.utils :as u])) +(ns status-im.utils.identicon) (def default-size 40) diff --git a/src/status_im/utils/image_processing.cljs b/src/status_im/utils/image_processing.cljs index 6f6e664ebf..b639e33e1e 100644 --- a/src/status_im/utils/image_processing.cljs +++ b/src/status_im/utils/image_processing.cljs @@ -1,6 +1,5 @@ (ns status-im.utils.image-processing - (:require [reagent.core :as r] - [status-im.utils.fs :refer [read-file]] + (:require [status-im.utils.fs :refer [read-file]] [taoensso.timbre :as log] [clojure.string :as str])) @@ -13,11 +12,9 @@ (.catch on-error)))) (defn- image-base64-encode [path on-success on-error] - (let [on-encoded (fn [data] - (on-success data)) - on-error (fn [error] + (let [on-error (fn [error] (on-error :base64 error))] - (read-file path "base64" on-encoded on-error))) + (read-file path "base64" on-success on-error))) (defn img->base64 [path on-success on-error] (let [on-resized (fn [path] @@ -27,4 +24,4 @@ on-error (fn [error] (log/debug "Resized error: " error) (on-error :resize error))] - (resize path 150 150 on-resized on-error))) \ No newline at end of file + (resize path 150 150 on-resized on-error))) diff --git a/src/status_im/utils/phone_number.cljs b/src/status_im/utils/phone_number.cljs index 5ae5cb475f..0e9ede1756 100644 --- a/src/status_im/utils/phone_number.cljs +++ b/src/status_im/utils/phone_number.cljs @@ -1,5 +1,4 @@ -(ns status-im.utils.phone-number - (:require [status-im.utils.utils :as u])) +(ns status-im.utils.phone-number) (def i18n (js/require "react-native-i18n")) (def locale (or (.-locale i18n) "___en")) diff --git a/src/status_im/utils/platform.cljs b/src/status_im/utils/platform.cljs index f7e6095a4a..7656d97825 100644 --- a/src/status_im/utils/platform.cljs +++ b/src/status_im/utils/platform.cljs @@ -1,6 +1,5 @@ (ns status-im.utils.platform - (:require [status-im.utils.utils :as u] - [status-im.android.platform :as android] + (:require [status-im.android.platform :as android] [status-im.ios.platform :as ios])) (def react-native (js/require "react-native")) diff --git a/src/status_im/utils/sms_listener.cljs b/src/status_im/utils/sms_listener.cljs index 39afeebd0e..c80b1914b8 100644 --- a/src/status_im/utils/sms_listener.cljs +++ b/src/status_im/utils/sms_listener.cljs @@ -1,6 +1,5 @@ (ns status-im.utils.sms-listener - (:require [status-im.utils.platform :refer [android?]] - [status-im.utils.utils :as u])) + (:require [status-im.utils.platform :refer [android?]])) (def sms-listener (.-default (js/require "react-native-android-sms-listener")))