Skip to content
Next
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
802
Merge Requests
51
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
Compare Revisions
9bc0207965e1630d778458cb7e78df95f787a739...f0fef876107eeca2e2ad865bc5f1d1f9b3bb6894
Source
f0fef876107eeca2e2ad865bc5f1d1f9b3bb6894
...
Target
9bc0207965e1630d778458cb7e78df95f787a739
Compare
Commits (4)
(chore) Remove unused imports from EntitiesService -
#2190
· af79b04d
Guy Thouret
authored
5 hours ago
af79b04d
(chore) Remove unused imports from BlockListService -
#2190
· 5ae4efa5
Guy Thouret
authored
5 hours ago
5ae4efa5
(chore) Remove unused imports / types from FeedService -
#2190
· c4b81ad8
Guy Thouret
authored
5 hours ago
c4b81ad8
(chore) Improve debug output and add a retry if empty feed data in FeaturedContentService -
#2190
· f0fef876
Guy Thouret
authored
4 hours ago
f0fef876
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
58 deletions
+50
-58
src/app/common/components/featured-content/featured-content.component.ts
View file @
f0fef876
...
...
@@ -46,7 +46,10 @@ export class FeaturedContentComponent implements OnInit {
async
load
()
{
try
{
this
.
entity
=
await
this
.
featuredContentService
.
fetch
();
console
.
log
(
'
featuredContentService.fetch() :
'
+
this
.
entity
.
guid
);
/** TODO: Remove debug line */
console
.
log
(
'
BOOST slot:
'
+
this
.
slot
+
'
entity.guid:
'
+
this
.
entity
.
guid
);
}
catch
(
e
)
{
console
.
error
(
'
FeaturedContentComponent.load
'
,
e
);
}
...
...
This diff is collapsed.
src/app/common/components/featured-content/featured-content.service.ts
View file @
f0fef876
...
...
@@ -4,31 +4,63 @@ import { FeedsService } from '../../services/feeds.service';
@
Injectable
()
export
class
FeaturedContentService
{
offset
:
number
=
-
1
;
maximumOffset
:
number
=
0
;
offset
=
-
1
;
maximumOffset
=
0
;
maximumEmptyFetch
=
5
;
emptyFetchCount
=
0
;
feedLength
=
0
;
constructor
(
protected
feedsService
:
FeedsService
)
{
this
.
feedsService
.
feed
.
subscribe
(
feed
=>
{
/** TODO: Remove debug line */
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
.
setLimit
(
12
)
.
setOffset
(
0
)
.
setEndpoint
(
'
api/v2/boost/feed
'
)
.
fetch
();
this
.
feedsService
.
feed
.
subscribe
(
feed
=>
{
this
.
maximumOffset
=
feed
.
length
-
1
;
});
}
async
fetch
()
{
if
(
this
.
feedReset
())
{
this
.
fetchNextFeed
();
}
this
.
retryFetchIfNoFeedData
();
return
this
.
entityFromFeed
();
}
protected
feedReset
():
boolean
{
if
(
this
.
offset
++
>=
this
.
maximumOffset
)
{
this
.
offset
=
0
;
this
.
fetchNextFeed
()
;
return
true
;
}
return
this
.
entityFromFeed
();
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
),
...
...
This diff is collapsed.
src/app/common/services/block-list.service.ts
View file @
f0fef876
...
...
@@ -4,13 +4,6 @@ import { Client } from '../../services/api/client';
import
{
Session
}
from
'
../../services/session
'
;
import
{
Storage
}
from
'
../../services/storage
'
;
import
AsyncLock
from
'
../../helpers/async-lock
'
;
import
MindsClientHttpAdapter
from
'
../../lib/minds-sync/adapters/MindsClientHttpAdapter.js
'
;
import
browserStorageAdapterFactory
from
'
../../helpers/browser-storage-adapter-factory
'
;
import
BlockListSync
from
'
../../lib/minds-sync/services/BlockListSync.js
'
;
import
AsyncStatus
from
'
../../helpers/async-status
'
;
@
Injectable
()
export
class
BlockListService
{
blocked
:
BehaviorSubject
<
string
[]
>
;
...
...
This diff is collapsed.
src/app/common/services/entities.service.ts
View file @
f0fef876
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
BehaviorSubject
,
Observable
,
of
}
from
'
rxjs
'
;
import
{
first
,
catchError
}
from
'
rxjs/operators
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
first
}
from
'
rxjs/operators
'
;
import
{
Client
}
from
'
../../services/api
'
;
import
{
BlockListService
}
from
'
./block-list.service
'
;
import
MindsClientHttpAdapter
from
'
../../lib/minds-sync/adapters/MindsClientHttpAdapter.js
'
;
import
browserStorageAdapterFactory
from
'
../../helpers/browser-storage-adapter-factory
'
;
import
EntitiesSync
from
'
../../lib/minds-sync/services/EntitiesSync.js
'
;
import
AsyncStatus
from
'
../../helpers/async-status
'
;
import
normalizeUrn
from
'
../../helpers/normalize-urn
'
;
type
EntityObservable
=
BehaviorSubject
<
Object
>
;
type
EntityObservables
=
Map
<
string
,
EntityObservable
>
;
...
...
This diff is collapsed.
src/app/common/services/feeds.service.ts
View file @
f0fef876
...
...
@@ -6,40 +6,8 @@ import { Session } from '../../services/session';
import
{
EntitiesService
}
from
'
./entities.service
'
;
import
{
BlockListService
}
from
'
./block-list.service
'
;
import
MindsClientHttpAdapter
from
'
../../lib/minds-sync/adapters/MindsClientHttpAdapter.js
'
;
import
browserStorageAdapterFactory
from
'
../../helpers/browser-storage-adapter-factory
'
;
import
FeedsSync
from
'
../../lib/minds-sync/services/FeedsSync.js
'
;
import
hashCode
from
'
../../helpers/hash-code
'
;
import
AsyncStatus
from
'
../../helpers/async-status
'
;
import
{
BehaviorSubject
,
Observable
,
of
,
forkJoin
,
combineLatest
}
from
'
rxjs
'
;
import
{
take
,
switchMap
,
map
,
tap
,
skipWhile
,
first
,
filter
,
}
from
'
rxjs/operators
'
;
export
type
FeedsServiceGetParameters
=
{
endpoint
:
string
;
timebased
:
boolean
;
//
limit
:
number
;
offset
?:
number
;
//
syncPageSize
?:
number
;
forceSync
?:
boolean
;
};
export
type
FeedsServiceGetResponse
=
{
entities
:
any
[];
next
?:
number
;
};
import
{
BehaviorSubject
,
Observable
,
combineLatest
}
from
'
rxjs
'
;
import
{
switchMap
,
map
,
tap
,
first
}
from
'
rxjs/operators
'
;
/**
* Enables the grabbing of data through observable feeds.
...
...
@@ -69,6 +37,7 @@ export class FeedsService {
this
.
pageSize
=
this
.
offset
.
pipe
(
map
(
offset
=>
this
.
limit
.
getValue
()
+
offset
)
);
this
.
feed
=
this
.
rawFeed
.
pipe
(
tap
(
feed
=>
{
if
(
feed
.
length
)
this
.
inProgress
.
next
(
true
);
...
...
@@ -87,6 +56,7 @@ export class FeedsService {
this
.
inProgress
.
next
(
false
);
})
);
this
.
hasMore
=
combineLatest
(
this
.
rawFeed
,
this
.
inProgress
,
...
...
This diff is collapsed.