@@ -69,7 +69,7 @@ init appContext projectRef contribRef changeLineId =
6969 , toggledChangeLines = ToggledChangeLines . empty
7070 , urlFocusedChangeLineId = changeLineId
7171 }
72- , fetchBranchDiff appContext projectRef contribRef
72+ , fetchBranchDiff appContext projectRef contribRef 1
7373 )
7474
7575
@@ -79,6 +79,7 @@ init appContext projectRef contribRef changeLineId =
7979
8080type Msg
8181 = FetchBranchDiffFinished ( HttpResult BranchDiffState )
82+ | RetryBranchDiffFetch Int
8283 | ToggleChangeDetails ChangeLine
8384 | CopyChangeLinePermalink ChangeLineId
8485 | ScrollTo ChangeLineId
@@ -117,6 +118,15 @@ update appContext projectRef contribRef msg model =
117118 , cmd_
118119 )
119120
121+ Ok (( BranchDiffState . Computing { numTries } ) as bds) ->
122+ if numTries >= 3 then
123+ ( { model | branchDiff = bds }, Cmd . none )
124+
125+ else
126+ ( { model | branchDiff = bds }
127+ , Util . delayMsg 1000 ( RetryBranchDiffFetch ( numTries + 1 ))
128+ )
129+
120130 Ok bds ->
121131 ( { model | branchDiff = bds }, Cmd . none )
122132
@@ -125,6 +135,11 @@ update appContext projectRef contribRef msg model =
125135 in
126136 ( model_, cmd )
127137
138+ RetryBranchDiffFetch numTries ->
139+ ( { model | branchDiff = BranchDiffState . Reloading { numTries = numTries } }
140+ , fetchBranchDiff appContext projectRef contribRef numTries
141+ )
142+
128143 ScrollTo changeLineId ->
129144 ( model, scrollTo changeLineId )
130145
@@ -179,10 +194,10 @@ scrollTo changeLineId =
179194 ScrollTo . scrollTo_ NoOp " page-content" ( ChangeLineId . toDomId changeLineId) 16
180195
181196
182- fetchBranchDiff : AppContext -> ProjectRef -> ContributionRef -> Cmd Msg
183- fetchBranchDiff appContext projectRef contributionRef =
197+ fetchBranchDiff : AppContext -> ProjectRef -> ContributionRef -> Int -> Cmd Msg
198+ fetchBranchDiff appContext projectRef contributionRef numTries =
184199 ShareApi . projectContributionDiff projectRef contributionRef
185- |> HttpApi . toRequest ( BranchDiffState . decode 1 ) FetchBranchDiffFinished
200+ |> HttpApi . toRequest ( BranchDiffState . decode numTries ) FetchBranchDiffFinished
186201 |> HttpApi . perform appContext. api
187202
188203
0 commit comments