-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9789] Add a loading indicator and button to username input of start…
… new chat
- Loading branch information
1 parent
81c4d16
commit b98f8de
Showing
11 changed files
with
141 additions
and
88 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,21 +1,13 @@ | ||
(ns status-im.ui.screens.add-new.new-chat.db | ||
(:require [status-im.utils.hex :as hex] | ||
[status-im.ethereum.ens :as ens] | ||
[status-im.utils.platform :as platform] | ||
[status-im.i18n :as i18n] | ||
[cljs.spec.alpha :as spec] | ||
[clojure.string :as string])) | ||
(:require [cljs.spec.alpha :as spec] | ||
[status-im.ethereum.ens :as ens])) | ||
|
||
(defn own-public-key? | ||
[{:keys [multiaccount]} public-key] | ||
(= (:public-key multiaccount) public-key)) | ||
|
||
(defn validate-pub-key [db public-key] | ||
(cond | ||
(or (not (spec/valid? :global/public-key public-key)) | ||
(= public-key ens/default-key)) | ||
(i18n/label (if platform/desktop? | ||
:t/use-valid-contact-code-desktop | ||
:t/use-valid-contact-code)) | ||
(own-public-key? db public-key) | ||
(i18n/label :t/can-not-add-yourself))) | ||
(or | ||
(not (spec/valid? :global/public-key public-key)) | ||
(= public-key ens/default-key) | ||
(own-public-key? db public-key))) |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
(ns status-im.ui.screens.add-new.new-chat.styles | ||
(:require [status-im.ui.components.colors :as colors])) | ||
|
||
(def error-message | ||
{:margin-horizontal 14 | ||
:margin-top 4 | ||
(def message | ||
{:margin-horizontal 16 | ||
:align-self :center | ||
:font-size 12 | ||
:color colors/red}) | ||
:color colors/gray}) | ||
|
||
(def list-title | ||
{:margin-top 24 | ||
:margin-left 16 | ||
:font-size 14 | ||
:color colors/gray}) | ||
{:margin-top 24 | ||
:margin-left 16 | ||
:font-size 14 | ||
:color colors/gray}) |
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 |
---|---|---|
@@ -1,24 +1,30 @@ | ||
(ns status-im.utils.debounce | ||
(:require [re-frame.core :as re-frame])) | ||
|
||
(def timeout (atom nil)) | ||
(def timeout (atom {})) | ||
|
||
(defn clear [event-key] | ||
(when-let [event-timeout (get @timeout event-key)] | ||
(js/clearTimeout event-timeout))) | ||
|
||
(defn clear-all [] | ||
(doseq [[_ v] @timeout] | ||
(js/clearTimeout v))) | ||
|
||
(defn debounce-and-dispatch | ||
"Dispatches event only if there were no calls of this function in period of *time* ms" | ||
[event time] | ||
(when @timeout (js/clearTimeout @timeout)) | ||
(reset! timeout (js/setTimeout #(re-frame/dispatch event) time))) | ||
(let [event-key (first event)] | ||
(clear event-key) | ||
(swap! timeout assoc event-key (js/setTimeout #(re-frame/dispatch event) time)))) | ||
|
||
(defn clear [] | ||
(when @timeout (js/clearTimeout @timeout))) | ||
|
||
(def chill? (atom false)) | ||
(def chill (atom {})) | ||
|
||
(defn dispatch-and-chill | ||
"Dispateches event and ignores next calls in period of *time* ms" | ||
[event time] | ||
(when-not @chill? | ||
(reset! chill? true) | ||
(js/setTimeout #(reset! chill? false) time) | ||
(re-frame/dispatch event))) | ||
|
||
(let [event-key (first event)] | ||
(when-not (get @chill event-key) | ||
(swap! chill assoc event-key true) | ||
(js/setTimeout #(swap! chill assoc event-key false) time) | ||
(re-frame/dispatch event)))) |
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