Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
70e59559
Commit
70e59559
authored
Mar 23, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clears timeout
parent
14b077b7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
app/assets/javascripts/lib/utils/poll.js
app/assets/javascripts/lib/utils/poll.js
+9
-5
No files found.
app/assets/javascripts/lib/utils/poll.js
View file @
70e59559
...
@@ -36,6 +36,7 @@ export default class Poll {
...
@@ -36,6 +36,7 @@ export default class Poll {
this
.
options
.
data
=
options
.
data
||
{};
this
.
options
.
data
=
options
.
data
||
{};
this
.
intervalHeader
=
'
POLL-INTERVAL
'
;
this
.
intervalHeader
=
'
POLL-INTERVAL
'
;
this
.
timeoutID
=
null
;
this
.
canPoll
=
true
;
this
.
canPoll
=
true
;
}
}
...
@@ -44,11 +45,8 @@ export default class Poll {
...
@@ -44,11 +45,8 @@ export default class Poll {
const
pollInterval
=
headers
[
this
.
intervalHeader
];
const
pollInterval
=
headers
[
this
.
intervalHeader
];
if
(
pollInterval
>
0
&&
response
.
status
===
httpStatusCodes
.
OK
&&
this
.
canPoll
)
{
if
(
pollInterval
>
0
&&
response
.
status
===
httpStatusCodes
.
OK
&&
this
.
canPoll
)
{
setTimeout
(()
=>
{
this
.
timeoutID
=
setTimeout
(()
=>
{
// Stop can be called in the meanwhile, so let's check again.
if
(
this
.
canPoll
)
{
this
.
makeRequest
();
this
.
makeRequest
();
}
},
pollInterval
);
},
pollInterval
);
}
}
...
@@ -63,7 +61,13 @@ export default class Poll {
...
@@ -63,7 +61,13 @@ export default class Poll {
.
catch
(
error
=>
errorCallback
(
error
));
.
catch
(
error
=>
errorCallback
(
error
));
}
}
/**
* Stops the polling recursive chain
* and guarantees if the timeout is already running it won't make another request by
* cancelling the previously established timeout.
*/
stop
()
{
stop
()
{
this
.
canPoll
=
false
;
this
.
canPoll
=
false
;
clearTimeout
(
this
.
timeoutID
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment