1
0
Fork 0

Improve coding style.

This commit is contained in:
Nicolas Perriault 2017-05-29 16:28:41 +02:00
parent 6d7e9e9036
commit 54ef5210df
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
4 changed files with 22 additions and 46 deletions

View File

@ -39,11 +39,7 @@ update msg model =
model ! []
UrlChange location ->
let
newModel =
{ model | location = location }
in
Update.Route.update newModel
Update.Route.update { model | location = location }
Back ->
model ! [ Navigation.back 1 ]
@ -129,9 +125,7 @@ update msg model =
model ! [ Command.registerApp model ]
OpenThread status ->
{ model
| currentView = ThreadView (Thread Nothing Nothing)
}
{ model | currentView = ThreadView (Thread Nothing Nothing) }
! [ Navigation.newUrl <| "#thread/" ++ (toString status.id) ]
FollowAccount account ->

View File

@ -341,12 +341,7 @@ update msg ({ accountInfo } as model) =
AccountRelationships result ->
case result of
Ok { decoded } ->
{ model
| accountInfo =
{ accountInfo
| relationships = List.concat [ accountInfo.relationships, decoded ]
}
}
{ model | accountInfo = { accountInfo | relationships = accountInfo.relationships ++ decoded } }
! []
Err error ->

View File

@ -55,7 +55,7 @@ deleteStatusFromCurrentView id model =
case ( thread.status, thread.context ) of
( Just status, Just context ) ->
if status.id == id then
-- the current thread status as been deleted, close it
-- current thread status has been deleted, close it
LocalTimelineView
else
let
@ -79,11 +79,8 @@ deleteStatusFromCurrentView id model =
deleteStatusFromAllTimelines : Int -> Model -> Model
deleteStatusFromAllTimelines id model =
deleteStatusFromAllTimelines id ({ accountInfo } as model) =
let
accountInfo =
model.accountInfo
accountTimeline =
deleteStatus id accountInfo.timeline
in
@ -152,7 +149,7 @@ empty id =
markAsLoading : Bool -> String -> Model -> Model
markAsLoading loading id model =
markAsLoading loading id ({ accountInfo } as model) =
let
mark timeline =
{ timeline | loading = loading }
@ -176,19 +173,16 @@ markAsLoading loading id model =
"hashtag-timeline" ->
{ model | hashtagTimeline = mark model.hashtagTimeline }
"mutes-timeline" ->
{ model | mutes = mark model.mutes }
"blocks-timeline" ->
{ model | blocks = mark model.blocks }
"account-timeline" ->
case model.currentView of
AccountView account ->
let
accountInfo =
model.accountInfo
in
{ model
| accountInfo =
{ accountInfo
| timeline = mark accountInfo.timeline
}
}
{ model | accountInfo = { accountInfo | timeline = mark accountInfo.timeline } }
_ ->
model
@ -290,7 +284,7 @@ update append entries links timeline =
updateWithBoolFlag : Int -> Bool -> (Status -> Status) -> Model -> Model
updateWithBoolFlag statusId flag statusUpdater model =
updateWithBoolFlag statusId flag statusUpdater ({ accountInfo } as model) =
let
updateStatus status =
if (Mastodon.Helper.extractReblog status).id == statusId then
@ -306,9 +300,6 @@ updateWithBoolFlag statusId flag statusUpdater model =
Nothing ->
notification
accountInfo =
model.accountInfo
updateTimeline updateEntry timeline =
{ timeline | entries = List.map updateEntry timeline.entries }
in

View File

@ -139,7 +139,7 @@ isThreadMember thread status =
appendToThreadDescendants : Thread -> Status -> Thread
appendToThreadDescendants ({ context } as thread) status =
case thread.context of
case context of
Just context ->
{ thread
| context =
@ -151,7 +151,7 @@ appendToThreadDescendants ({ context } as thread) status =
updateCurrentViewWithStatus : Status -> Model -> Model
updateCurrentViewWithStatus status model =
updateCurrentViewWithStatus status ({ accountInfo } as model) =
case model.currentView of
ThreadView ({ context } as thread) ->
if isThreadMember thread status then
@ -163,16 +163,12 @@ updateCurrentViewWithStatus status model =
case model.accountInfo.account of
Just account ->
if Mastodon.Helper.sameAccount account status.account then
let
accountInfo =
model.accountInfo
in
{ model
| accountInfo =
{ accountInfo
| timeline = Update.Timeline.prepend status accountInfo.timeline
}
}
{ model
| accountInfo =
{ accountInfo
| timeline = Update.Timeline.prepend status accountInfo.timeline
}
}
else
model