Merge pull request #404 from status-im/bug/#399
Short username in request header
This commit is contained in:
commit
e8aa157ea5
|
@ -24,7 +24,8 @@
|
||||||
[status-im.components.webview-bridge :refer [webview-bridge]]
|
[status-im.components.webview-bridge :refer [webview-bridge]]
|
||||||
[status-im.i18n :refer [label]]
|
[status-im.i18n :refer [label]]
|
||||||
[status-im.utils.datetime :as dt]
|
[status-im.utils.datetime :as dt]
|
||||||
[taoensso.timbre :as log]))
|
[taoensso.timbre :as log]
|
||||||
|
[status-im.utils.name :refer [shortened-name]]))
|
||||||
|
|
||||||
(defn drag-icon []
|
(defn drag-icon []
|
||||||
[view st/drag-container
|
[view st/drag-container
|
||||||
|
@ -44,13 +45,14 @@
|
||||||
[text {:style st/command-name}
|
[text {:style st/command-name}
|
||||||
(str (:description command) " " (label :t/request))]
|
(str (:description command) " " (label :t/request))]
|
||||||
(when added
|
(when added
|
||||||
|
(let [name' (shortened-name (or name chat-id) 20)]
|
||||||
[text {:style st/message-info}
|
[text {:style st/message-info}
|
||||||
(str "By " (or name chat-id) ", "
|
(str "By " name' ", "
|
||||||
(dt/format-date "MMM" added)
|
(dt/format-date "MMM" added)
|
||||||
" "
|
" "
|
||||||
(dt/get-ordinal-date added)
|
(dt/get-ordinal-date added)
|
||||||
" at "
|
" at "
|
||||||
(dt/format-date "HH:mm" added))])])
|
(dt/format-date "HH:mm" added))]))])
|
||||||
|
|
||||||
(defn request-info [response-height]
|
(defn request-info [response-height]
|
||||||
(let [layout-height (subscribe [:max-layout-height :default])
|
(let [layout-height (subscribe [:max-layout-height :default])
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
(ns status-im.utils.name
|
||||||
|
(:require [clojure.string :as str]))
|
||||||
|
|
||||||
|
(defn too-long? [name max-len]
|
||||||
|
(> (count name) max-len))
|
||||||
|
|
||||||
|
(defn max-name
|
||||||
|
[name max-len]
|
||||||
|
(let [names (str/split name " ")]
|
||||||
|
(first
|
||||||
|
(reduce (fn [[name done] next-name]
|
||||||
|
(if done
|
||||||
|
name
|
||||||
|
(let [new-name (str/join " " [name next-name])]
|
||||||
|
(if (too-long? new-name max-len)
|
||||||
|
(let [new-name' (str name " " (first next-name) ".")]
|
||||||
|
(if (too-long? new-name' max-len)
|
||||||
|
[name true]
|
||||||
|
[new-name' true]))
|
||||||
|
[new-name]))))
|
||||||
|
[(first names)]
|
||||||
|
(rest names)))))
|
||||||
|
|
||||||
|
(defn shortened-name [name max-len]
|
||||||
|
(if (> (count name) max-len)
|
||||||
|
(let [name' (max-name name max-len)]
|
||||||
|
(if (too-long? name' max-len)
|
||||||
|
(str (str/trim (subs name 0 max-len)) "...")
|
||||||
|
name'))
|
||||||
|
name))
|
Loading…
Reference in New Issue