2017-05-07 08:31:51 -04:00
|
|
|
module Update.Mastodon exposing (update)
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Navigation
|
2017-11-29 08:06:08 -05:00
|
|
|
import Mastodon.Helper exposing (extractStatusId)
|
2017-05-07 08:31:51 -04:00
|
|
|
import Mastodon.Model exposing (..)
|
|
|
|
import Task
|
|
|
|
import Types exposing (..)
|
|
|
|
import Update.Draft
|
|
|
|
import Update.Error exposing (..)
|
|
|
|
import Update.Timeline
|
|
|
|
|
|
|
|
|
|
|
|
errorText : Error -> String
|
|
|
|
errorText error =
|
|
|
|
case error of
|
|
|
|
MastodonError statusCode statusMsg errorMsg ->
|
|
|
|
"HTTP " ++ (toString statusCode) ++ " " ++ statusMsg ++ ": " ++ errorMsg
|
|
|
|
|
|
|
|
ServerError statusCode statusMsg errorMsg ->
|
|
|
|
"HTTP " ++ (toString statusCode) ++ " " ++ statusMsg ++ ": " ++ errorMsg
|
|
|
|
|
|
|
|
TimeoutError ->
|
|
|
|
"Request timed out."
|
|
|
|
|
|
|
|
NetworkError ->
|
|
|
|
"Unreachable host."
|
|
|
|
|
|
|
|
|
|
|
|
update : MastodonMsg -> Model -> ( Model, Cmd Msg )
|
2017-05-30 18:27:30 -04:00
|
|
|
update msg ({ accountInfo, search } as model) =
|
2017-05-07 08:31:51 -04:00
|
|
|
case msg of
|
|
|
|
AccessToken result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
let
|
|
|
|
client =
|
2017-05-09 12:43:12 -04:00
|
|
|
Client decoded.server decoded.accessToken Nothing
|
2017-05-07 08:31:51 -04:00
|
|
|
in
|
2017-05-09 12:43:12 -04:00
|
|
|
{ model | clients = client :: model.clients }
|
2017-05-30 02:57:52 -04:00
|
|
|
! [ Command.saveClients <| client :: model.clients
|
|
|
|
, Navigation.load <| model.location.origin ++ model.location.pathname
|
2017-05-07 08:31:51 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-25 04:25:43 -04:00
|
|
|
AccountFollowed _ result ->
|
2017-05-07 08:31:51 -04:00
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-25 17:07:17 -04:00
|
|
|
processFollowEvent decoded model ! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-25 04:25:43 -04:00
|
|
|
AccountUnfollowed account result ->
|
2017-05-07 08:31:51 -04:00
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-25 04:25:43 -04:00
|
|
|
processUnfollowEvent account decoded model ! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-25 17:07:17 -04:00
|
|
|
AccountMuted account result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
processMuteEvent account decoded model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountUnmuted account result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
processMuteEvent account decoded model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountBlocked account result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
processBlockEvent account decoded model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountUnblocked account result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
processBlockEvent account decoded model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-07 08:31:51 -04:00
|
|
|
AppRegistered result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
{ model | registration = Just decoded }
|
|
|
|
! [ Command.saveRegistration decoded
|
|
|
|
, Command.navigateToAuthUrl decoded
|
|
|
|
]
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-29 10:28:01 -04:00
|
|
|
ThreadStatusLoaded id result ->
|
2017-05-07 08:31:51 -04:00
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model
|
|
|
|
| currentView =
|
|
|
|
case model.currentView of
|
|
|
|
ThreadView thread ->
|
|
|
|
ThreadView { thread | status = Just decoded }
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
model.currentView
|
|
|
|
}
|
2017-11-29 08:06:08 -05:00
|
|
|
! [ Command.scrollToThreadStatus <| extractStatusId id ]
|
2017-05-29 10:28:01 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model
|
|
|
|
| currentView = LocalTimelineView
|
|
|
|
, errors = addErrorNotification (errorText error) model
|
|
|
|
}
|
|
|
|
! []
|
|
|
|
|
|
|
|
ThreadContextLoaded id result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
{ model
|
|
|
|
| currentView =
|
|
|
|
case model.currentView of
|
|
|
|
ThreadView thread ->
|
|
|
|
ThreadView { thread | context = Just decoded }
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
model.currentView
|
|
|
|
}
|
2017-11-29 08:06:08 -05:00
|
|
|
! [ Command.scrollToThreadStatus <| extractStatusId id ]
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model
|
2017-05-13 09:55:46 -04:00
|
|
|
| currentView = LocalTimelineView
|
2017-05-07 08:31:51 -04:00
|
|
|
, errors = addErrorNotification (errorText error) model
|
|
|
|
}
|
|
|
|
! []
|
|
|
|
|
|
|
|
CurrentUser result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-09 12:43:12 -04:00
|
|
|
let
|
|
|
|
updatedClients =
|
|
|
|
case model.clients of
|
|
|
|
client :: xs ->
|
|
|
|
({ client | account = Just decoded }) :: xs
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
model.clients
|
|
|
|
in
|
|
|
|
{ model | currentUser = Just decoded, clients = updatedClients }
|
2021-01-10 22:12:21 -05:00
|
|
|
! [ Command.saveClients updatedClients, Command.clearDraft ]
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
FavoriteAdded result ->
|
|
|
|
case result of
|
|
|
|
Ok _ ->
|
|
|
|
model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
FavoriteRemoved result ->
|
|
|
|
case result of
|
|
|
|
Ok _ ->
|
|
|
|
model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-27 03:32:15 -04:00
|
|
|
HashtagTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | hashtagTimeline = Update.Timeline.update append decoded links model.hashtagTimeline } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-07 08:31:51 -04:00
|
|
|
LocalTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | localTimeline = Update.Timeline.update append decoded links model.localTimeline } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
Notifications append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
let
|
|
|
|
aggregated =
|
|
|
|
Mastodon.Helper.aggregateNotifications decoded
|
|
|
|
in
|
|
|
|
{ model | notifications = Update.Timeline.update append aggregated links model.notifications } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
GlobalTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | globalTimeline = Update.Timeline.update append decoded links model.globalTimeline } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-13 09:55:46 -04:00
|
|
|
FavoriteTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | favoriteTimeline = Update.Timeline.update append decoded links model.favoriteTimeline } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-25 17:07:17 -04:00
|
|
|
Mutes append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | mutes = Update.Timeline.update append decoded links model.mutes } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
Blocks append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | blocks = Update.Timeline.update append decoded links model.blocks } ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-07 08:31:51 -04:00
|
|
|
Reblogged result ->
|
|
|
|
case result of
|
|
|
|
Ok _ ->
|
|
|
|
model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
StatusPosted _ ->
|
2021-01-10 22:12:21 -05:00
|
|
|
model ! [ Command.clearDraft ]
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
StatusDeleted result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
Update.Timeline.deleteStatusFromAllTimelines decoded model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
Unreblogged result ->
|
|
|
|
case result of
|
|
|
|
Ok _ ->
|
|
|
|
model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountReceived result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model | accountInfo = { accountInfo | account = Just decoded, relationships = [] } } ! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
AccountTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model
|
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| timeline = Update.Timeline.update append decoded links accountInfo.timeline
|
|
|
|
}
|
|
|
|
}
|
|
|
|
! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-08 06:22:20 -04:00
|
|
|
AccountFollowers append result ->
|
2017-05-07 08:31:51 -04:00
|
|
|
case result of
|
2017-05-08 06:22:20 -04:00
|
|
|
Ok { decoded, links } ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model
|
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| followers = Update.Timeline.update append decoded links accountInfo.followers
|
|
|
|
}
|
|
|
|
}
|
2017-05-09 12:43:12 -04:00
|
|
|
! [ Command.loadRelationships (List.head model.clients) <| List.map .id decoded ]
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
2017-05-08 06:22:20 -04:00
|
|
|
AccountFollowing append result ->
|
2017-05-07 08:31:51 -04:00
|
|
|
case result of
|
2017-05-08 06:22:20 -04:00
|
|
|
Ok { decoded, links } ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model
|
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| following = Update.Timeline.update append decoded links accountInfo.following
|
|
|
|
}
|
|
|
|
}
|
2017-05-09 12:43:12 -04:00
|
|
|
! [ Command.loadRelationships (List.head model.clients) <| List.map .id decoded ]
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountRelationship result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
case decoded of
|
|
|
|
[ relationship ] ->
|
2017-05-29 10:28:01 -04:00
|
|
|
{ model | accountInfo = { accountInfo | relationship = Just relationship } } ! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
_ ->
|
|
|
|
model ! []
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AccountRelationships result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
2017-05-29 10:28:41 -04:00
|
|
|
{ model | accountInfo = { accountInfo | relationships = accountInfo.relationships ++ decoded } }
|
2017-05-08 06:22:20 -04:00
|
|
|
! []
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
HomeTimeline append result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded, links } ->
|
|
|
|
{ model | homeTimeline = Update.Timeline.update append decoded links model.homeTimeline } ! []
|
|
|
|
|
|
|
|
Err error ->
|
2017-05-30 18:27:30 -04:00
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
SearchResultsReceived result ->
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
{ model | search = { search | term = model.search.term, results = Just decoded } } ! []
|
|
|
|
|
|
|
|
Err error ->
|
2017-05-07 08:31:51 -04:00
|
|
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
|
|
|
|
|
|
|
AutoSearch result ->
|
|
|
|
let
|
|
|
|
draft =
|
|
|
|
model.draft
|
|
|
|
in
|
|
|
|
case result of
|
|
|
|
Ok { decoded } ->
|
|
|
|
{ model
|
|
|
|
| draft =
|
|
|
|
{ draft
|
|
|
|
| showAutoMenu =
|
|
|
|
Update.Draft.showAutoMenu
|
|
|
|
decoded
|
|
|
|
draft.autoAtPosition
|
|
|
|
draft.autoQuery
|
|
|
|
, autoAccounts = decoded
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Force selection of the first item after each
|
|
|
|
-- Successfull request
|
|
|
|
! [ Task.perform identity (Task.succeed ((DraftEvent << ResetAutocomplete) True)) ]
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
{ model
|
|
|
|
| draft = { draft | showAutoMenu = False }
|
|
|
|
, errors = addErrorNotification (errorText error) model
|
|
|
|
}
|
|
|
|
! []
|
|
|
|
|
|
|
|
|
|
|
|
{-| Update viewed account relationships as well as the relationship with the
|
|
|
|
current connected user, both according to the "following" status provided.
|
|
|
|
-}
|
2017-05-25 17:07:17 -04:00
|
|
|
processFollowEvent : Relationship -> Model -> Model
|
2017-05-29 10:28:01 -04:00
|
|
|
processFollowEvent relationship ({ accountInfo } as model) =
|
2017-05-07 08:31:51 -04:00
|
|
|
let
|
|
|
|
updateRelationship r =
|
|
|
|
if r.id == relationship.id then
|
2017-05-25 17:07:17 -04:00
|
|
|
{ r | following = relationship.following }
|
2017-05-07 08:31:51 -04:00
|
|
|
else
|
|
|
|
r
|
|
|
|
|
|
|
|
accountRelationships =
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationships |> List.map updateRelationship
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
accountRelationship =
|
2017-05-29 10:28:01 -04:00
|
|
|
case accountInfo.relationship of
|
2017-05-29 17:41:03 -04:00
|
|
|
Just accountRelationship ->
|
|
|
|
if accountRelationship.id == relationship.id then
|
2017-05-25 17:07:17 -04:00
|
|
|
Just { relationship | following = relationship.following }
|
2017-05-07 08:31:51 -04:00
|
|
|
else
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationship
|
2017-05-07 08:31:51 -04:00
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
Nothing
|
|
|
|
in
|
|
|
|
{ model
|
2017-05-29 10:28:01 -04:00
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| relationships = accountRelationships
|
|
|
|
, relationship = accountRelationship
|
|
|
|
}
|
2017-05-07 08:31:51 -04:00
|
|
|
}
|
2017-05-25 04:25:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
processUnfollowEvent : Account -> Relationship -> Model -> Model
|
|
|
|
processUnfollowEvent account relationship model =
|
|
|
|
let
|
|
|
|
newModel =
|
2017-05-25 17:07:17 -04:00
|
|
|
processFollowEvent relationship model
|
2017-05-25 04:25:43 -04:00
|
|
|
in
|
|
|
|
case model.currentUser of
|
|
|
|
Just currentUser ->
|
|
|
|
{ newModel
|
|
|
|
| homeTimeline = Update.Timeline.cleanUnfollow account currentUser model.homeTimeline
|
|
|
|
}
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
newModel
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
{-| Update viewed account relationships as well as the relationship with the
|
|
|
|
current connected user, both according to the "muting" status provided.
|
|
|
|
-}
|
|
|
|
processMuteEvent : Account -> Relationship -> Model -> Model
|
2017-05-29 10:28:01 -04:00
|
|
|
processMuteEvent account relationship ({ accountInfo } as model) =
|
2017-05-25 17:07:17 -04:00
|
|
|
let
|
|
|
|
updateRelationship r =
|
|
|
|
if r.id == relationship.id then
|
|
|
|
{ r | muting = relationship.muting }
|
|
|
|
else
|
|
|
|
r
|
|
|
|
|
|
|
|
accountRelationships =
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationships |> List.map updateRelationship
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
accountRelationship =
|
2017-05-29 10:28:01 -04:00
|
|
|
case accountInfo.relationship of
|
2017-05-29 17:41:03 -04:00
|
|
|
Just accountRelationship ->
|
|
|
|
if accountRelationship.id == relationship.id then
|
2017-05-25 17:07:17 -04:00
|
|
|
Just { relationship | muting = relationship.muting }
|
|
|
|
else
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationship
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
Nothing
|
|
|
|
in
|
|
|
|
{ model
|
2017-05-29 10:28:01 -04:00
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| relationship = accountRelationship
|
|
|
|
, relationships = accountRelationships
|
|
|
|
}
|
2017-05-25 17:07:17 -04:00
|
|
|
, homeTimeline = Update.Timeline.dropAccountStatuses account model.homeTimeline
|
|
|
|
, localTimeline = Update.Timeline.dropAccountStatuses account model.localTimeline
|
|
|
|
, globalTimeline = Update.Timeline.dropAccountStatuses account model.globalTimeline
|
|
|
|
, mutes = Update.Timeline.removeMute account model.mutes
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{-| Update viewed account relationships as well as the relationship with the
|
|
|
|
current connected user, both according to the "blocking" status provided.
|
|
|
|
-}
|
|
|
|
processBlockEvent : Account -> Relationship -> Model -> Model
|
2017-05-29 10:28:01 -04:00
|
|
|
processBlockEvent account relationship ({ accountInfo } as model) =
|
2017-05-25 17:07:17 -04:00
|
|
|
let
|
|
|
|
updateRelationship r =
|
|
|
|
if r.id == relationship.id then
|
|
|
|
{ r | blocking = relationship.blocking }
|
|
|
|
else
|
|
|
|
r
|
|
|
|
|
|
|
|
accountRelationships =
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationships |> List.map updateRelationship
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
accountRelationship =
|
2017-05-29 10:28:01 -04:00
|
|
|
case accountInfo.relationship of
|
2017-05-29 17:41:03 -04:00
|
|
|
Just accountRelationship ->
|
|
|
|
if accountRelationship.id == relationship.id then
|
2017-05-25 17:07:17 -04:00
|
|
|
Just { relationship | blocking = relationship.blocking }
|
|
|
|
else
|
2017-05-29 10:28:01 -04:00
|
|
|
accountInfo.relationship
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
Nothing
|
|
|
|
in
|
|
|
|
{ model
|
2017-05-29 10:28:01 -04:00
|
|
|
| accountInfo =
|
|
|
|
{ accountInfo
|
|
|
|
| relationship = accountRelationship
|
|
|
|
, relationships = accountRelationships
|
|
|
|
}
|
2017-05-25 17:07:17 -04:00
|
|
|
, homeTimeline = Update.Timeline.dropAccountStatuses account model.homeTimeline
|
|
|
|
, localTimeline = Update.Timeline.dropAccountStatuses account model.localTimeline
|
|
|
|
, globalTimeline = Update.Timeline.dropAccountStatuses account model.globalTimeline
|
|
|
|
, blocks = Update.Timeline.removeBlock account model.blocks
|
|
|
|
, notifications = Update.Timeline.dropNotificationsFromAccount account model.notifications
|
|
|
|
}
|