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
808
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
8871491e
Commit
8871491e
authored
8 minutes ago
by
Ben Hayward
Browse files
Options
Download
Updated to account for session switching
parent
f5118c96
fix/avatar-change-detection-2197
1 merge request
!628
[Sprint/QuietQuail](fix): Avatar changing forms now change avatar without refresh of components
Pipeline
#94148616
running with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
src/app/common/services/user-avatar.service.ts
View file @
8871491e
...
...
@@ -3,7 +3,7 @@
* @desc Singleton service used to store the current user avatar as a BehaviorSubject.
*/
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
BehaviorSubject
,
Subscription
}
from
'
rxjs
'
;
import
{
Session
}
from
'
../../services/session
'
;
import
{
MindsUser
}
from
'
../../interfaces/entities
'
;
...
...
@@ -14,9 +14,17 @@ export class UserAvatarService {
private
minds
=
window
.
Minds
;
private
user
:
MindsUser
;
public
src$
:
BehaviorSubject
<
string
>
;
public
loggedIn$
:
Subscription
;
constructor
(
public
session
:
Session
)
{
this
.
init
();
// Subscribe to loggedIn$ and on login, update src$.
this
.
loggedIn$
=
this
.
session
.
loggedinEmitter
.
subscribe
(
is
=>
{
if
(
is
)
{
this
.
src$
.
next
(
this
.
getSrc
());
}
});
}
/**
...
...
@@ -24,8 +32,13 @@ export class UserAvatarService {
*/
public
init
():
void
{
this
.
user
=
this
.
session
.
getLoggedInUser
();
this
.
src$
=
new
BehaviorSubject
(
`
${
this
.
minds
.
cdn_url
}
icon/
${
this
.
user
.
guid
}
/large/
${
this
.
user
.
icontime
}
`
);
this
.
src$
=
new
BehaviorSubject
(
this
.
getSrc
());
}
/**
* Gets the Src string using the global minds object and the held user object.
*/
public
getSrc
():
string
{
return
`
${
this
.
minds
.
cdn_url
}
icon/
${
this
.
user
.
guid
}
/large/
${
this
.
user
.
icontime
}
`
;
}
}
This diff is collapsed.
Please
register
or
sign in
to comment