Fix default draft settings; Reset draft on load

This commit is contained in:
Ryan Fox 2021-01-11 03:12:21 +00:00
parent e6a7eb4146
commit 992c032e9f
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
3 changed files with 16 additions and 10 deletions

View File

@ -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))

View File

@ -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

View File

@ -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