Replaced incorrect aget access FIX #3067

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
Audrius Molis 2018-01-22 14:02:42 +02:00 committed by Dmitry Novotochinov
parent ae04dde8ba
commit cf83725ef1
No known key found for this signature in database
GPG Key ID: 267674DCC86628D9
19 changed files with 71 additions and 52 deletions

View File

@ -1,5 +1,6 @@
(ns status-im.chat.models.input
(:require [clojure.string :as str]
[goog.object :as object]
[status-im.ui.components.react :as rc]
[status-im.native-module.core :as status]
[status-im.chat.constants :as const]
@ -18,8 +19,8 @@
(str/replace text
#":([a-z_\-+0-9]*):"
(fn [[original emoji-id]]
(if-let [emoji-map (aget dependencies/emojis "lib" emoji-id)]
(aget emoji-map "char")
(if-let [emoji-map (object/get (object/get dependencies/emojis "lib") emoji-id)]
(object/get emoji-map "char")
original)))))
(defn text-ends-with-space? [text]

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.chats
(:require [status-im.data-store.realm.core :as realm]
(:require [goog.object :as object]
[status-im.data-store.realm.core :as realm]
[status-im.utils.random :refer [timestamp]]
[taoensso.timbre :as log])
(:refer-clojure :exclude [exists?]))
@ -73,20 +74,20 @@
[chat-id]
(-> @realm/account-realm
(realm/get-one-by-field :chat :chat-id chat-id)
(aget "contacts")))
(object/get "contacts")))
(defn has-contact?
[chat-id identity]
(let [contacts (get-contacts chat-id)
contact (.find contacts (fn [object _ _]
(= identity (aget object "identity"))))]
(= identity (object/get object "identity"))))]
(if contact true false)))
(defn- save-contacts
[identities contacts added-at]
(doseq [contact-identity identities]
(if-let [contact (.find contacts (fn [object _ _]
(= contact-identity (aget object "identity"))))]
(= contact-identity (object/get object "identity"))))]
(doto contact
(aset "is-in-chat" true)
(aset "added-at" added-at))
@ -104,7 +105,7 @@
[identities contacts]
(doseq [contact-identity identities]
(when-let [contact (.find contacts (fn [object _ _]
(= contact-identity (aget object "identity"))))]
(= contact-identity (object/get object "identity"))))]
(realm/delete @realm/account-realm contact))))
(defn remove-contacts
@ -123,4 +124,4 @@
(defn get-property
[chat-id property]
(when-let [chat (realm/get-one-by-field @realm/account-realm :chat :chat-id chat-id)]
(aget chat (name property))))
(object/get chat (name property))))

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.contact-groups
(:require [status-im.data-store.realm.core :as realm]
(:require [goog.object :as object]
[status-im.data-store.realm.core :as realm]
[status-im.utils.random :refer [timestamp]])
(:refer-clojure :exclude [exists?]))
@ -37,13 +38,13 @@
[group-id]
(-> @realm/account-realm
(realm/get-one-by-field :contact-group :group-id group-id)
(aget "contacts")))
(object/get "contacts")))
(defn- save-contacts
[identities contacts]
(doseq [contact-identity identities]
(when-not (.find contacts (fn [object _ _]
(= contact-identity (aget object "identity"))))
(= contact-identity (object/get object "identity"))))
(.push contacts (clj->js {:identity contact-identity})))))
(defn add-contacts

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.account.v10.message
(:require [taoensso.timbre :as log]
[goog.object :as object]
[clojure.string :as str]))
(def schema {:name :message
@ -40,8 +41,8 @@
(let [messages (.objects new-realm "message")]
(dotimes [i (.-length messages)]
(let [message (aget messages i)
content (aget message "content")
type (aget message "content-type")]
content (object/get message "content")
type (object/get message "content-type")]
(when (and (or (= type "wallet-command")
(= type "wallet-request")
(= type "command")

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.account.v12.pending-message
(:require [taoensso.timbre :as log]))
(:require [goog.object :as object]
[taoensso.timbre :as log]))
(def schema {:name :pending-message
:primaryKey :id
@ -29,8 +30,8 @@
(dotimes [i (.-length messages)]
(let [message (aget messages i)
new-message (aget new-messages i)
key-type (aget message "key-type")
key (aget message "key")]
key-type (object/get message "key-type")
key (object/get message "key")]
(if (= key-type "sym")
(aset new-message "sym-key-id" key)
(aset new-message "pub-key" key))))))

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.account.v15.contact
(:require [taoensso.timbre :as log]))
(:require [goog.object :as object]
[taoensso.timbre :as log]))
(def schema {:name :contact
:primaryKey :whisper-identity
@ -39,7 +40,7 @@
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (aget contact "whisper-identity")]
id (object/get contact "whisper-identity")]
(when (or (= id "mailman")
(= id "transactor-group")
(= id "transactor-personal"))

View File

@ -16,6 +16,7 @@
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
@ -48,12 +49,12 @@
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [group-id (aget object "group-id")
{:keys [bot] :as content} (reader/read-string (aget object "content"))]
(let [group-id (object/get object "group-id")
{:keys [bot] :as content} (reader/read-string (object/get object "content"))]
(when-not bot
(let [chat-id (aget object "chat-id")
(let [chat-id (object/get object "chat-id")
chat (chat-by-id realm chat-id)
group? (aget chat "group-chat")
group? (object/get chat "group-chat")
bot-name (if group?
"transactor-group"
"transactor-personal")

View File

@ -16,6 +16,7 @@
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
@ -70,7 +71,7 @@
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [{:keys [bot command] :as content} (reader/read-string (aget object "content"))
(let [{:keys [bot command] :as content} (reader/read-string (object/get object "content"))
content' (cond->
content

View File

@ -12,6 +12,7 @@
[status-im.data-store.realm.schemas.account.v5.contact-group :as contact-group]
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
@ -96,7 +97,7 @@
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [content (reader/read-string (aget object "content"))
(let [content (reader/read-string (object/get object "content"))
new-props (get mapping (selector content))
new-content (merge content new-props)]
(log/debug "migrating v19 command/request database, updating: " content " with: " new-props)
@ -107,11 +108,11 @@
(some-> new-realm
(.objects "message")
(.map (fn [msg _ _]
(let [message-id (aget msg "message-id")
chat-id (aget msg "chat-id")
from (aget msg "from")
msg-status (aget msg "message-status")
statuses (aget msg "user-statuses")]
(let [message-id (object/get msg "message-id")
chat-id (object/get msg "chat-id")
from (object/get msg "from")
msg-status (object/get msg "message-status")
statuses (object/get msg "user-statuses")]
(when statuses
(.map statuses (fn [status _ _]
(let [status-id (str message-id "-" from)]
@ -140,7 +141,7 @@
(.objects "user-status")
(.map (fn [status _ _]
;; orphaned statues, status-id must be set to some unique value, as realm complains when they are deleted
(when (clojure.string/blank? (aget status "status-id"))
(when (clojure.string/blank? (object/get status "status-id"))
(log/debug "Setting unique id for orphaned status")
(aset status "status-id" (str (swap! id-seq inc) "-deleted"))))))))

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.account.v6.contact
(:require [taoensso.timbre :as log]))
(:require [goog.object :as object]
[taoensso.timbre :as log]))
(def schema {:name :contact
:primaryKey :whisper-identity
@ -37,7 +38,7 @@
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (aget contact "whisper-identity")]
id (object/get contact "whisper-identity")]
(when (= id "console")
(log/debug (js->clj contact))
(aset contact "dapp-url" nil)

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.account.v7.contact
(:require [taoensso.timbre :as log]))
(:require [goog.object :as object]
[taoensso.timbre :as log]))
(def schema {:name :contact
:primaryKey :whisper-identity
@ -39,7 +40,7 @@
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (aget contact "whisper-identity")]
id (object/get contact "whisper-identity")]
(when (or (= id "console")
(= id "wallet")
(= id "browse"))

View File

@ -15,6 +15,7 @@
[status-im.data-store.realm.schemas.account.v5.contact-group :as contact-group]
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
[goog.object :as object]
[taoensso.timbre :as log]))
(def schema [chat/schema
@ -39,8 +40,8 @@
(let [new-commands (.objects new-realm "command")]
(dotimes [i (.-length new-commands)]
(let [command (aget new-commands i)
command-name (aget command "name")
command-title (aget command "title")]
command-name (object/get command "name")
command-title (object/get command "title")]
(cond
(and (= command-name "global") (= command-title "Browser"))
(aset command "params" 0 "placeholder" "URL")

View File

@ -1,5 +1,6 @@
(ns status-im.data-store.realm.schemas.base.v3.account
(:require [taoensso.timbre :as log]
(:require [goog.object :as object]
[taoensso.timbre :as log]
[status-im.utils.signing-phrase.core :as signing-phrase]))
(def schema {:name :account
@ -27,7 +28,7 @@
(let [accounts (.objects new-realm "account")]
(dotimes [i (.-length accounts)]
(let [account (aget accounts i)
phrase (aget account "signing-phrase")]
phrase (object/get account "signing-phrase")]
(when (empty? phrase)
(log/debug (js->clj account))
(aset account "signing-phrase" (signing-phrase/generate)))))))

View File

@ -1,5 +1,6 @@
(ns status-im.ui.components.camera
(:require [reagent.core :as r]
(:require [goog.object :as object]
[reagent.core :as r]
[clojure.walk :refer [keywordize-keys]]
[status-im.utils.platform :as platform]
[status-im.react-native.js-dependencies :as rn-dependecies]))
@ -7,7 +8,7 @@
(def default-camera (.-default rn-dependecies/camera))
(defn constants [t]
(-> (aget rn-dependecies/camera "constants" t)
(-> (object/get rn-dependecies/camera "constants" t)
(js->clj)
(keywordize-keys)))

View File

@ -1,12 +1,13 @@
(ns status-im.ui.components.context-menu
(:require [reagent.core :as r]
(:require [goog.object :as object]
[reagent.core :as r]
[status-im.ui.components.styles :as st]
[status-im.utils.platform :refer [platform-specific ios?]]
[status-im.ui.components.react :as rn]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn- get-property [name]
(aget rn-dependencies/popup-menu name))
(object/get rn-dependencies/popup-menu name))
(defn- get-class [name]
(rn/adapt-class (get-property name)))

View File

@ -1,6 +1,7 @@
(ns status-im.ui.components.icons.vector-icons
(:require-macros [status-im.utils.slurp :refer [slurp-svg]])
(:require [reagent.core :as reagent]
(:require [goog.object :as object]
[reagent.core :as reagent]
[status-im.utils.platform :as platform]
[status-im.ui.components.styles :as styles]
[status-im.ui.components.react :as react]
@ -8,7 +9,7 @@
(:refer-clojure :exclude [use]))
(defn get-property [name]
(aget rn-dependencies/svg name))
(object/get rn-dependencies/svg name))
(defn adapt-class [class]
(when class

View File

@ -1,6 +1,7 @@
(ns status-im.ui.components.react
(:require-macros [status-im.utils.views :as views])
(:require [clojure.string :as string]
[goog.object :as object]
[reagent.core :as r]
[status-im.ui.components.styles :as st]
[status-im.utils.utils :as u]
@ -10,7 +11,7 @@
(defn get-react-property [name]
(if rn-dependencies/react-native
(aget rn-dependencies/react-native name)
(object/get rn-dependencies/react-native name)
#js {}))
(defn adapt-class [class]
@ -135,7 +136,7 @@
(def image-picker-class rn-dependencies/image-crop-picker)
(defn show-access-error [o]
(when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (aget o "code")) ; Do not show error when user cancel selection
(when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (object/get o "code")) ; Do not show error when user cancel selection
(u/show-popup (i18n/label :t/error)
(i18n/label :t/photos-access-error))))

View File

@ -1,11 +1,12 @@
(ns status-im.utils.image-processing
(:require [status-im.utils.fs :refer [read-file]]
(:require [goog.object :as object]
[status-im.utils.fs :refer [read-file]]
[taoensso.timbre :as log]
[clojure.string :as str]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn- resize [path max-width max-height on-resize on-error]
(let [resize-fn (aget rn-dependencies/image-resizer "default" "createResizedImage")]
(let [resize-fn (object/get rn-dependencies/image-resizer "default" "createResizedImage")]
(-> (resize-fn path max-width max-height "JPEG" 75 0 nil)
(.then on-resize)
(.catch on-error))))
@ -17,7 +18,7 @@
(defn img->base64 [path on-success on-error]
(let [on-resized (fn [image]
(let [path (aget image "path")]
(let [path (object/get image "path")]
(log/debug "Resized: " path)
(image-base64-encode path on-success on-error)))
on-error (fn [error]

View File

@ -1,5 +1,6 @@
(ns status-im.utils.notifications
(:require [re-frame.core :as re-frame :refer [dispatch reg-fx]]
(:require [goog.object :as object]
[re-frame.core :as re-frame :refer [dispatch reg-fx]]
[status-im.utils.handlers :as handlers]
[status-im.react-native.js-dependencies :as rn]
[status-im.utils.config :as config]
@ -20,7 +21,7 @@
(.requestPermissions (.-default rn/react-native-fcm)))
(defn get-fcm-token []
(-> (.getFCMToken (aget rn/react-native-fcm "default"))
(-> (.getFCMToken (object/get rn/react-native-fcm "default"))
(.then (fn [x]
(log/debug "get-fcm-token: " x)
(dispatch [:update-fcm-token x])))))