mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 09:53:13 +00:00
Merge pull request #5625 from overleaf/jpa-block-update-loop
[web] block a loop of failing rootDoc update requests GitOrigin-RevId: 1388024fc125ee1e80e45a7bbbc787306cb60d1d
This commit is contained in:
parent
b5998148e7
commit
8ba1803972
1 changed files with 20 additions and 3 deletions
|
@ -184,6 +184,7 @@ export default App.controller(
|
|||
}
|
||||
})
|
||||
|
||||
let rootDocUpdateFailed = 0
|
||||
$scope.$watch('project.rootDoc_id', (rootDoc_id, oldRootDoc_id) => {
|
||||
if (this.ignoreUpdates) {
|
||||
return
|
||||
|
@ -200,9 +201,25 @@ export default App.controller(
|
|||
}
|
||||
// otherwise only save changes, null values are allowed
|
||||
if (rootDoc_id !== oldRootDoc_id) {
|
||||
settings.saveProjectSettings({ rootDocId: rootDoc_id }).catch(() => {
|
||||
$scope.project.rootDoc_id = oldRootDoc_id
|
||||
})
|
||||
settings
|
||||
.saveProjectSettings({ rootDocId: rootDoc_id })
|
||||
.then(() => {
|
||||
rootDocUpdateFailed = 0
|
||||
})
|
||||
.catch(() => {
|
||||
rootDocUpdateFailed++
|
||||
// Let the login redirect run (if any) and reset afterwards.
|
||||
setTimeout(() => {
|
||||
if (rootDocUpdateFailed > 10) {
|
||||
// We are in a loop of failing updates. Stop now.
|
||||
this.ignoreUpdates = true
|
||||
}
|
||||
$scope.$apply(() => {
|
||||
$scope.project.rootDoc_id = oldRootDoc_id
|
||||
})
|
||||
this.ignoreUpdates = false
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue