diff --git a/syng-im/src/syng_im/android/core.cljs b/syng-im/src/syng_im/android/core.cljs index 3430b4aca9..1cd03b3b51 100644 --- a/syng-im/src/syng_im/android/core.cljs +++ b/syng-im/src/syng_im/android/core.cljs @@ -52,4 +52,5 @@ (dispatch [:initialize-protocol]) (dispatch [:load-user-phone-number]) (dispatch [:load-syng-contacts]) + (dispatch [:set-sign-up-chat]) (.registerComponent app-registry "SyngIm" #(r/reactify-component app-root))) diff --git a/syng-im/src/syng_im/components/chat/plain_message_input.cljs b/syng-im/src/syng_im/components/chat/plain_message_input.cljs index 3a3d170c7c..aa53427c30 100644 --- a/syng-im/src/syng_im/components/chat/plain_message_input.cljs +++ b/syng-im/src/syng_im/components/chat/plain_message_input.cljs @@ -11,7 +11,7 @@ [reagent.core :as r])) (defn plain-message-input-view [] - (let [text (r/atom "!") + (let [text (r/atom "") chat-id (subscribe [:get-current-chat-id])] (dispatch [:generate-suggestions @text]) (fn [] diff --git a/syng-im/src/syng_im/handlers.cljs b/syng-im/src/syng_im/handlers.cljs index 8c2f38f1a5..333777e1ac 100644 --- a/syng-im/src/syng_im/handlers.cljs +++ b/syng-im/src/syng_im/handlers.cljs @@ -16,6 +16,7 @@ [syng-im.handlers.contacts :as contacts-service] [syng-im.handlers.suggestions :as suggestions-service] [syng-im.handlers.commands :as commands-service] + [syng-im.handlers.sign-up :as sign-up-service] [syng-im.models.chats :refer [create-chat]] [syng-im.models.chat :refer [signal-chat-updated @@ -87,16 +88,18 @@ (register-handler :send-chat-msg (fn [db [action chat-id text]] (log/debug action "chat-id" chat-id "text" text) - (let [{msg-id :msg-id - {from :from - to :to} :msg} (api/send-user-msg {:to chat-id - :content text}) - msg {:msg-id msg-id - :from from - :to to - :content text - :content-type text-content-type - :outgoing true}] + (let [msg (if (= chat-id "console") + (sign-up-service/send-console-msg text) + (let [{msg-id :msg-id + {from :from + to :to} :msg} (api/send-user-msg {:to chat-id + :content text})] + {:msg-id msg-id + :from from + :to to + :content text + :content-type text-content-type + :outgoing true}))] (save-message chat-id msg) (signal-chat-updated db chat-id)))) @@ -146,6 +149,12 @@ (nav-push navigator {:view-id :chat}) (set-current-chat-id db chat-id))) +(register-handler :set-sign-up-chat + (fn [db [_]] + (-> db + (set-current-chat-id "console") + sign-up-service/intro))) + ;; -- Chat -------------------------------------------------------------- (register-handler :generate-suggestions diff --git a/syng-im/src/syng_im/handlers/sign_up.cljs b/syng-im/src/syng_im/handlers/sign_up.cljs new file mode 100644 index 0000000000..6e4f2e9269 --- /dev/null +++ b/syng-im/src/syng_im/handlers/sign_up.cljs @@ -0,0 +1,38 @@ +(ns syng-im.handlers.sign-up + (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] + [syng-im.db :as db] + ;; [syng-im.models.commands :refer [commands suggestions]] + [syng-im.utils.utils :refer [log on-error http-post toast]] + [syng-im.utils.logging :as log] + [syng-im.utils.random :as random] + [syng-im.constants :refer [text-content-type]])) + +(defn intro [db] + (dispatch [:received-msg {:msg-id "1" + :content "Hello there! It's Syng, a Dapp browser in your phone." + :content-type text-content-type + :outgoing false + :from "console" + :to "me"}]) + (dispatch [:received-msg {:msg-id "2" + :content "Syng uses a highly secure key-pair authentication type to provide you a reliable way to access your account" + :content-type text-content-type + :outgoing false + :from "console" + :to "me"}]) + (dispatch [:received-msg {:msg-id "3" + :content "A key pair has been generated and saved to your device. Create a password to secure your key" + :content-type text-content-type + :outgoing false + :from "console" + :to "me"}]) + (dispatch [:set-input-command :keypair-password]) + db) + +(defn send-console-msg [text] + {:msg-id (random/id) + :from "me" + :to "console" + :content text + :content-type text-content-type + :outgoing true})