-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
272 additions
and
194 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns status-im.extensions.constants) | ||
|
||
(def uri-prefix "https://get.status.im/extension/") | ||
(def link-prefix "status-im://extension/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(ns status-im.extensions.events | ||
(:require [status-im.utils.handlers :as handlers] | ||
[status-im.extensions.core :as extensions] | ||
[status-im.extensions.registry :as extensions.registry])) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.callback/qr-code-scanned | ||
(fn [cofx [_ _ url]] | ||
(extensions/set-extension-url-from-qr cofx url))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/add-extension-pressed | ||
(fn [cofx [_ extension-key]] | ||
(extensions/edit cofx extension-key))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/uninstall-extension-pressed | ||
(fn [cofx [_ extension-key]] | ||
(extensions.registry/uninstall cofx extension-key))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/input-changed | ||
(fn [cofx [_ input-key value]] | ||
(extensions/set-input cofx input-key value))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/activation-checkbox-pressed | ||
(fn [cofx [_ extension-key active?]] | ||
(extensions.registry/change-state cofx extension-key active?))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/find-button-pressed | ||
(fn [cofx [_ url]] | ||
(extensions.registry/load cofx url false))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/install-extension-button-pressed | ||
(fn [cofx [_ url]] | ||
(extensions.registry/install-from-message cofx url true))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions.ui/install-button-pressed | ||
(fn [cofx [_ url data modal?]] | ||
(extensions.registry/install cofx url data modal?))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(ns status-im.extensions.module | ||
(:require-macros [status-im.modules :as modules]) | ||
(:require status-im.extensions.ui.db | ||
[pluto.storages :as storages] | ||
[re-frame.core :as re-frame] | ||
[status-im.utils.fx :as fx] | ||
[clojure.string :as string] | ||
[status-im.extensions.constants :as constants])) | ||
|
||
(modules/defmodule extensions | ||
{:load 'status-im.extensions.registry/load | ||
:valid-uri? 'status-im.extensions.core/valid-uri? | ||
:parse-extension 'status-im.extensions.core/parse-extension | ||
:take-picture-view 'status-im.extensions.capacities.camera.views/take-picture | ||
:screen-holder-view 'status-im.extensions.capacities.views/screen-holder | ||
:extensions-settings-view 'status-im.extensions.ui.views/extensions-settings | ||
:selection-modal-screen-view 'status-im.extensions.ui.views/selection-modal-screen | ||
:edit-extension-view 'status-im.extensions.ui.add.views/edit-extension | ||
:show-extension-view 'status-im.extensions.ui.add.views/show-extension | ||
:show-extension-modal-view 'status-im.extensions.ui.add.views/show-extension-modal}) | ||
|
||
(defn load [& args] | ||
(apply (get-symbol :load) args)) | ||
|
||
(defn valid-uri? [& args] | ||
(apply (get-symbol :valid-uri?) args)) | ||
|
||
(defn parse-extension [& args] | ||
(apply (get-symbol :parse-extension) args)) | ||
|
||
(defn take-picture-view [] | ||
[(get-symbol :take-picture-view)]) | ||
|
||
(defn screen-holder-view [] | ||
[(get-symbol :screen-holder-view)]) | ||
|
||
(defn extensions-settings-view [] | ||
[(get-symbol :extensions-settings-view)]) | ||
|
||
(defn selection-modal-screen-view [] | ||
[(get-symbol :selection-modal-screen-view)]) | ||
|
||
(defn edit-extension-view [] | ||
[(get-symbol :edit-extension-view)]) | ||
|
||
(defn show-extension-view [] | ||
[(get-symbol :show-extension-view)]) | ||
|
||
(defn show-extension-modal-view [] | ||
[(get-symbol :show-extension-modal-view)]) | ||
|
||
;; Initialization | ||
;; Prevents loading of the rest of the module till it is necessary. | ||
|
||
(defn url->uri [s] | ||
(when s | ||
(-> s | ||
(string/replace constants/uri-prefix "") | ||
(string/replace constants/link-prefix "")))) | ||
|
||
(defn load-from [url f] | ||
(when-let [uri (url->uri url)] | ||
(storages/fetch uri f))) | ||
|
||
(re-frame/reg-fx | ||
:extensions/load | ||
(fn [{:keys [extensions follow-up]}] | ||
(doseq [{:keys [url active?]} extensions] | ||
(load-from url #(re-frame/dispatch [follow-up url (parse-extension % url) active?]))))) | ||
|
||
(fx/defn initialize | ||
[{{:account/keys [account] :as db} :db}] | ||
(let [{:keys [extensions dev-mode?]} account | ||
ext-vals (vals extensions)] | ||
(when dev-mode? | ||
{:db (assoc db :extensions/store (into {} (map (fn [{:keys [id data]}] {id data}) ext-vals))) | ||
:extensions/load {:extensions ext-vals | ||
:follow-up :extensions/add-to-registry}}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 3 additions & 13 deletions
16
..._im/ui/screens/extensions/add/events.cljs → src/status_im/extensions/ui/add/events.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._im/ui/screens/extensions/add/styles.cljs → src/status_im/extensions/ui/add/styles.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.