From d5fcc0b0030feec13c712a77d33e1a6c20ccf561 Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Tue, 18 Sep 2018 10:13:35 +0200 Subject: [PATCH] [FIX 5813] connect to custom mailserver button fix Signed-off-by: yenda --- src/status_im/data_store/mailservers.cljs | 9 ++++++--- src/status_im/events.cljs | 5 +++++ src/status_im/mailserver/core.cljs | 4 ++-- test/cljs/status_im/test/mailserver/core.cljs | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/status_im/data_store/mailservers.cljs b/src/status_im/data_store/mailservers.cljs index 05b432d4f9..eb4ba32aa2 100644 --- a/src/status_im/data_store/mailservers.cljs +++ b/src/status_im/data_store/mailservers.cljs @@ -5,9 +5,12 @@ (re-frame/reg-cofx :data-store/get-all-mailservers (fn [cofx _] - (assoc cofx :data-store/mailservers (-> @core/account-realm - (core/get-all :mailserver) - (core/all-clj :mailserver))))) + (assoc cofx :data-store/mailservers (mapv #(-> % + (update :id keyword) + (update :fleet keyword)) + (-> @core/account-realm + (core/get-all :mailserver) + (core/all-clj :mailserver)))))) (defn save-tx "Returns tx function for saving a mailserver" diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 11664aa71f..b31a320591 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -264,6 +264,11 @@ (fn [cofx [_ _ url]] (mailserver/set-url-from-qr url cofx))) +(handlers/register-handler-fx + :mailserver.ui/connect-pressed + (fn [cofx [_ mailserver-id]] + (mailserver/show-connection-confirmation mailserver-id cofx))) + (handlers/register-handler-fx :mailserver.ui/connect-confirmed (fn [cofx [_ current-fleet mailserver-id]] diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index 2a64d5742d..f913c12426 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -48,7 +48,7 @@ (defn- build [id mailserver-name address] (assoc (address->mailserver address) - :id (keyword (string/replace id "-" "")) + :id id :name mailserver-name)) (defn connected? [id {:keys [db]}] @@ -136,7 +136,7 @@ current-fleet (fleet/current-fleet db) mailserver (build (or (:value id) - (string/replace (:random-id cofx) "-" "")) + (keyword (string/replace (:random-id cofx) "-" ""))) (:value name) (:value url)) current (connected? (:id mailserver) cofx)] diff --git a/test/cljs/status_im/test/mailserver/core.cljs b/test/cljs/status_im/test/mailserver/core.cljs index 59f8a921c7..d324954b24 100644 --- a/test/cljs/status_im/test/mailserver/core.cljs +++ b/test/cljs/status_im/test/mailserver/core.cljs @@ -232,7 +232,7 @@ (is (= 1 (count (:data-store/tx actual))))))) (testing "existing mailserver" (let [cofx {:random-id "random-id" - :db {:mailservers/manage {:id {:value "a"} + :db {:mailservers/manage {:id {:value :a} :name {:value "new-name"} :url {:value "enode://new-id:new-password@url:port"}}