parent
68b6be2f31
commit
338deb9cc5
|
@ -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]))
|
||||
|
||||
|
||||
|
|
|
@ -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]))
|
||||
|
|
@ -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
|
|
@ -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
|
|
@ -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]]
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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]))))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue