Skip to content

Commit eb8557d

Browse files
committed
Introduced onboarding sign in
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
1 parent 8b1288e commit eb8557d

76 files changed

Lines changed: 1226 additions & 1000 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

resources/icons/logo.svg

Lines changed: 5 additions & 0 deletions
Loading
5.87 KB
Loading
29.4 KB
Loading

resources/js/bots/console/bot.js

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -570,66 +570,6 @@ status.command({
570570
}
571571
});
572572

573-
status.response({
574-
name: "password",
575-
color: "#7099e6",
576-
scope: ["personal-chats", "anonymous", "dapps"],
577-
description: I18n.t('password_description'),
578-
icon: "lock_white",
579-
sequentialParams: true,
580-
params: [
581-
{
582-
name: "password",
583-
type: status.types.PASSWORD,
584-
placeholder: I18n.t('password_placeholder'),
585-
hidden: true
586-
},
587-
{
588-
name: "password-confirmation",
589-
type: status.types.PASSWORD,
590-
placeholder: I18n.t('password_placeholder2'),
591-
hidden: true
592-
}
593-
],
594-
validator: function (params, context) {
595-
if (!params.hasOwnProperty("password-confirmation") || params["password-confirmation"].length === 0) {
596-
if (params.password === null || params.password.length < 6) {
597-
var error = status.components.validationMessage(
598-
I18n.t('password_validation_title'),
599-
I18n.t('password_error')
600-
);
601-
return {markup: error};
602-
}
603-
} else {
604-
if (params.password !== params["password-confirmation"]) {
605-
var error = status.components.validationMessage(
606-
I18n.t('password_validation_title'),
607-
I18n.t('password_error1')
608-
);
609-
return {markup: error};
610-
}
611-
}
612-
613-
},
614-
preview: function (params, context) {
615-
var style = {
616-
marginTop: 5,
617-
marginHorizontal: 0,
618-
fontSize: 14,
619-
color: "black"
620-
};
621-
622-
if (context.platform == "ios") {
623-
style.fontSize = 8;
624-
style.marginTop = 10;
625-
style.marginBottom = 2;
626-
style.letterSpacing = 1;
627-
}
628-
629-
return {markup: status.components.text({style: style}, "●●●●●●●●●●")};
630-
}
631-
});
632-
633573
status.response({
634574
name: "grant-permissions",
635575
scope: ["personal-chats", "anonymous", "registered", "dapps"],

src/status_im/android/core.cljs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
;; this listener and handle application's closing
2323
;; in handlers
2424
(let [stack (subscribe [:get :navigation-stack])
25-
creating? (subscribe [:get :accounts/creating-account?])
2625
result-box (subscribe [:get-current-chat-ui-prop :result-box])
2726
webview (subscribe [:get :webview-bridge])]
2827
(cond
29-
@creating? true
3028

3129
(and @webview (:can-go-back? @result-box))
3230
(do (.goBack @webview) true)

src/status_im/chat/console.cljs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require [status-im.ui.components.styles :refer [default-chat-color]]
33
[status-im.utils.random :as random]
44
[status-im.constants :as const]
5-
[status-im.chat.constants :as chat-const]
65
[status-im.i18n :as i18n]
76
[clojure.string :as string]))
87

@@ -16,51 +15,6 @@
1615
:content content
1716
:content-type content-type})
1817

19-
(def shake-your-phone-message
20-
(console-message {:content (i18n/label :t/shake-your-phone)
21-
:content-type const/text-content-type}))
22-
23-
(def account-generation-message
24-
(console-message {:message-id chat-const/crazy-math-message-id
25-
:content (i18n/label :t/account-generation-message)
26-
:content-type const/text-content-type}))
27-
28-
(def move-to-internal-failure-message
29-
(console-message {:message-id chat-const/move-to-internal-failure-message-id
30-
:content {:command "grant-permissions"
31-
:content (i18n/label :t/move-to-internal-failure-message)}
32-
:content-type const/content-type-command-request}))
33-
34-
(defn passphrase-messages [mnemonic signing-phrase crazy-math-message?]
35-
[(console-message {:message-id chat-const/passphrase-message-id
36-
:content (if crazy-math-message?
37-
(i18n/label :t/phew-here-is-your-passphrase)
38-
(i18n/label :t/here-is-your-passphrase))
39-
:content-type const/text-content-type})
40-
41-
(console-message {:message-id (random/id)
42-
:content mnemonic
43-
:content-type const/text-content-type})
44-
45-
(console-message {:message-id chat-const/signing-phrase-message-id
46-
:content (i18n/label :t/here-is-your-signing-phrase)
47-
:content-type const/text-content-type})
48-
49-
(console-message {:message-id (random/id)
50-
:content signing-phrase
51-
:content-type const/text-content-type})])
52-
53-
(def intro-status-message
54-
(console-message {:message-id chat-const/intro-status-message-id
55-
:content (i18n/label :t/intro-status)
56-
:content-type const/content-type-status}))
57-
58-
(def intro-message1
59-
(console-message {:message-id chat-const/intro-message1-id
60-
:content {:command "password"
61-
:content (i18n/label :t/intro-message1)}
62-
:content-type const/content-type-command-request}))
63-
6418
(def chat
6519
{:chat-id const/console-chat-id
6620
:name (string/capitalize const/console-chat-id)

src/status_im/chat/constants.cljs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@
55
(def arg-wrapping-char "\"")
66

77
(def input-height 56)
8-
(def max-input-height 66)
98
(def input-spacing-top 16)
109

1110
(def console-chat-id "console")
12-
(def crazy-math-message-id "crazy-math-message")
13-
(def move-to-internal-failure-message-id "move-to-internal-failure-message")
14-
(def passphrase-message-id "passphraze-message")
15-
(def signing-phrase-message-id "signing-phrase-message")
16-
(def intro-status-message-id "intro-status")
17-
(def intro-message1-id "intro-message1")
1811

1912
;; TODO(janherich): figure out something better then this
2013
(def send-command-ref ["transactor" :command 83 "send"])
2114
(def request-command-ref ["transactor" :command 83 "request"])
22-
(def phone-command-ref ["console" :command 50 "phone"])

src/status_im/chat/events.cljs

Lines changed: 48 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
[status-im.protocol.core :as protocol]
88
[status-im.chat.models :as models]
99
[status-im.chat.console :as console]
10-
[status-im.chat.constants :as chat.constants]
1110
[status-im.data-store.chats :as chats]
1211
[status-im.data-store.messages :as messages]
1312
[status-im.data-store.pending-messages :as pending-messages]
@@ -29,7 +28,7 @@
2928
:stored-unviewed-messages
3029
(fn [cofx _]
3130
(assoc cofx :stored-unviewed-messages
32-
(messages/get-unviewed (-> cofx :db :current-public-key)))))
31+
(messages/get-unviewed (-> cofx :db :current-public-key)))))
3332

3433
(re-frame/reg-cofx
3534
:get-stored-message
@@ -129,7 +128,7 @@
129128
[re-frame/trim-v]
130129
(fn [db [details]]
131130
(models/set-chat-ui-props db {:show-bottom-info? true
132-
:bottom-info details})))
131+
:bottom-info details})))
133132

134133
(def index-messages (partial into {} (map (juxt :message-id identity))))
135134

@@ -153,18 +152,15 @@
153152
(update-in db [:chats chat-id :messages message-id] assoc :appearing? false)))
154153

155154
(defn init-console-chat
156-
[{:keys [chats] :accounts/keys [current-account-id] :as db}]
155+
[{:keys [chats] :as db}]
157156
(if (chats constants/console-chat-id)
158157
{:db db}
159-
(cond-> {:db (-> db
160-
(assoc :current-chat-id constants/console-chat-id)
161-
(update :chats assoc constants/console-chat-id console/chat))
162-
:dispatch-n [[:add-contacts [console/contact]]]
163-
:save-chat console/chat
164-
:save-all-contacts [console/contact]}
165-
166-
(not current-account-id)
167-
(update :dispatch-n concat [[:chat-received-message/add-when-commands-loaded console/intro-message1]]))))
158+
{:db (-> db
159+
(assoc :current-chat-id constants/console-chat-id)
160+
(update :chats assoc constants/console-chat-id console/chat))
161+
:dispatch [:add-contacts [console/contact]]
162+
:save-chat console/chat
163+
:save-all-contacts [console/contact]}))
168164

