diff --git a/src/Update/Main.elm b/src/Update/Main.elm index 6ed8bd1..abb26d7 100644 --- a/src/Update/Main.elm +++ b/src/Update/Main.elm @@ -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 -> diff --git a/src/Update/Mastodon.elm b/src/Update/Mastodon.elm index 75b885a..b0d4482 100644 --- a/src/Update/Mastodon.elm +++ b/src/Update/Mastodon.elm @@ -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 -> diff --git a/src/Update/Timeline.elm b/src/Update/Timeline.elm index fd3a365..f5e414f 100644 --- a/src/Update/Timeline.elm +++ b/src/Update/Timeline.elm @@ -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 diff --git a/src/Update/WebSocket.elm b/src/Update/WebSocket.elm index 866a545..828827c 100644 --- a/src/Update/WebSocket.elm +++ b/src/Update/WebSocket.elm @@ -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