Merge pull request #404 from status-im/bug/#399
Short username in request header
Former-commit-id: e8aa157ea5
This commit is contained in:
commit
321935e8ca
|
@ -24,7 +24,8 @@
|
|||
[status-im.components.webview-bridge :refer [webview-bridge]]
|
||||
[status-im.i18n :refer [label]]
|
||||
[status-im.utils.datetime :as dt]
|
||||
[taoensso.timbre :as log]))
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.name :refer [shortened-name]]))
|
||||
|
||||
(defn drag-icon []
|
||||
[view st/drag-container
|
||||
|
@ -44,13 +45,14 @@
|
|||
[text {:style st/command-name}
|
||||
(str (:description command) " " (label :t/request))]
|
||||
(when added
|
||||
[text {:style st/message-info}
|
||||
(str "By " (or name chat-id) ", "
|
||||
(dt/format-date "MMM" added)
|
||||
" "
|
||||
(dt/get-ordinal-date added)
|
||||
" at "
|
||||
(dt/format-date "HH:mm" added))])])
|
||||
(let [name' (shortened-name (or name chat-id) 20)]
|
||||
[text {:style st/message-info}
|
||||
(str "By " name' ", "
|
||||
(dt/format-date "MMM" added)
|
||||
" "
|
||||
(dt/get-ordinal-date added)
|
||||
" at "
|
||||
(dt/format-date "HH:mm" added))]))])
|
||||
|
||||
(defn request-info [response-height]
|
||||
(let [layout-height (subscribe [:max-layout-height :default])
|
||||
|
|
|
@ -67,4 +67,4 @@
|
|||
[group-last-activity {:contacts @contacts
|
||||
:sync-state @sync-state}]
|
||||
[last-activity {:online-text (online-text @contact @chat-id)
|
||||
:sync-state @sync-state}])])))
|
||||
:sync-state @sync-state}])])))
|
||||
|
|
|
@ -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