parent
bf09b87215
commit
f064c5d8d6
@ -35,6 +35,7 @@ defaultDraft =
|
|||||||
, spoilerText = Nothing
|
, spoilerText = Nothing
|
||||||
, sensitive = False
|
, sensitive = False
|
||||||
, visibility = "public"
|
, visibility = "public"
|
||||||
|
, statusLength = 0
|
||||||
, autoState = Autocomplete.empty
|
, autoState = Autocomplete.empty
|
||||||
, autoAtPosition = Nothing
|
, autoAtPosition = Nothing
|
||||||
, autoQuery = ""
|
, autoQuery = ""
|
||||||
@ -275,6 +276,7 @@ updateDraft draftMsg currentUser model =
|
|||||||
newDraft =
|
newDraft =
|
||||||
{ draft
|
{ draft
|
||||||
| status = status
|
| status = status
|
||||||
|
, statusLength = String.length status
|
||||||
, autoCursorPosition = selectionStart
|
, autoCursorPosition = selectionStart
|
||||||
, autoAtPosition = atPosition
|
, autoAtPosition = atPosition
|
||||||
, autoQuery = query
|
, autoQuery = query
|
||||||
|
@ -114,6 +114,7 @@ type alias Draft =
|
|||||||
, spoilerText : Maybe String
|
, spoilerText : Maybe String
|
||||||
, sensitive : Bool
|
, sensitive : Bool
|
||||||
, visibility : String
|
, visibility : String
|
||||||
|
, statusLength : Int
|
||||||
|
|
||||||
-- Autocomplete values
|
-- Autocomplete values
|
||||||
, autoState : Autocomplete.State
|
, autoState : Autocomplete.State
|
||||||
|
@ -12,7 +12,6 @@ import Html.Attributes exposing (..)
|
|||||||
import Mastodon.Model exposing (..)
|
import Mastodon.Model exposing (..)
|
||||||
import Types exposing (..)
|
import Types exposing (..)
|
||||||
import View.Events exposing (..)
|
import View.Events exposing (..)
|
||||||
import View.Formatter exposing (formatContent)
|
|
||||||
|
|
||||||
|
|
||||||
accountLink : Account -> Html Msg
|
accountLink : Account -> Html Msg
|
||||||
|
@ -113,9 +113,6 @@ draftReplyToView draft =
|
|||||||
draftView : Model -> Html Msg
|
draftView : Model -> Html Msg
|
||||||
draftView ({ draft, currentUser } as model) =
|
draftView ({ draft, currentUser } as model) =
|
||||||
let
|
let
|
||||||
hasSpoiler =
|
|
||||||
draft.spoilerText /= Nothing
|
|
||||||
|
|
||||||
visibilityOptionView ( visibility, description ) =
|
visibilityOptionView ( visibility, description ) =
|
||||||
option [ value visibility ]
|
option [ value visibility ]
|
||||||
[ text <| visibility ++ ": " ++ description ]
|
[ text <| visibility ++ ": " ++ description ]
|
||||||
@ -125,6 +122,17 @@ draftView ({ draft, currentUser } as model) =
|
|||||||
viewAutocompleteMenu model.draft
|
viewAutocompleteMenu model.draft
|
||||||
else
|
else
|
||||||
text ""
|
text ""
|
||||||
|
|
||||||
|
( hasSpoiler, charCount ) =
|
||||||
|
case draft.spoilerText of
|
||||||
|
Just spoilerText ->
|
||||||
|
( True, (String.length spoilerText) + draft.statusLength )
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
( False, draft.statusLength )
|
||||||
|
|
||||||
|
limitExceeded =
|
||||||
|
charCount > 500
|
||||||
in
|
in
|
||||||
div [ class "panel panel-default" ]
|
div [ class "panel panel-default" ]
|
||||||
[ div [ class "panel-heading" ]
|
[ div [ class "panel-heading" ]
|
||||||
@ -250,9 +258,19 @@ draftView ({ draft, currentUser } as model) =
|
|||||||
, onClick (DraftEvent ClearDraft)
|
, onClick (DraftEvent ClearDraft)
|
||||||
]
|
]
|
||||||
[ text "Clear" ]
|
[ text "Clear" ]
|
||||||
|
, button
|
||||||
|
[ type_ "button"
|
||||||
|
, class <|
|
||||||
|
if limitExceeded then
|
||||||
|
"btn btn-danger active"
|
||||||
|
else
|
||||||
|
"btn btn-default active"
|
||||||
|
]
|
||||||
|
[ text <| toString charCount ]
|
||||||
, button
|
, button
|
||||||
[ type_ "submit"
|
[ type_ "submit"
|
||||||
, class "btn btn-primary"
|
, class "btn btn-primary"
|
||||||
|
, disabled limitExceeded
|
||||||
]
|
]
|
||||||
[ text "Toot!" ]
|
[ text "Toot!" ]
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user