mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-03-14 09:45:42 +00:00
parent
47adbe2813
commit
430e212a9e
3 changed files with 5 additions and 2 deletions
|
@ -145,6 +145,7 @@ struct CreateFirstProfile: View {
|
||||||
TextField("Enter your name…", text: $displayName)
|
TextField("Enter your name…", text: $displayName)
|
||||||
.focused($focusDisplayName)
|
.focused($focusDisplayName)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
.padding(.trailing, 20)
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
.background(
|
.background(
|
||||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||||
|
|
|
@ -37,7 +37,7 @@ import Data.Either (fromRight, partitionEithers, rights)
|
||||||
import Data.Foldable (foldr')
|
import Data.Foldable (foldr')
|
||||||
import Data.Functor (($>))
|
import Data.Functor (($>))
|
||||||
import Data.Int (Int64)
|
import Data.Int (Int64)
|
||||||
import Data.List (find, foldl', isSuffixOf, partition, sortOn, zipWith4)
|
import Data.List (dropWhileEnd, find, foldl', isSuffixOf, partition, sortOn, zipWith4)
|
||||||
import Data.List.NonEmpty (NonEmpty (..))
|
import Data.List.NonEmpty (NonEmpty (..))
|
||||||
import qualified Data.List.NonEmpty as L
|
import qualified Data.List.NonEmpty as L
|
||||||
import Data.Map.Strict (Map)
|
import Data.Map.Strict (Map)
|
||||||
|
@ -4334,7 +4334,7 @@ displayNameP = safeDecodeUtf8 <$> (quoted '\'' <|> takeNameTill (\c -> isSpace c
|
||||||
refChar c = c > ' ' && c /= '#' && c /= '@' && c /= '\''
|
refChar c = c > ' ' && c /= '#' && c /= '@' && c /= '\''
|
||||||
|
|
||||||
mkValidName :: String -> String
|
mkValidName :: String -> String
|
||||||
mkValidName = reverse . dropWhile isSpace . fst3 . foldl' addChar ("", '\NUL', 0 :: Int)
|
mkValidName = dropWhileEnd isSpace . take 50 . reverse . fst3 . foldl' addChar ("", '\NUL', 0 :: Int)
|
||||||
where
|
where
|
||||||
fst3 (x, _, _) = x
|
fst3 (x, _, _) = x
|
||||||
addChar (r, prev, punct) c = if validChar then (c' : r, c', punct') else (r, prev, punct)
|
addChar (r, prev, punct) c = if validChar then (c' : r, c', punct') else (r, prev, punct)
|
||||||
|
|
|
@ -38,3 +38,5 @@ testMkValidName = do
|
||||||
mkValidName "alice@example.com" `shouldBe` "alice@example.com"
|
mkValidName "alice@example.com" `shouldBe` "alice@example.com"
|
||||||
mkValidName "alice <> bob" `shouldBe` "alice <> bob"
|
mkValidName "alice <> bob" `shouldBe` "alice <> bob"
|
||||||
mkValidName "alice -> bob" `shouldBe` "alice -> bob"
|
mkValidName "alice -> bob" `shouldBe` "alice -> bob"
|
||||||
|
mkValidName "01234567890123456789012345678901234567890123456789extra" `shouldBe` "01234567890123456789012345678901234567890123456789"
|
||||||
|
mkValidName "0123456789012345678901234567890123456789012345678 extra" `shouldBe` "0123456789012345678901234567890123456789012345678"
|
||||||
|
|
Loading…
Add table
Reference in a new issue