169165
(handlers/register-handler-fx
170166
:init-console-chat
@@ -186,31 +182,26 @@
186182
get-stored-messages
187183
stored-unviewed-messages
188184
stored-message-ids]} _]
189-
(let [{:accounts/keys [account-creation?]} db
190-
load-default-contacts-event [:load-default-contacts!]]
191-
(if account-creation?
192-
{:db db
193-
:dispatch load-default-contacts-event}
194-
(let [chat->message-id->request (reduce (fn [acc {:keys [chat-id message-id] :as request}]
195-
(assoc-in acc [chat-id message-id] request))
196-
{}
197-
stored-unanswered-requests)
198-
chats (reduce (fn [acc {:keys [chat-id] :as chat}]
199-
(let [chat-messages (index-messages (get-stored-messages chat-id))]
200-
(assoc acc chat-id
185+
(let [chat->message-id->request (reduce (fn [acc {:keys [chat-id message-id] :as request}]
186+
(assoc-in acc [chat-id message-id] request))
187+
{}
188+
stored-unanswered-requests)
189+
chats (reduce (fn [acc {:keys [chat-id] :as chat}]
190+
(let [chat-messages (index-messages (get-stored-messages chat-id))]
191+
(assoc acc chat-id
201192
(assoc chat
202-
:unviewed-messages (get stored-unviewed-messages chat-id)
203-
:requests (get chat->message-id->request chat-id)
204-
:messages chat-messages
205-
:not-loaded-message-ids (set/difference (get stored-message-ids chat-id)
206-
(-> chat-messages keys set))))))
207-
{}
208-
all-stored-chats)]
209-
(-> db
210-
(assoc :chats chats
211-
:deleted-chats inactive-chat-ids)
212-
init-console-chat
213-
(update :dispatch-n conj load-default-contacts-event)))))))
193+
:unviewed-messages (get stored-unviewed-messages chat-id)
194+
:requests (get chat->message-id->request chat-id)
195+
:messages chat-messages
196+
:not-loaded-message-ids (set/difference (get stored-message-ids chat-id)
197+
(-> chat-messages keys set))))))
198+
{}
199+
all-stored-chats)]
200+
(-> db
201+
(assoc :chats chats
202+
:deleted-chats inactive-chat-ids)
203+
init-console-chat
204+
(update :dispatch-n conj [:load-default-contacts!])))))
214205

215206
(handlers/register-handler-fx
216207
:send-seen!
@@ -219,40 +210,18 @@
219210
(let [{:keys [web3 chats] :contacts/keys [contacts]} db
220211
{:keys [group-chat public? messages]} (get chats chat-id)
221212
statuses (assoc (get-in messages [message-id :user-statuses]) me :seen)]
222-
(cond-> {:db (-> db
223-
(update-in [:chats chat-id :unviewed-messages] disj message-id)
224-
(assoc-in [:chats chat-id :messages message-id :user-statuses] statuses))
213+
(cond-> {:db (-> db
214+
(update-in [:chats chat-id :unviewed-messages] disj message-id)
215+
(assoc-in [:chats chat-id :messages message-id :user-statuses] statuses))
225216
:update-message {:message-id message-id
226217
:user-statuses statuses}}
227-
;; for public chats and 1-1 bot/dapp chats, it makes no sense to signalise `:seen` msg
228-
(not (or public? (get-in contacts [chat-id :dapp?])))
229-
(assoc :protocol-send-seen {:web3 web3
230-
:message (cond-> {:from me
231-
:to from
232-
:message-id message-id}
233-
group-chat (assoc :group-id chat-id))})))))
234-
235-
(handlers/register-handler-fx
236-
:show-mnemonic
237-
[re-frame/trim-v]
238-
(fn [{:keys [db]} [mnemonic signing-phrase]]
239-
(let [crazy-math-message? (contains? (get-in db [:chats chat.constants/console-chat-id]) chat.constants/crazy-math-message-id)
240-
messages-events (->> (console/passphrase-messages mnemonic signing-phrase crazy-math-message?)
241-
(mapv #(vector :chat-received-message/add %)))]
242-
{:dispatch-n messages-events})))
243-
244-
;; TODO(alwx): can be simplified
245-
(handlers/register-handler-fx
246-
:account-generation-message
247-
(fn [{:keys [db]} _]
248-
(when-not (contains? (get-in db [:chats chat.constants/console-chat-id]) chat.constants/passphrase-message-id)
249-
{:dispatch [:chat-received-message/add console/account-generation-message]})))
250-
251-
(handlers/register-handler-fx
252-
:move-to-internal-failure-message
253-
(fn [{:keys [db]} _]
254-
(when-not (contains? (get-in db [:chats chat.constants/console-chat-id]) chat.constants/move-to-internal-failure-message-id)
255-
{:dispatch [:chat-received-message/add console/move-to-internal-failure-message]})))
218+
;; for public chats and 1-1 bot/dapp chats, it makes no sense to signalise `:seen` msg
219+
(not (or public? (get-in contacts [chat-id :dapp?])))
220+
(assoc :protocol-send-seen {:web3 web3
221+
:message (cond-> {:from me
222+
:to from
223+
:message-id message-id}
224+
group-chat (assoc :group-id chat-id))})))))
256225

