From cff3349c7d55bb372c4b5fb71a7f3ad008b9262b Mon Sep 17 00:00:00 2001 From: Adrian Tiberius Date: Mon, 18 Jul 2016 19:50:13 +0300 Subject: [PATCH] cleanup --- src/status_im/accounts/handlers.cljs | 1 + src/status_im/{ => accounts}/login/handlers.cljs | 2 +- src/status_im/{ => accounts}/login/screen.cljs | 4 ++-- src/status_im/{ => accounts}/login/styles.cljs | 2 +- src/status_im/android/core.cljs | 2 +- src/status_im/chat/sign_up.cljs | 2 -- src/status_im/commands/handlers/loading.cljs | 14 +++----------- src/status_im/handlers.cljs | 2 +- src/status_im/models/chats.cljs | 2 -- src/status_im/persistence/realm/core.cljs | 8 -------- src/status_im/persistence/realm/schemas.cljs | 6 +----- 11 files changed, 11 insertions(+), 34 deletions(-) rename src/status_im/{ => accounts}/login/handlers.cljs (71%) rename src/status_im/{ => accounts}/login/screen.cljs (97%) rename src/status_im/{ => accounts}/login/styles.cljs (96%) diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index e5bd588fed..408ff3a973 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -12,6 +12,7 @@ [status-im.persistence.realm.core :as realm] [status-im.i18n :refer [label]] [status-im.constants :refer [content-type-command-request]] + status-im.accounts.login.handlers [clojure.string :as str])) diff --git a/src/status_im/login/handlers.cljs b/src/status_im/accounts/login/handlers.cljs similarity index 71% rename from src/status_im/login/handlers.cljs rename to src/status_im/accounts/login/handlers.cljs index 79c6944d31..5a00d18935 100644 --- a/src/status_im/login/handlers.cljs +++ b/src/status_im/accounts/login/handlers.cljs @@ -1,4 +1,4 @@ -(ns status-im.login.handlers +(ns status-im.accounts.login.handlers (:require [re-frame.core :refer [register-handler after dispatch]] [status-im.utils.handlers :as u])) diff --git a/src/status_im/login/screen.cljs b/src/status_im/accounts/login/screen.cljs similarity index 97% rename from src/status_im/login/screen.cljs rename to src/status_im/accounts/login/screen.cljs index 3329467df6..6c00fe2642 100644 --- a/src/status_im/login/screen.cljs +++ b/src/status_im/accounts/login/screen.cljs @@ -1,4 +1,4 @@ -(ns status-im.login.screen +(ns status-im.accounts.login.screen (:require-macros [status-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [status-im.components.react :refer [view @@ -22,7 +22,7 @@ white-form-text-input]] [status-im.qr-scanner.views.scan-button :refer [scan-button]] [status-im.i18n :refer [label]] - [status-im.login.styles :as st])) + [status-im.accounts.login.styles :as st])) (def toolbar-title [view toolbar-title-container diff --git a/src/status_im/login/styles.cljs b/src/status_im/accounts/login/styles.cljs similarity index 96% rename from src/status_im/login/styles.cljs rename to src/status_im/accounts/login/styles.cljs index 37278d33cb..e718fed938 100644 --- a/src/status_im/login/styles.cljs +++ b/src/status_im/accounts/login/styles.cljs @@ -1,4 +1,4 @@ -(ns status-im.login.styles +(ns status-im.accounts.login.styles (:require [status-im.components.styles :refer [font title-font text1-color diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index b039e9e472..3cd4552193 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -14,7 +14,7 @@ [status-im.discovery.screen :refer [discovery]] [status-im.discovery.tag :refer [discovery-tag]] [status-im.chat.screen :refer [chat]] - [status-im.login.screen :refer [login]] + [status-im.accounts.login.screen :refer [login]] [status-im.accounts.screen :refer [accounts]] [status-im.chats-list.screen :refer [chats-list]] [status-im.new-group.screen :refer [new-group]] diff --git a/src/status_im/chat/sign_up.cljs b/src/status_im/chat/sign_up.cljs index e6b129b7d9..c60f6d2bce 100644 --- a/src/status_im/chat/sign_up.cljs +++ b/src/status_im/chat/sign_up.cljs @@ -6,7 +6,6 @@ [status-im.models.chats :as c] [status-im.components.styles :refer [default-chat-color]] [status-im.utils.utils :refer [on-error http-post toast]] - [status-im.utils.logging :as log] [status-im.utils.random :as random] [status-im.utils.sms-listener :refer [add-sms-listener remove-sms-listener]] @@ -199,7 +198,6 @@ (defn create-chat [handler] (fn [db] (let [{:keys [new-chat] :as db'} (handler db)] - (log/debug new-chat) (when new-chat (c/create-chat new-chat)) (dissoc db' :new-chat)))) diff --git a/src/status_im/commands/handlers/loading.cljs b/src/status_im/commands/handlers/loading.cljs index eee3ddc22a..feeb9be155 100644 --- a/src/status_im/commands/handlers/loading.cljs +++ b/src/status_im/commands/handlers/loading.cljs @@ -13,16 +13,12 @@ (defn load-commands! [_ [identity]] - (let [is-console? (= identity "console") - schema (if is-console? - :base - :account)] (dispatch [::fetch-commands! identity]) ;; todo uncomment - #_(if-let [{:keys [file]} (realm/get-one-by-field schema :commands + #_(if-let [{:keys [file]} (realm/get-one-by-field :account :commands :chat-id identity)] (dispatch [::parse-commands! identity file]) - (dispatch [::fetch-commands! identity])))) + (dispatch [::fetch-commands! identity]))) (defn fetch-commands! [db [identity]] @@ -77,11 +73,7 @@ (defn save-commands-js! [_ [id file]] - (let [is-console? (= id "console") - schema (if is-console? - :base - :account)] - (realm/create-object schema :commands {:chat-id id :file file}))) + (realm/create-object :account :commands {:chat-id id :file file})) (defn loading-failed! [db [id reason details]] diff --git a/src/status_im/handlers.cljs b/src/status_im/handlers.cljs index 93044f0e34..e6422caeca 100644 --- a/src/status_im/handlers.cljs +++ b/src/status_im/handlers.cljs @@ -66,13 +66,13 @@ (fn [_ _] (assoc app-db :signed-up (storage/get kv/kv-store :signed-up) - :user-identity (protocol/stored-identity nil) :password (storage/get kv/kv-store :password)))) (register-handler :initialize-account (u/side-effect! (fn [_ [_ account]] (dispatch [:initialize-protocol account]) + (dispatch [:initialize-account-db]) (dispatch [:initialize-chats]) (dispatch [:load-contacts]) (dispatch [:init-chat])))) diff --git a/src/status_im/models/chats.cljs b/src/status_im/models/chats.cljs index 9e86014fe4..854e7bcc57 100644 --- a/src/status_im/models/chats.cljs +++ b/src/status_im/models/chats.cljs @@ -42,10 +42,8 @@ (defn create-chat ([{:keys [last-msg-id] :as chat}] (let [chat (assoc chat :last-msg-id (or last-msg-id ""))] - (log/debug "Creating chat" chat) (r/write :account #(r/create :account :chats chat)))) ([db chat-id identities group-chat? chat-name] - (log/debug "Creating chat" chat-id) (when-not (chat-exists? chat-id) (let [chat-name (or chat-name (get-chat-name chat-id identities)) diff --git a/src/status_im/persistence/realm/core.cljs b/src/status_im/persistence/realm/core.cljs index 7c5f234d5d..801e245409 100644 --- a/src/status_im/persistence/realm/core.cljs +++ b/src/status_im/persistence/realm/core.cljs @@ -30,7 +30,6 @@ (str/ends-with? path realm_file))) (defn realm [schema] - (log/debug "Schema: " schema) (case schema :base base-realm :account @account-realm)) @@ -59,12 +58,10 @@ (defn change-account-realm [address handler] (let [path (.-path @account-realm) realm-file (str new-account-filename ".realm") - _ (log/debug "account realm path: " path address) is-new-account? (str/ends-with? path realm-file)] (close-account-realm) (if is-new-account? (let [new-path (str/replace path realm-file (str address ".realm"))] - (log/debug "account new path: " new-path) (fs/move-file path new-path #(move-file-handler address % handler))) (do (reset! account-realm (create-account-realm address)) @@ -115,24 +112,20 @@ query)) (defn get-by-filter [schema schema-name filter] - (log/debug "Get by filter: " schema schema-name) (-> (.objects (realm schema) (name schema-name)) (.filtered filter))) (defn get-by-field [schema schema-name field value] - (log/debug "Get by field: " schema schema-name field value) (let [q (to-query schema schema-name :eq field value)] (.filtered (.objects (realm schema) (name schema-name)) q))) (defn get-by-fields [schema schema-name fields] - (log/debug "Get by fields: " schema schema-name fields) (let [queries (map (fn [[k v]] (to-query schema schema-name :eq k v)) fields)] (.filtered (.objects (realm schema) (name schema-name)) (and-q queries)))) (defn get-all [schema schema-name] - (log/debug "Get all: " schema schema-name) (.objects (realm schema) (to-string schema-name))) (defn sorted [results field-name order] @@ -173,7 +166,6 @@ (.-length objs)) (defn get-list [schema schema-name] - (log/debug "Get list: " schema schema-name) (vals (js->clj (.objects (realm schema) (to-string schema-name)) :keywordize-keys true))) (defn collection->map [collection] diff --git a/src/status_im/persistence/realm/schemas.cljs b/src/status_im/persistence/realm/schemas.cljs index 4625b8b2c8..1506f3ad96 100644 --- a/src/status_im/persistence/realm/schemas.cljs +++ b/src/status_im/persistence/realm/schemas.cljs @@ -26,11 +26,7 @@ {:name :kv-store :primaryKey :key :properties {:key "string" - :value "string"}} - {:name :commands - :primaryKey :chat-id - :properties {:chat-id "string" - :file "string"}}] + :value "string"}}] :schemaVersion 0}) (def account {:schema [{:name :contacts