Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
828
Issues
828
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
6b663682
Commit
6b663682
authored
1 hour ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(chore): use maps for object
parent
94ed6cc6
refactor/es-feeds
1 merge request
!373
Refactor/es feeds
Pipeline
#67989225
failed with stage
in 8 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
entities.service.ts
src/app/common/services/entities.service.ts
+13
-16
No files found.
src/app/common/services/entities.service.ts
View file @
6b663682
...
...
@@ -11,15 +11,12 @@ import AsyncStatus from "../../helpers/async-status";
import
normalizeUrn
from
"../../helpers/normalize-urn"
;
type
EntityObservable
=
BehaviorSubject
<
Object
>
;
interface
EntityObservables
{
[
key
:
string
]:
EntityObservable
}
type
EntityObservables
=
Map
<
string
,
EntityObservable
>
@
Injectable
()
export
class
EntitiesService
{
entities
:
EntityObservables
=
{}
;
entities
:
EntityObservables
=
new
Map
<
string
,
EntityObservable
>
()
;
constructor
(
protected
client
:
Client
,
...
...
@@ -42,10 +39,10 @@ export class EntitiesService {
if
(
feedItem
.
entity
)
{
this
.
addEntity
(
feedItem
.
entity
);
}
if
(
!
this
.
entities
[
feedItem
.
urn
]
)
{
if
(
!
this
.
entities
.
has
(
feedItem
.
urn
)
)
{
urnsToFetch
.
push
(
feedItem
.
urn
);
}
if
(
this
.
entities
[
feedItem
.
urn
]
&&
!
feedItem
.
entity
)
{
if
(
this
.
entities
.
has
(
feedItem
.
urn
)
&&
!
feedItem
.
entity
)
{
urnsToResync
.
push
(
feedItem
.
urn
);
}
}
...
...
@@ -64,7 +61,7 @@ export class EntitiesService {
for
(
const
feedItem
of
feed
)
{
if
(
blockedGuids
.
indexOf
(
feedItem
.
owner_guid
)
<
0
)
entities
.
push
(
this
.
entities
[
feedItem
.
urn
]
);
entities
.
push
(
this
.
entities
.
get
(
feedItem
.
urn
)
);
}
return
entities
;
...
...
@@ -80,11 +77,11 @@ export class EntitiesService {
urn
=
`urn:activity:
${
urn
}
`
;
// and assume activity
}
this
.
entities
[
urn
]
=
new
BehaviorSubject
(
null
);
this
.
entities
.
set
(
urn
,
new
BehaviorSubject
(
null
)
);
this
.
fetch
([
urn
]);
// Update in the background
return
this
.
entities
[
urn
]
;
return
this
.
entities
.
get
(
urn
)
;
}
/**
...
...
@@ -119,10 +116,10 @@ export class EntitiesService {
* @return void
*/
addEntity
(
entity
):
void
{
if
(
this
.
entities
[
entity
.
urn
]
)
{
this
.
entities
[
entity
.
urn
]
.
next
(
entity
);
if
(
this
.
entities
.
has
(
entity
.
urn
)
)
{
this
.
entities
.
get
(
entity
.
urn
)
.
next
(
entity
);
}
else
{
this
.
entities
[
entity
.
urn
]
=
new
BehaviorSubject
(
entity
);
this
.
entities
.
set
(
entity
.
urn
,
new
BehaviorSubject
(
entity
)
);
}
}
...
...
@@ -132,10 +129,10 @@ export class EntitiesService {
* @return void
*/
addNotFoundEntity
(
urn
):
void
{
if
(
!
this
.
entities
[
urn
]
)
{
this
.
entities
[
urn
]
=
new
BehaviorSubject
(
null
);
if
(
!
this
.
entities
.
has
(
urn
)
)
{
this
.
entities
.
set
(
urn
,
new
BehaviorSubject
(
null
)
);
}
this
.
entities
[
urn
]
.
error
(
"Not found"
);
this
.
entities
.
get
(
urn
)
.
error
(
"Not found"
);
}
static
_
(
client
:
Client
,
blockListService
:
BlockListService
)
{
...
...
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