Fix default draft settings; Reset draft on load
This commit is contained in:
parent
e6a7eb4146
commit
992c032e9f
@ -44,6 +44,7 @@ module Command
|
||||
, search
|
||||
, notifyStatus
|
||||
, notifyNotification
|
||||
, clearDraft
|
||||
)
|
||||
|
||||
import Dom
|
||||
@ -729,3 +730,7 @@ notifyNotification notification =
|
||||
|
||||
_ ->
|
||||
Cmd.none
|
||||
|
||||
clearDraft : Cmd Msg
|
||||
clearDraft =
|
||||
Task.perform identity (Task.succeed (DraftEvent ClearDraft))
|
||||
|
@ -78,8 +78,15 @@ update : DraftMsg -> Account -> Model -> ( Model, Cmd Msg )
|
||||
update draftMsg currentUser ({ draft } as model) =
|
||||
case draftMsg of
|
||||
ClearDraft ->
|
||||
{ model | draft = empty }
|
||||
! [ Command.updateDomStatus empty.status ]
|
||||
let
|
||||
newDraft =
|
||||
{ empty
|
||||
| visibility = currentUser.source.privacy
|
||||
, sensitive = currentUser.source.sensitive
|
||||
}
|
||||
in
|
||||
{ model | draft = newDraft }
|
||||
! [ Command.updateDomStatus newDraft.status ]
|
||||
|
||||
ToggleSpoiler enabled ->
|
||||
let
|
||||
|
@ -159,7 +159,7 @@ update msg ({ accountInfo, search } as model) =
|
||||
model.clients
|
||||
in
|
||||
{ model | currentUser = Just decoded, clients = updatedClients }
|
||||
! [ Command.saveClients updatedClients ]
|
||||
! [ Command.saveClients updatedClients, Command.clearDraft ]
|
||||
|
||||
Err error ->
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
@ -249,13 +249,7 @@ update msg ({ accountInfo, search } as model) =
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
|
||||
StatusPosted _ ->
|
||||
-- FIXME: here we should rather send a ClearDraft command, and update the
|
||||
-- ClearDraft message handler to update DOM status
|
||||
let
|
||||
draft =
|
||||
Update.Draft.empty
|
||||
in
|
||||
{ model | draft = draft } ! [ Command.updateDomStatus draft.status ]
|
||||
model ! [ Command.clearDraft ]
|
||||
|
||||
StatusDeleted result ->
|
||||
case result of
|
||||
|
Loading…
Reference in New Issue
Block a user