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
810
Merge Requests
54
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
f5118c96
Commit
f5118c96
authored
1 hour ago
by
Ben Hayward
Browse files
Options
Download
Refactored and got rid of account switching bug
parent
908ebf3f
fix/avatar-change-detection-2197
1 merge request
!628
[Sprint/QuietQuail](fix): Avatar changing forms now change avatar without refresh of components
Pipeline
#93466360
passed with stages
in 73 minutes
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
src/app/common/services/user-avatar.service.ts
View file @
f5118c96
...
...
@@ -4,17 +4,28 @@
*/
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
BehaviorSubject
}
from
'
rxjs
'
;
import
{
Session
}
from
'
../../services/session
'
;
import
{
MindsUser
}
from
'
../../interfaces/entities
'
;
@
Injectable
({
providedIn
:
'
root
'
,
})
export
class
UserAvatarService
{
private
minds
=
window
.
Minds
;
public
src$
:
BehaviorSubject
<
string
>
=
new
BehaviorSubject
(
null
);
private
user
:
MindsUser
;
public
src$
:
BehaviorSubject
<
string
>
;
constructor
()
{
this
.
src$
.
next
(
`
${
this
.
minds
.
cdn_url
}
icon/
${
this
.
minds
.
user
.
guid
}
/large/
${
this
.
minds
.
user
.
icontime
}
`
constructor
(
public
session
:
Session
)
{
this
.
init
();
}
/**
* Sets the current user and avatar src.
*/
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 diff is collapsed.
src/app/modules/forms/login/login.ts
View file @
f5118c96
...
...
@@ -3,6 +3,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import
{
Client
}
from
'
../../../services/api
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
UserAvatarService
}
from
'
../../../common/services/user-avatar.service
'
;
@
Component
({
moduleId
:
module
.
id
,
...
...
@@ -31,7 +32,8 @@ export class LoginForm {
public
session
:
Session
,
public
client
:
Client
,
fb
:
FormBuilder
,
private
zone
:
NgZone
private
zone
:
NgZone
,
private
userAvatarService
:
UserAvatarService
)
{
this
.
form
=
fb
.
group
({
username
:
[
''
,
Validators
.
required
],
...
...
@@ -65,6 +67,7 @@ export class LoginForm {
// TODO: [emi/sprint/bison] Find a way to reset controls. Old implementation throws Exception;
this
.
inProgress
=
false
;
this
.
session
.
login
(
data
.
user
);
this
.
userAvatarService
.
init
();
this
.
done
.
next
(
data
.
user
);
})
.
catch
(
e
=>
{
...
...
@@ -102,6 +105,7 @@ export class LoginForm {
})
.
then
((
data
:
any
)
=>
{
this
.
session
.
login
(
data
.
user
);
this
.
userAvatarService
.
init
();
this
.
done
.
next
(
data
.
user
);
})
.
catch
(
e
=>
{
...
...
This diff is collapsed.
Please
register
or
sign in
to comment