Confirm when unregistering an account.
This commit is contained in:
parent
92b9e53b8f
commit
8681a926dc
@ -31,5 +31,6 @@ init { registration, clients } location =
|
||||
, currentView = LocalTimelineView
|
||||
, currentUser = Nothing
|
||||
, notificationFilter = NotificationAll
|
||||
, confirm = Nothing
|
||||
}
|
||||
! [ Command.initCommands registration (List.head clients) (Util.extractAuthCode location) ]
|
||||
|
@ -74,10 +74,13 @@ type WebSocketMsg
|
||||
|
||||
type Msg
|
||||
= AddFavorite Int
|
||||
| AskConfirm String Msg Msg
|
||||
| ClearError Int
|
||||
| CloseAccount
|
||||
| CloseAccountSelector
|
||||
| CloseThread
|
||||
| ConfirmCancelled Msg
|
||||
| Confirmed Msg
|
||||
| DeleteStatus Int
|
||||
| DraftEvent DraftMsg
|
||||
| FilterNotifications NotificationFilter
|
||||
@ -108,6 +111,13 @@ type Msg
|
||||
| WebSocketEvent WebSocketMsg
|
||||
|
||||
|
||||
type alias Confirm =
|
||||
{ message : String
|
||||
, onConfirm : Msg
|
||||
, onCancel : Msg
|
||||
}
|
||||
|
||||
|
||||
type CurrentView
|
||||
= -- Basically, what we should be displaying in the fourth column
|
||||
AccountFollowersView Account (Timeline Account)
|
||||
@ -201,6 +211,7 @@ type alias Model =
|
||||
, currentUser : Maybe Account
|
||||
, currentView : CurrentView
|
||||
, notificationFilter : NotificationFilter
|
||||
, confirm : Maybe Confirm
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,15 @@ update msg model =
|
||||
ClearError index ->
|
||||
{ model | errors = removeAt index model.errors } ! []
|
||||
|
||||
AskConfirm message onClick onCancel ->
|
||||
{ model | confirm = Just <| Confirm message onClick onCancel } ! []
|
||||
|
||||
ConfirmCancelled onCancel ->
|
||||
update onCancel { model | confirm = Nothing }
|
||||
|
||||
Confirmed onConfirm ->
|
||||
update onConfirm { model | confirm = Nothing }
|
||||
|
||||
SwitchClient client ->
|
||||
let
|
||||
newClients =
|
||||
|
@ -49,7 +49,16 @@ accountIdentityView currentUser client =
|
||||
]
|
||||
, button
|
||||
[ class "btn btn-danger"
|
||||
, onClick <| LogoutClient client
|
||||
, onClick <|
|
||||
AskConfirm
|
||||
"""
|
||||
Are you sure you want to unregister this account
|
||||
with Tooty? Note that you'll probably want to
|
||||
revoke the application in the official Web client
|
||||
on the related instance.
|
||||
"""
|
||||
(LogoutClient client)
|
||||
NoOp
|
||||
]
|
||||
[ text "Logout" ]
|
||||
, if isCurrentUser then
|
||||
|
@ -155,4 +155,10 @@ view model =
|
||||
|
||||
Nothing ->
|
||||
text ""
|
||||
, case model.confirm of
|
||||
Nothing ->
|
||||
text ""
|
||||
|
||||
Just confirm ->
|
||||
Common.confirmView confirm
|
||||
]
|
||||
|
@ -7,10 +7,12 @@ module View.Common
|
||||
, icon
|
||||
, justifiedButtonGroup
|
||||
, loadMoreBtn
|
||||
, confirmView
|
||||
)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
import Mastodon.Http exposing (Links)
|
||||
import Mastodon.Model exposing (..)
|
||||
import Types exposing (..)
|
||||
@ -105,3 +107,30 @@ loadMoreBtn { id, links, loading } =
|
||||
|
||||
Nothing ->
|
||||
text ""
|
||||
|
||||
|
||||
confirmView : Confirm -> Html Msg
|
||||
confirmView { message, onConfirm, onCancel } =
|
||||
div []
|
||||
[ div [ class "modal-backdrop" ] []
|
||||
, div
|
||||
[ class "modal fade in", style [ ( "display", "block" ) ], tabindex -1 ]
|
||||
[ div
|
||||
[ class "modal-dialog" ]
|
||||
[ div
|
||||
[ class "modal-content" ]
|
||||
[ div [ class "modal-header" ] [ h4 [] [ text "Confirmation required" ] ]
|
||||
, div [ class "modal-body" ] [ p [] [ text message ] ]
|
||||
, div
|
||||
[ class "modal-footer" ]
|
||||
[ button
|
||||
[ type_ "button", class "btn btn-default", onClick (ConfirmCancelled onCancel) ]
|
||||
[ text "Cancel" ]
|
||||
, button
|
||||
[ type_ "button", class "btn btn-primary", onClick (Confirmed onConfirm) ]
|
||||
[ text "OK" ]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user