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
Boxiang Sun
gitlab-ce
Commits
d9928d1a
Commit
d9928d1a
authored
Jul 13, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Decouple poll from main component to increase reusability.
parent
820c0d6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
app/assets/javascripts/notes/components/issue_notes.vue
app/assets/javascripts/notes/components/issue_notes.vue
+4
-7
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+6
-2
No files found.
app/assets/javascripts/notes/components/issue_notes.vue
View file @
d9928d1a
...
...
@@ -61,17 +61,14 @@ export default {
});
},
initPolling
()
{
const
{
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
const
options
=
{
endpoint
:
`
${
notesPath
}
?full_data=1`
,
lastFetchedAt
,
};
const
{
lastFetchedAt
}
=
$
(
'
.js-notes-wrapper
'
)[
0
].
dataset
;
this
.
$store
.
commit
(
'
setLastFetchedAt
'
,
lastFetchedAt
);
// FIXME: @fatihacet Implement real polling mechanism
setInterval
(()
=>
{
this
.
$store
.
dispatch
(
'
poll
'
,
options
)
this
.
$store
.
dispatch
(
'
poll
'
)
.
then
((
res
)
=>
{
options
.
lastFetchedAt
=
res
.
last_fetched_at
;
this
.
$store
.
commit
(
'
setLastFetchedAt
'
,
res
.
lastFetchedAt
)
;
})
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while fetching latest comments.
'
);
// eslint-disable-line
...
...
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
d9928d1a
...
...
@@ -7,6 +7,7 @@ const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
const
state
=
{
notes
:
[],
targetNoteHash
:
null
,
lastFetchedAt
:
null
,
};
const
getters
=
{
...
...
@@ -104,6 +105,9 @@ const mutations = {
});
}
},
setLastFetchedAt
(
storeState
,
fetchedAt
)
{
storeState
.
lastFetchedAt
=
fetchedAt
;
},
};
const
actions
=
{
...
...
@@ -156,10 +160,10 @@ const actions = {
});
},
poll
(
context
,
data
)
{
const
{
endpoint
,
lastFetchedAt
}
=
data
;
const
{
notesPath
}
=
$
(
'
.js-notes-wrapper
'
)[
0
].
dataset
;
return
service
.
poll
(
endpoint
,
lastFetchedAt
)
.
poll
(
`
${
notesPath
}
?full_data=1`
,
context
.
state
.
lastFetchedAt
)
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
if
(
res
.
notes
.
length
)
{
...
...
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