Improve coding style.
This commit is contained in:
parent
6d7e9e9036
commit
54ef5210df
@ -39,11 +39,7 @@ update msg model =
|
|||||||
model ! []
|
model ! []
|
||||||
|
|
||||||
UrlChange location ->
|
UrlChange location ->
|
||||||
let
|
Update.Route.update { model | location = location }
|
||||||
newModel =
|
|
||||||
{ model | location = location }
|
|
||||||
in
|
|
||||||
Update.Route.update newModel
|
|
||||||
|
|
||||||
Back ->
|
Back ->
|
||||||
model ! [ Navigation.back 1 ]
|
model ! [ Navigation.back 1 ]
|
||||||
@ -129,9 +125,7 @@ update msg model =
|
|||||||
model ! [ Command.registerApp model ]
|
model ! [ Command.registerApp model ]
|
||||||
|
|
||||||
OpenThread status ->
|
OpenThread status ->
|
||||||
{ model
|
{ model | currentView = ThreadView (Thread Nothing Nothing) }
|
||||||
| currentView = ThreadView (Thread Nothing Nothing)
|
|
||||||
}
|
|
||||||
! [ Navigation.newUrl <| "#thread/" ++ (toString status.id) ]
|
! [ Navigation.newUrl <| "#thread/" ++ (toString status.id) ]
|
||||||
|
|
||||||
FollowAccount account ->
|
FollowAccount account ->
|
||||||
|
@ -341,12 +341,7 @@ update msg ({ accountInfo } as model) =
|
|||||||
AccountRelationships result ->
|
AccountRelationships result ->
|
||||||
case result of
|
case result of
|
||||||
Ok { decoded } ->
|
Ok { decoded } ->
|
||||||
{ model
|
{ model | accountInfo = { accountInfo | relationships = accountInfo.relationships ++ decoded } }
|
||||||
| accountInfo =
|
|
||||||
{ accountInfo
|
|
||||||
| relationships = List.concat [ accountInfo.relationships, decoded ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
! []
|
! []
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
|
@ -55,7 +55,7 @@ deleteStatusFromCurrentView id model =
|
|||||||
case ( thread.status, thread.context ) of
|
case ( thread.status, thread.context ) of
|
||||||
( Just status, Just context ) ->
|
( Just status, Just context ) ->
|
||||||
if status.id == id then
|
if status.id == id then
|
||||||
-- the current thread status as been deleted, close it
|
-- current thread status has been deleted, close it
|
||||||
LocalTimelineView
|
LocalTimelineView
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@ -79,11 +79,8 @@ deleteStatusFromCurrentView id model =
|
|||||||
|
|
||||||
|
|
||||||
deleteStatusFromAllTimelines : Int -> Model -> Model
|
deleteStatusFromAllTimelines : Int -> Model -> Model
|
||||||
deleteStatusFromAllTimelines id model =
|
deleteStatusFromAllTimelines id ({ accountInfo } as model) =
|
||||||
let
|
let
|
||||||
accountInfo =
|
|
||||||
model.accountInfo
|
|
||||||
|
|
||||||
accountTimeline =
|
accountTimeline =
|
||||||
deleteStatus id accountInfo.timeline
|
deleteStatus id accountInfo.timeline
|
||||||
in
|
in
|
||||||
@ -152,7 +149,7 @@ empty id =
|
|||||||
|
|
||||||
|
|
||||||
markAsLoading : Bool -> String -> Model -> Model
|
markAsLoading : Bool -> String -> Model -> Model
|
||||||
markAsLoading loading id model =
|
markAsLoading loading id ({ accountInfo } as model) =
|
||||||
let
|
let
|
||||||
mark timeline =
|
mark timeline =
|
||||||
{ timeline | loading = loading }
|
{ timeline | loading = loading }
|
||||||
@ -176,19 +173,16 @@ markAsLoading loading id model =
|
|||||||
"hashtag-timeline" ->
|
"hashtag-timeline" ->
|
||||||
{ model | hashtagTimeline = mark model.hashtagTimeline }
|
{ model | hashtagTimeline = mark model.hashtagTimeline }
|
||||||
|
|
||||||
|
"mutes-timeline" ->
|
||||||
|
{ model | mutes = mark model.mutes }
|
||||||
|
|
||||||
|
"blocks-timeline" ->
|
||||||
|
{ model | blocks = mark model.blocks }
|
||||||
|
|
||||||
"account-timeline" ->
|
"account-timeline" ->
|
||||||
case model.currentView of
|
case model.currentView of
|
||||||
AccountView account ->
|
AccountView account ->
|
||||||
let
|
{ model | accountInfo = { accountInfo | timeline = mark accountInfo.timeline } }
|
||||||
accountInfo =
|
|
||||||
model.accountInfo
|
|
||||||
in
|
|
||||||
{ model
|
|
||||||
| accountInfo =
|
|
||||||
{ accountInfo
|
|
||||||
| timeline = mark accountInfo.timeline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
model
|
model
|
||||||
@ -290,7 +284,7 @@ update append entries links timeline =
|
|||||||
|
|
||||||
|
|
||||||
updateWithBoolFlag : Int -> Bool -> (Status -> Status) -> Model -> Model
|
updateWithBoolFlag : Int -> Bool -> (Status -> Status) -> Model -> Model
|
||||||
updateWithBoolFlag statusId flag statusUpdater model =
|
updateWithBoolFlag statusId flag statusUpdater ({ accountInfo } as model) =
|
||||||
let
|
let
|
||||||
updateStatus status =
|
updateStatus status =
|
||||||
if (Mastodon.Helper.extractReblog status).id == statusId then
|
if (Mastodon.Helper.extractReblog status).id == statusId then
|
||||||
@ -306,9 +300,6 @@ updateWithBoolFlag statusId flag statusUpdater model =
|
|||||||
Nothing ->
|
Nothing ->
|
||||||
notification
|
notification
|
||||||
|
|
||||||
accountInfo =
|
|
||||||
model.accountInfo
|
|
||||||
|
|
||||||
updateTimeline updateEntry timeline =
|
updateTimeline updateEntry timeline =
|
||||||
{ timeline | entries = List.map updateEntry timeline.entries }
|
{ timeline | entries = List.map updateEntry timeline.entries }
|
||||||
in
|
in
|
||||||
|
@ -139,7 +139,7 @@ isThreadMember thread status =
|
|||||||
|
|
||||||
appendToThreadDescendants : Thread -> Status -> Thread
|
appendToThreadDescendants : Thread -> Status -> Thread
|
||||||
appendToThreadDescendants ({ context } as thread) status =
|
appendToThreadDescendants ({ context } as thread) status =
|
||||||
case thread.context of
|
case context of
|
||||||
Just context ->
|
Just context ->
|
||||||
{ thread
|
{ thread
|
||||||
| context =
|
| context =
|
||||||
@ -151,7 +151,7 @@ appendToThreadDescendants ({ context } as thread) status =
|
|||||||
|
|
||||||
|
|
||||||
updateCurrentViewWithStatus : Status -> Model -> Model
|
updateCurrentViewWithStatus : Status -> Model -> Model
|
||||||
updateCurrentViewWithStatus status model =
|
updateCurrentViewWithStatus status ({ accountInfo } as model) =
|
||||||
case model.currentView of
|
case model.currentView of
|
||||||
ThreadView ({ context } as thread) ->
|
ThreadView ({ context } as thread) ->
|
||||||
if isThreadMember thread status then
|
if isThreadMember thread status then
|
||||||
@ -163,16 +163,12 @@ updateCurrentViewWithStatus status model =
|
|||||||
case model.accountInfo.account of
|
case model.accountInfo.account of
|
||||||
Just account ->
|
Just account ->
|
||||||
if Mastodon.Helper.sameAccount account status.account then
|
if Mastodon.Helper.sameAccount account status.account then
|
||||||
let
|
{ model
|
||||||
accountInfo =
|
| accountInfo =
|
||||||
model.accountInfo
|
{ accountInfo
|
||||||
in
|
| timeline = Update.Timeline.prepend status accountInfo.timeline
|
||||||
{ model
|
}
|
||||||
| accountInfo =
|
}
|
||||||
{ accountInfo
|
|
||||||
| timeline = Update.Timeline.prepend status accountInfo.timeline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
model
|
model
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user