mirror of
https://github.com/status-im/status-react.git
synced 2025-02-25 09:05:55 +00:00
Multiple hit on save should not create multiple groups
This commit is contained in:
parent
20550b42c6
commit
cdbabca9fe
@ -2,6 +2,7 @@
|
|||||||
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
||||||
(:require [status-im.components.styles :as common]
|
(:require [status-im.components.styles :as common]
|
||||||
[status-im.utils.platform :refer [platform-specific]]
|
[status-im.utils.platform :refer [platform-specific]]
|
||||||
|
[status-im.utils.utils :as u]
|
||||||
[status-im.components.react :refer [view
|
[status-im.components.react :refer [view
|
||||||
text
|
text
|
||||||
touchable-highlight]]))
|
touchable-highlight]]))
|
||||||
@ -21,9 +22,11 @@
|
|||||||
:android {:font-size 14
|
:android {:font-size 14
|
||||||
:letter-spacing 0.5}})
|
:letter-spacing 0.5}})
|
||||||
|
|
||||||
(defn sticky-button [label on-press]
|
(defn sticky-button
|
||||||
[touchable-highlight {:on-press on-press}
|
([label on-press] (sticky-button label on-press false))
|
||||||
|
([label on-press once?]
|
||||||
|
[touchable-highlight {:on-press (if once? (u/wrap-call-once! on-press) on-press)}
|
||||||
[view sticky-button-style
|
[view sticky-button-style
|
||||||
[text {:style sticky-button-label-style
|
[text {:style sticky-button-label-style
|
||||||
:uppercase? (get-in platform-specific [:uppercase?])}
|
:uppercase? (get-in platform-specific [:uppercase?])}
|
||||||
label]]])
|
label]]]))
|
@ -95,3 +95,13 @@
|
|||||||
|
|
||||||
(defn hash-tag? [s]
|
(defn hash-tag? [s]
|
||||||
(= \# (first s)))
|
(= \# (first s)))
|
||||||
|
|
||||||
|
(defn wrap-call-once!
|
||||||
|
"Returns a version of provided function that will be called only the first time wrapping function is called. Returns nil."
|
||||||
|
[f]
|
||||||
|
(let [called? (volatile! false)]
|
||||||
|
(fn [& args]
|
||||||
|
(when-not @called?
|
||||||
|
(vreset! called? true)
|
||||||
|
(apply f args)
|
||||||
|
nil))))
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
(ns status-im.test.runner
|
(ns status-im.test.runner
|
||||||
(:require [doo.runner :refer-macros [doo-tests]]
|
(:require [doo.runner :refer-macros [doo-tests]]
|
||||||
[status-im.test.chat.models.input]
|
[status-im.test.chat.models.input]
|
||||||
[status-im.test.handlers]))
|
[status-im.test.handlers]
|
||||||
|
[status-im.test.utils.utils]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
@ -12,4 +13,5 @@
|
|||||||
(set! goog.DEBUG false)
|
(set! goog.DEBUG false)
|
||||||
|
|
||||||
(doo-tests 'status-im.test.chat.models.input
|
(doo-tests 'status-im.test.chat.models.input
|
||||||
'status-im.test.handlers)
|
'status-im.test.handlers
|
||||||
|
'status-im.test.utils.utils)
|
||||||
|
12
test/cljs/status_im/test/utils/utils.cljs
Normal file
12
test/cljs/status_im/test/utils/utils.cljs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
(ns status-im.test.utils.utils
|
||||||
|
(:require [cljs.test :refer-macros [deftest is]]
|
||||||
|
[status-im.utils.utils :as u]))
|
||||||
|
|
||||||
|
(deftest wrap-as-call-once-test
|
||||||
|
(let [count (atom 0)]
|
||||||
|
(letfn [(inc-count [] (swap! count inc))]
|
||||||
|
(let [f (u/wrap-call-once! inc-count)]
|
||||||
|
(is (nil? (f)))
|
||||||
|
(is (= 1 @count))
|
||||||
|
(is (nil? (f)))
|
||||||
|
(is (= 1 @count))))))
|
Loading…
x
Reference in New Issue
Block a user