BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9101cce2
Commit
9101cce2
authored
Oct 24, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't re-run smart interval callback if there is already one in progress
because some things take time
parent
2087f121
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
smart_interval.js
app/assets/javascripts/smart_interval.js
+18
-4
mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+2
-2
smart_interval_spec.js
spec/javascripts/smart_interval_spec.js
+1
-1
No files found.
app/assets/javascripts/smart_interval.js
View file @
9101cce2
...
...
@@ -42,13 +42,16 @@ class SmartInterval {
const
cfg
=
this
.
cfg
;
const
state
=
this
.
state
;
if
(
cfg
.
immediateExecution
)
{
if
(
cfg
.
immediateExecution
&&
!
this
.
isLoading
)
{
cfg
.
immediateExecution
=
false
;
cfg
.
c
allback
();
this
.
triggerC
allback
();
}
state
.
intervalId
=
window
.
setInterval
(()
=>
{
cfg
.
callback
();
if
(
this
.
isLoading
)
{
return
;
}
this
.
triggerCallback
();
if
(
this
.
getCurrentInterval
()
===
cfg
.
maxInterval
)
{
return
;
...
...
@@ -76,7 +79,7 @@ class SmartInterval {
// start a timer, using the existing interval
resume
()
{
this
.
stopTimer
();
// stop ex
si
ting timer, in case timer was not previously stopped
this
.
stopTimer
();
// stop ex
is
ting timer, in case timer was not previously stopped
this
.
start
();
}
...
...
@@ -104,6 +107,17 @@ class SmartInterval {
this
.
initPageUnloadHandling
();
}
triggerCallback
()
{
this
.
isLoading
=
true
;
this
.
cfg
.
callback
()
.
then
(()
=>
{
this
.
isLoading
=
false
;
})
.
catch
(()
=>
{
this
.
isLoading
=
false
;
});
}
initVisibilityChangeHandling
()
{
// cancel interval when tab no longer shown (prevents cached pages from polling)
document
.
addEventListener
(
'visibilitychange'
,
this
.
handleVisibilityChange
.
bind
(
this
));
...
...
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
9101cce2
...
...
@@ -81,7 +81,7 @@ export default {
return
new
MRWidgetService
(
endpoints
);
},
checkStatus
(
cb
)
{
this
.
service
.
checkStatus
()
return
this
.
service
.
checkStatus
()
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
this
.
handleNotification
(
res
);
...
...
@@ -121,7 +121,7 @@ export default {
}
},
fetchDeployments
()
{
this
.
service
.
fetchDeployments
()
return
this
.
service
.
fetchDeployments
()
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
if
(
res
.
length
)
{
...
...
spec/javascripts/smart_interval_spec.js
View file @
9101cce2
...
...
@@ -9,7 +9,7 @@ import '~/smart_interval';
function
createDefaultSmartInterval
(
config
)
{
const
defaultParams
=
{
callback
:
()
=>
{}
,
callback
:
()
=>
Promise
.
resolve
()
,
startingInterval
:
DEFAULT_STARTING_INTERVAL
,
maxInterval
:
DEFAULT_MAX_INTERVAL
,
incrementByFactorOf
:
DEFAULT_INCREMENT_FACTOR
,
...
...
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