Start sign up chat

This commit is contained in:
virvar 2016-04-04 16:13:36 +03:00
parent b794b07236
commit 048be42aa8
4 changed files with 59 additions and 11 deletions

View File

@ -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)))

View File

@ -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 []

View File

@ -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

View File

@ -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})