fixed extensions installation issues
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
1a46355c61
commit
8374a7d532
|
@ -27,7 +27,6 @@
|
||||||
(cond
|
(cond
|
||||||
(= permission constants/dapp-permission-install-extension)
|
(= permission constants/dapp-permission-install-extension)
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:extensions/manage :url :value] (:uri params))}
|
|
||||||
(extensions.registry/load (:uri params) true)
|
(extensions.registry/load (:uri params) true)
|
||||||
(send-response-to-bridge permission message-id true nil)
|
(send-response-to-bridge permission message-id true nil)
|
||||||
(process-next-permission dapp-name))
|
(process-next-permission dapp-name))
|
||||||
|
|
|
@ -510,21 +510,19 @@
|
||||||
(extensions.registry/change-state cofx extension-key active?)))
|
(extensions.registry/change-state cofx extension-key active?)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions.ui/show-button-pressed
|
:extensions.ui/find-button-pressed
|
||||||
(fn [cofx [_ url]]
|
(fn [cofx [_ url]]
|
||||||
(extensions.registry/load cofx url false)))
|
(extensions.registry/load cofx url false)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions.ui/install-extension-button-pressed
|
:extensions.ui/install-extension-button-pressed
|
||||||
(fn [{:keys [db] :as cofx} [_ url]]
|
(fn [cofx [_ url]]
|
||||||
(fx/merge cofx
|
(extensions.registry/load cofx url true)))
|
||||||
{:db (assoc-in db [:extensions/manage :url :value] url)}
|
|
||||||
(extensions.registry/load url true))))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions.ui/install-button-pressed
|
:extensions.ui/install-button-pressed
|
||||||
(fn [cofx [_ data modal?]]
|
(fn [cofx [_ url data modal?]]
|
||||||
(extensions.registry/install cofx data modal?)))
|
(extensions.registry/install cofx url data modal?)))
|
||||||
|
|
||||||
;; log-level module
|
;; log-level module
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,8 @@
|
||||||
(update-hooks hook-fn extension-key))))
|
(update-hooks hook-fn extension-key))))
|
||||||
|
|
||||||
(fx/defn install
|
(fx/defn install
|
||||||
[{:keys [db] :as cofx} {:keys [hooks] :as extension-data} modal?]
|
[{:keys [db] :as cofx} url {:keys [hooks] :as extension-data} modal?]
|
||||||
(let [{:extensions/keys [manage]
|
(let [{:account/keys [account]} db
|
||||||
:account/keys [account]} db
|
|
||||||
url (get-in manage [:url :value])
|
|
||||||
extension {:id url
|
extension {:id url
|
||||||
:name (get-in extension-data ['meta :name])
|
:name (get-in extension-data ['meta :name])
|
||||||
:url url
|
:url url
|
||||||
|
@ -112,11 +110,12 @@
|
||||||
(map #(existing-hooks-for % cofx extension-data))
|
(map #(existing-hooks-for % cofx extension-data))
|
||||||
(apply set/union)))
|
(apply set/union)))
|
||||||
|
|
||||||
(fx/defn stage-extension [{:keys [db] :as cofx} extension-data modal?]
|
(fx/defn stage-extension [{:keys [db] :as cofx} url extension-data modal?]
|
||||||
(let [hooks (existing-hooks cofx extension-data)]
|
(let [hooks (existing-hooks cofx extension-data)]
|
||||||
(if (empty? hooks)
|
(if (empty? hooks)
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc db :staged-extension extension-data)}
|
{:db (assoc db :extensions/staged-extension {:url url
|
||||||
|
:extension-data extension-data})}
|
||||||
(navigation/navigate-to-cofx (if modal? :show-extension-modal :show-extension) nil))
|
(navigation/navigate-to-cofx (if modal? :show-extension-modal :show-extension) nil))
|
||||||
{:utils/show-popup {:title (i18n/label :t/error)
|
{:utils/show-popup {:title (i18n/label :t/error)
|
||||||
:content (i18n/label :t/extension-hooks-cannot-be-added
|
:content (i18n/label :t/extension-hooks-cannot-be-added
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.ui.components.icons.vector-icons :as icons]
|
[status-im.ui.components.icons.vector-icons :as icons]
|
||||||
[status-im.chat.commands.protocol :as protocol]))
|
[status-im.chat.commands.protocol :as protocol]
|
||||||
|
[status-im.extensions.core :as extensions]))
|
||||||
|
|
||||||
(defn install-extension-message [extension-id outgoing]
|
(defn install-extension-message [extension-id outgoing]
|
||||||
[react/touchable-highlight {:on-press #(re-frame/dispatch
|
[react/touchable-highlight {:on-press #(re-frame/dispatch
|
||||||
|
@ -33,7 +34,9 @@
|
||||||
(letsubs [id->command [:chats/id->command]]
|
(letsubs [id->command [:chats/id->command]]
|
||||||
(let [{:keys [type] :as command} (commands-receiving/lookup-command-by-ref command-message id->command)
|
(let [{:keys [type] :as command} (commands-receiving/lookup-command-by-ref command-message id->command)
|
||||||
extension-id (get-in command-message [:content :params :extension-id])]
|
extension-id (get-in command-message [:content :params :extension-id])]
|
||||||
(if (and platform/mobile? extension-id (or (not type) (and type (satisfies? protocol/Extension type)
|
(if (and platform/mobile? extension-id
|
||||||
|
(extensions/valid-uri? extension-id)
|
||||||
|
(or (not type) (and type (satisfies? protocol/Extension type)
|
||||||
(not= extension-id (protocol/extension-id type)))))
|
(not= extension-id (protocol/extension-id type)))))
|
||||||
;; Show install message only for mobile and if message contains extension id and there is no extension installed
|
;; Show install message only for mobile and if message contains extension id and there is no extension installed
|
||||||
;; or installed extension has differen extension id
|
;; or installed extension has differen extension id
|
||||||
|
|
|
@ -164,7 +164,8 @@
|
||||||
(spec/def ::collectibles (spec/nilable map?))
|
(spec/def ::collectibles (spec/nilable map?))
|
||||||
|
|
||||||
(spec/def ::extension-url (spec/nilable string?))
|
(spec/def ::extension-url (spec/nilable string?))
|
||||||
(spec/def ::staged-extension (spec/nilable any?))
|
(spec/def :extensions/staged-extension (spec/nilable any?))
|
||||||
|
(spec/def :extensions/manage (spec/nilable any?))
|
||||||
(spec/def ::extensions-store (spec/nilable any?))
|
(spec/def ::extensions-store (spec/nilable any?))
|
||||||
|
|
||||||
;;;;NODE
|
;;;;NODE
|
||||||
|
@ -218,6 +219,7 @@
|
||||||
:networks/networks
|
:networks/networks
|
||||||
:networks/manage
|
:networks/manage
|
||||||
:bootnodes/manage
|
:bootnodes/manage
|
||||||
|
:extensions/staged-extension
|
||||||
:extensions/manage
|
:extensions/manage
|
||||||
:node/status
|
:node/status
|
||||||
:node/restart?
|
:node/restart?
|
||||||
|
@ -321,6 +323,5 @@
|
||||||
::device-UUID
|
::device-UUID
|
||||||
::collectible
|
::collectible
|
||||||
::collectibles
|
::collectibles
|
||||||
::staged-extension
|
|
||||||
::extensions-store
|
::extensions-store
|
||||||
:registry/registry]))
|
:registry/registry]))
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions/stage
|
:extensions/stage
|
||||||
(fn [cofx [_ _ extension-data]]
|
(fn [cofx [_ url extension-data]]
|
||||||
(extensions.registry/stage-extension cofx extension-data false)))
|
(extensions.registry/stage-extension cofx url extension-data false)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions/stage-modal
|
:extensions/stage-modal
|
||||||
(fn [cofx [_ _ extension-data]]
|
(fn [cofx [_ url extension-data]]
|
||||||
(extensions.registry/stage-extension cofx extension-data true)))
|
(extensions.registry/stage-extension cofx url extension-data true)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:extensions/add-to-registry
|
:extensions/add-to-registry
|
||||||
|
|
|
@ -9,4 +9,4 @@
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:get-staged-extension
|
:get-staged-extension
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(:staged-extension db)))
|
(:extensions/staged-extension db)))
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
hooks))
|
hooks))
|
||||||
|
|
||||||
(views/defview show-extension-base [modal?]
|
(views/defview show-extension-base [modal?]
|
||||||
(views/letsubs [{:keys [data errors]} [:get-staged-extension]]
|
(views/letsubs [{:keys [extension-data url]} [:get-staged-extension]]
|
||||||
|
(let [{:keys [data errors]} extension-data]
|
||||||
(if data
|
(if data
|
||||||
[react/view styles/screen
|
[react/view styles/screen
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
|
@ -71,14 +72,14 @@
|
||||||
{:forward? true
|
{:forward? true
|
||||||
:label (i18n/label :t/install)
|
:label (i18n/label :t/install)
|
||||||
:disabled? (not (empty? errors))
|
:disabled? (not (empty? errors))
|
||||||
:on-press #(re-frame/dispatch [:extensions.ui/install-button-pressed data modal?])}]]]]
|
:on-press #(re-frame/dispatch [:extensions.ui/install-button-pressed url data modal?])}]]]]
|
||||||
[react/view styles/screen
|
[react/view styles/screen
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
[react/view {:flex 1}
|
[react/view {:flex 1}
|
||||||
[toolbar/simple-toolbar (i18n/label :t/extension)]
|
[toolbar/simple-toolbar (i18n/label :t/extension)]
|
||||||
[react/view {:style {:flex 1 :justify-content :center :align-items :center}}
|
[react/view {:style {:flex 1 :justify-content :center :align-items :center}}
|
||||||
[react/text (i18n/label :t/invalid-extension)]
|
[react/text (i18n/label :t/invalid-extension)]
|
||||||
[react/text (str errors)]]]])))
|
[react/text (str errors)]]]]))))
|
||||||
|
|
||||||
(views/defview show-extension []
|
(views/defview show-extension []
|
||||||
[show-extension-base false])
|
[show-extension-base false])
|
||||||
|
@ -118,4 +119,4 @@
|
||||||
{:forward? true
|
{:forward? true
|
||||||
:label (i18n/label :t/find)
|
:label (i18n/label :t/find)
|
||||||
:disabled? (and (not @pressed) (not (extensions/valid-uri? url)))
|
:disabled? (and (not @pressed) (not (extensions/valid-uri? url)))
|
||||||
:on-press #(do (reset! pressed true) (re-frame/dispatch [:extensions.ui/show-button-pressed (string/trim url)]))}]]]])))
|
:on-press #(do (reset! pressed true) (re-frame/dispatch [:extensions.ui/find-button-pressed (string/trim url)]))}]]]])))
|
||||||
|
|
Loading…
Reference in New Issue