Merge pull request #592 from status-im/xmas-cleanup

Remove required namespaces
Remove unused local symbols
Apply lein-kibit suggestions
This commit is contained in:
Roman Volosovskyi 2017-01-16 08:48:04 +02:00 committed by GitHub
commit 34f43e11ce
130 changed files with 319 additions and 498 deletions

View File

@ -17,5 +17,5 @@
:heads-up-display false
:jsload-callback #(swap! cnt inc))
(core/init :test)
(core/init)
;(init-stubs)

View File

@ -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

View File

@ -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?)))))

View File

@ -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))

View File

@ -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])

View File

@ -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

View File

@ -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]]

View File

@ -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))

View File

@ -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

View File

@ -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!

View File

@ -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)

View File

@ -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

View File

@ -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))

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)))))

View File

@ -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

View File

@ -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)

View File

@ -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]]))

View File

@ -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})
:height 15})

View File

@ -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})

View File

@ -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

View File

@ -10,8 +10,7 @@
separator-color
text1-color
text2-color
text3-color]]
[taoensso.timbre :as log]))
text3-color]]))
(def suggestion-height 60)

View File

@ -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])]

View File

@ -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

View File

@ -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?

View File

@ -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))

View File

@ -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]

View File

@ -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 []

View File

@ -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))]

View File

@ -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 %))}]))

View File

@ -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)

View File

@ -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]]]])})))

View File

@ -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])

View File

@ -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])

View File

@ -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])

View File

@ -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)))

View File

@ -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])}

View File

@ -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}]

View File

@ -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?

View File

@ -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

View File

@ -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)))

View File

@ -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)})

View File

@ -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)

View File

@ -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)))

View File

@ -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

View File

@ -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)]

View File

@ -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)))
(.open class (clj->js opts)))

View File

@ -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

View File

@ -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))]])

View File

@ -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)

View File

@ -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

View File

@ -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]}]

View File

@ -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"))))

View File

@ -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!

View File

@ -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)))))))

View File

@ -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]

View File

@ -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]]

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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 []

View File

@ -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]

View File

@ -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)

View File

@ -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))
(data-store/delete-all-by-chat-id chat-id))

View File

@ -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

View File

@ -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))))
(mapv #(realm/create realm/base-realm :account % update?) accounts))))

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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) #"\"" "\\\""))

View File

@ -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 []

View File

@ -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?

View File

@ -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]

View File

@ -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

View File

@ -36,5 +36,5 @@
:contact-info {:type :string
:optional true}}})
(defn migration [old-realm new-realm]
(defn migration [_ _]
(log/debug "migrating chat schema"))

View File

@ -6,5 +6,5 @@
:is-in-chat {:type "bool"
:default true}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat-contact schema"))
(defn migration [_ _]
(log/debug "migrating chat-contact schema"))

View File

@ -6,5 +6,5 @@
:properties {:chat-id "string"
:file "string"}})
(defn migration [old-realm new-realm]
(log/debug "migrating command schema"))
(defn migration [_ _]
(log/debug "migrating command schema"))

View File

@ -22,5 +22,5 @@
:dapp-hash {:type :int
:optional true}}})
(defn migration [old-realm new-realm]
(defn migration [_ _]
(log/debug "migrating contact schema"))

View File

@ -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"))

View File

@ -6,5 +6,5 @@
:properties {:key "string"
:value "string"}})
(defn migration [old-realm new-realm]
(log/debug "migrating kv-store schema"))
(defn migration [_ _]
(log/debug "migrating kv-store schema"))

View File

@ -32,5 +32,5 @@
:show? {:type :bool
:default true}}})
(defn migration [old-realm new-realm]
(defn migration [_ _]
(log/debug "migrating message schema"))

View File

@ -18,5 +18,5 @@
:attempts :int
:was-sent? :bool}})
(defn migration [old-realm new-realm]
(log/debug "migrating pending-message schema"))
(defn migration [_ _]
(log/debug "migrating pending-message schema"))

View File

@ -9,5 +9,5 @@
:optional true}
:ttl :int}})
(defn migration [old-realm new-realm]
(defn migration [_ _]
(log/debug "migrating processed-message schema"))

View File

@ -9,5 +9,5 @@
:default "open"}
:added :date}})
(defn migration [old-realm new-realm]
(log/debug "migrating request schema"))
(defn migration [_ _]
(log/debug "migrating request schema"))

View File

@ -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"))
(defn migration [_ _]
(log/debug "migrating tag schema"))

View File

@ -8,5 +8,5 @@
:default ""}
:status "string"}})
(defn migration [old-realm new-realm]
(log/debug "migrating user-status schema"))
(defn migration [_ _]
(log/debug "migrating user-status schema"))

View File

@ -19,5 +19,5 @@
:default false}
:network :string}})
(defn migration [old-realm new-realm]
(defn migration [_ _]
(log/debug "migrating account schema"))

View File

@ -6,5 +6,5 @@
:properties {:key "string"
:value "string"}})
(defn migration [old-realm new-realm]
(log/debug "migrating kv-store schema"))
(defn migration [_ _]
(log/debug "migrating kv-store schema"))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)))))

View File

@ -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!

View File

@ -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)))

View File

@ -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]

View File

@ -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"))

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More