Add a logout button.

This commit is contained in:
Nicolas Perriault 2017-05-12 22:03:52 +02:00
parent 3c7584306f
commit 92b9e53b8f
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
4 changed files with 25 additions and 1 deletions

View File

@ -796,4 +796,5 @@ input.form-control[type=file] {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-left: 3px;
}

View File

@ -83,6 +83,7 @@ type Msg
| FilterNotifications NotificationFilter
| FollowAccount Int
| LoadAccount Int
| LogoutClient Client
| TimelineLoadNext String String
| MastodonEvent MastodonMsg
| NoOp

View File

@ -58,6 +58,23 @@ update msg model =
, Command.loadTimelines <| Just client
]
LogoutClient client ->
let
newClients =
List.filter (\c -> c.token /= client.token) model.clients
newClient =
List.head newClients
in
{ model
| clients = newClients
, currentView = Update.Timeline.preferred model
}
! [ Command.saveClients newClients
, Command.loadUserAccount newClient
, Command.loadTimelines newClient
]
MastodonEvent msg ->
let
( newModel, commands ) =

View File

@ -47,11 +47,16 @@ accountIdentityView currentUser client =
|> replace "/@" "@"
|> text
]
, button
[ class "btn btn-danger"
, onClick <| LogoutClient client
]
[ text "Logout" ]
, if isCurrentUser then
text ""
else
button
[ class "btn btn-default"
[ class "btn btn-primary"
, onClick <| SwitchClient client
]
[ text "Use" ]