Skip to content
Next
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
804
Merge Requests
55
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
605b1b40
Commit
605b1b40
authored
39 minutes ago
by
Guy Thouret
Browse files
Options
Download
(fix) Move the increment and test of offset inside the async pipe in FeaturedContentService -
#2190
parent
d608876c
fix/2190-boost-feed
1 merge request
!629
WIP: Fix duplicate boost posts appearing in newfeed
Pipeline
#94111035
running with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
42 deletions
+9
-42
src/app/common/components/featured-content/featured-content.service.ts
View file @
605b1b40
...
...
@@ -4,10 +4,8 @@ import { FeedsService } from '../../services/feeds.service';
@
Injectable
()
export
class
FeaturedContentService
{
offset
=
-
1
;
offset
=
0
;
maximumOffset
=
0
;
maximumEmptyFetch
=
5
;
emptyFetchCount
=
0
;
feedLength
=
0
;
constructor
(
protected
feedsService
:
FeedsService
)
{
...
...
@@ -16,10 +14,6 @@ export class FeaturedContentService {
console
.
log
(
'
BOOST feed.length:
'
+
feed
.
length
);
this
.
feedLength
=
feed
.
length
;
this
.
maximumOffset
=
this
.
feedLength
-
1
;
if
(
this
.
feedLength
>
0
)
{
this
.
emptyFetchCount
=
0
;
}
});
this
.
feedsService
...
...
@@ -30,49 +24,22 @@ export class FeaturedContentService {
}
async
fetch
()
{
if
(
this
.
feedReset
())
{
this
.
fetchNextFeed
();
}
this
.
retryFetchIfNoFeedData
();
return
this
.
entityFromFeed
();
}
protected
feedReset
():
boolean
{
if
(
this
.
offset
++
>=
this
.
maximumOffset
)
{
this
.
offset
=
0
;
return
true
;
}
return
false
;
}
protected
retryFetchIfNoFeedData
()
{
while
(
this
.
feedLength
===
0
&&
this
.
emptyFetchCount
<
this
.
maximumEmptyFetch
)
{
/** TODO: Remove Debug Line */
console
.
log
(
'
BOOST retry fetch - no feed data
'
);
this
.
emptyFetchCount
++
;
this
.
feedsService
.
fetch
();
}
}
protected
async
entityFromFeed
()
{
/** TODO: Remove debug line */
console
.
log
(
'
BOOST featuredContentService.offset :
'
+
this
.
offset
);
return
await
this
.
feedsService
.
feed
.
pipe
(
filter
(
item
=>
item
.
length
>
0
),
first
(),
mergeMap
(
feed
=>
feed
),
filter
(
entities
=>
entities
.
length
>
0
),
mergeMap
(
feed
=>
feed
),
// Convert feed array to stream
skip
(
this
.
offset
),
take
(
1
),
switchMap
(
async
entity
=>
{
if
(
!
entity
)
{
return
false
;
}
else
{
if
(
this
.
offset
++
>=
this
.
maximumOffset
)
{
this
.
offset
=
0
;
this
.
fetchNextFeed
();
}
return
await
entity
.
pipe
(
first
()).
toPromise
();
}
return
await
entity
.
pipe
(
first
()).
toPromise
();
})
)
.
toPromise
();
...
...
This diff is collapsed.
Please
register
or
sign in
to comment