Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Mobile
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
147
Issues
147
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Commits
760fa50d
Commit
760fa50d
authored
6 minutes ago
by
Martin Santangelo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(bug) infinite feed error discovery and local storage of pagination token
parent
8bdcbde9
feat/infinite-scroll-feed-service
1 merge request
!290
[Sprint/KiltedKoala] (feat) infinite scroll feed service
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
8 deletions
+61
-8
feeds.service.js
src/common/services/feeds.service.js
+45
-7
feeds.storage.js
src/common/services/sql/feeds.storage.js
+3
-1
FeedStore.js
src/common/stores/FeedStore.js
+10
-0
DiscoveryStore.js
src/discovery/DiscoveryStore.js
+3
-0
No files found.
src/common/services/feeds.service.js
View file @
760fa50d
...
...
@@ -54,15 +54,20 @@ export default class FeedsService {
*/
endReached
=
false
;
/**
* @var {boolean}
*/
paginated
=
true
;
/**
* Get entities from the current page
*/
async
getEntities
()
{
const
end
=
this
.
limit
+
this
.
offset
;
if
(
end
>
this
.
feed
.
length
&&
!
this
.
endReached
)
{
await
this
.
fetch
();
if
(
this
.
paginated
&&
end
>
this
.
feed
.
length
&&
!
this
.
endReached
)
{
await
this
.
fetch
(
true
);
}
const
feedPage
=
this
.
feed
.
slice
(
this
.
offset
,
this
.
limit
+
this
.
offset
);
const
feedPage
=
this
.
feed
.
slice
(
this
.
offset
,
end
);
return
await
entitiesService
.
getFromFeed
(
feedPage
,
this
,
this
.
asActivities
);
}
...
...
@@ -135,6 +140,10 @@ export default class FeedsService {
return
this
;
}
/**
* Set parameters
* @param {Object} params
*/
setParams
(
params
):
FeedsService
{
this
.
params
=
params
;
if
(
!
params
.
sync
)
{
...
...
@@ -153,6 +162,16 @@ export default class FeedsService {
return
this
;
}
/**
* Set paginated
* @param {boolean} paginated
* @returns {FeedsService}
*/
setPaginated
(
paginated
:
boolean
):
FeedsService
{
this
.
paginated
=
paginated
;
return
this
;
}
/**
* Abort pending fetch
*/
...
...
@@ -162,14 +181,25 @@ export default class FeedsService {
/**
* Fetch
* @param {boolean} more
*/
async
fetch
()
{
async
fetch
(
more
=
false
)
{
abort
(
this
);
const
response
=
await
apiService
.
get
(
this
.
endpoint
,
{...
this
.
params
,
...{
limit
:
150
,
as_activities
:
this
.
asActivities
?
1
:
0
,
from_timestamp
:
this
.
pagingToken
}},
this
);
const
params
=
{...
this
.
params
,
...{
limit
:
150
,
as_activities
:
this
.
asActivities
?
1
:
0
}};
if
(
this
.
paginated
&&
more
)
params
.
from_timestamp
=
this
.
pagingToken
;
const
response
=
await
apiService
.
get
(
this
.
endpoint
,
params
,
this
);
if
(
response
.
entities
.
length
)
{
this
.
feed
=
this
.
feed
.
concat
(
response
.
entities
);
if
(
more
)
{
this
.
feed
=
this
.
feed
.
concat
(
response
.
entities
);
}
else
{
this
.
feed
=
response
.
entities
;
}
this
.
pagingToken
=
response
[
'
load-next
'
];
if
(
response
.
entities
.
length
<
150
)
this
.
endReached
=
true
;
}
else
{
this
.
endReached
=
true
;
}
...
...
@@ -185,7 +215,14 @@ export default class FeedsService {
try
{
const
feed
=
await
feedsStorage
.
read
(
this
);
if
(
feed
)
{
this
.
feed
=
feed
;
// support old format
if
(
Array
.
isArray
(
feed
))
{
this
.
feed
=
feed
;
this
.
pagingToken
=
this
.
feed
[
this
.
feed
.
length
-
1
].
timestamp
-
1
;
}
else
{
this
.
feed
=
feed
.
feed
;
this
.
pagingToken
=
feed
.
next
;
}
return
true
;
}
}
catch
(
err
)
{
...
...
@@ -258,6 +295,7 @@ export default class FeedsService {
clear
():
FeedStore
{
this
.
offset
=
0
;
this
.
limit
=
12
;
this
.
pagingToken
=
''
;
this
.
params
=
{
sync
:
1
};
this
.
feed
=
[];
return
this
;
...
...
This diff is collapsed.
Click to expand it.
src/common/services/sql/feeds.storage.js
View file @
760fa50d
...
...
@@ -24,7 +24,9 @@ export class FeedsStorage {
try
{
await
this
.
getDb
();
await
this
.
db
.
executeSql
(
'
REPLACE INTO feeds (key, offset, data, updated) values (?,?,?,?)
'
,
[
key
,
0
,
JSON
.
stringify
(
this
.
map
(
feed
.
feed
)),
Math
.
floor
(
Date
.
now
()
/
1000
)]);
const
params
=
[
key
,
0
,
JSON
.
stringify
({
feed
:
this
.
map
(
feed
.
feed
),
next
:
feed
.
pagingToken
}),
Math
.
floor
(
Date
.
now
()
/
1000
)];
await
this
.
db
.
executeSql
(
'
REPLACE INTO feeds (key, offset, data, updated) values (?,?,?,?)
'
,
params
);
}
catch
(
err
)
{
logService
.
exception
(
'
[FeedsStorage]
'
,
err
);
}
...
...
This diff is collapsed.
Click to expand it.
src/common/stores/FeedStore.js
View file @
760fa50d
...
...
@@ -181,6 +181,16 @@ export default class FeedStore {
return
this
;
}
/**
* Set paginated
* @param {boolean} paginated
* @returns {FeedStore}
*/
setPaginated
(
paginated
:
boolean
):
FeedStore
{
this
.
feedsService
.
setPaginated
(
paginated
);
return
this
;
}
/**
* Set the params for the feeds service
* @param {Object} params
...
...
This diff is collapsed.
Click to expand it.
src/discovery/DiscoveryStore.js
View file @
760fa50d
...
...
@@ -66,6 +66,9 @@ class DiscoveryStore {
this
.
listenChanges
();
// we don't have feed pagination on discovery
this
.
listStore
.
setPaginated
(
false
);
this
.
listStore
.
getMetadataService
()
.
setSource
(
'
feed/discovery
'
)
.
setMedium
(
'
feed
'
);
...
...
This diff is collapsed.
Click to expand it.
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