257226
(handlers/register-handler-fx
258227
:browse-link-from-message
@@ -269,16 +238,16 @@
269238
(models/set-chat-ui-props {:validation-messages nil})
270239
(update-in [:chats chat-id] dissoc :chat-loaded-event))}
271240

272-
chat-loaded-event
273-
(assoc :dispatch chat-loaded-event))))
241+
chat-loaded-event
242+
(assoc :dispatch chat-loaded-event))))
274243

275244
(handlers/register-handler-fx
276245
:add-chat-loaded-event
277246
[(re-frame/inject-cofx :get-stored-chat) re-frame/trim-v]
278247
(fn [{:keys [db] :as cofx} [chat-id event]]
279248
(if (get (:chats db) chat-id)
280249
{:db (assoc-in db [:chats chat-id :chat-loaded-event] event)}
281-
(-> (models/add-chat cofx chat-id) ; chat not created yet, we have to create it
250+
(-> (models/add-chat cofx chat-id) ; chat not created yet, we have to create it
282251
(assoc-in [:db :chats chat-id :chat-loaded-event] event)))))
283252

284253
;; TODO(janherich): remove this unnecessary event in the future (only model function `add-chat` will stay)
@@ -309,7 +278,7 @@
309278
:start-chat
310279
[(re-frame/inject-cofx :get-stored-chat) re-frame/trim-v]
311280
(fn [{:keys [db] :as cofx} [contact-id {:keys [navigation-replace?]}]]
312-
(when (not= (:current-public-key db) contact-id) ; don't allow to open chat with yourself
281+
(when (not= (:current-public-key db) contact-id) ; don't allow to open chat with yourself
313282
(if (get (:chats db) contact-id)
314283
(navigate-to-chat cofx contact-id navigation-replace?) ; existing chat, just preload and displey
315284
(let [add-chat-fx (models/add-chat cofx contact-id)] ; new chat, create before preload & display
@@ -334,12 +303,12 @@
334303
(update :chats dissoc chat-id)
335304
(update :deleted-chats (fnil conj #{}) chat-id))
336305
:delete-pending-messages chat-id}
337-
(or group-chat debug?)
338-
(assoc :delete-messages chat-id)
339-
debug?
340-
(assoc :delete-chat chat-id)
341-
(not debug?)
342-
(assoc :deactivate-chat chat-id)))))
306+
(or group-chat debug?)
307+
(assoc :delete-messages chat-id)
308+
debug?
309+
(assoc :delete-chat chat-id)
310+
(not debug?)
311+
(assoc :deactivate-chat chat-id)))))
343312

344313
(handlers/register-handler-fx
345314
:delete-chat

0 commit comments

Comments
 (0)