Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit e5823c0

Browse files
merge: more user settings
2 parents fb9ed46 + d00420c commit e5823c0

File tree

10 files changed

+337
-64
lines changed

10 files changed

+337
-64
lines changed

studio/src/app/components/core/app-navigation-actions/app-navigation-actions.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {Component, Event, EventEmitter, Prop, State, h} from '@stencil/core';
33
import {Subscription} from 'rxjs';
44

55
import {AuthUser} from '../../../models/auth/auth.user';
6+
import {User} from '../../../models/data/user';
67

78
import {Utils} from '../../../utils/core/utils';
89
import {IonControllerUtils} from '../../../utils/core/ion-controller-utils';
910

1011
import {AuthService} from '../../../services/auth/auth.service';
1112
import {NavDirection, NavService} from '../../../services/core/nav/nav.service';
13+
import {UserService} from '../../../services/data/user/user.service';
1214

1315
@Component({
1416
tag: 'app-navigation-actions',
@@ -26,26 +28,41 @@ export class AppNavigationActions {
2628

2729
private navService: NavService;
2830

31+
private userService: UserService;
32+
private userSubscription: Subscription;
33+
2934
@State()
3035
private authUser: AuthUser;
3136

37+
@State()
38+
private photoUrl: string;
39+
3240
@Event() private actionPublish: EventEmitter<void>;
3341

3442
constructor() {
3543
this.authService = AuthService.getInstance();
3644
this.navService = NavService.getInstance();
45+
this.userService = UserService.getInstance();
3746
}
3847

3948
componentWillLoad() {
4049
this.subscription = this.authService.watch().subscribe((authUser: AuthUser) => {
4150
this.authUser = authUser;
4251
});
52+
53+
this.userSubscription = this.userService.watch().subscribe((user: User) => {
54+
this.photoUrl = user && user.data ? user.data.photo_url : undefined;
55+
});
4356
}
4457

4558
componentDidUnload() {
4659
if (this.subscription) {
4760
this.subscription.unsubscribe();
4861
}
62+
63+
if (this.userSubscription) {
64+
this.userSubscription.unsubscribe();
65+
}
4966
}
5067

5168
private async openMenu($event: UIEvent) {
@@ -85,9 +102,9 @@ export class AppNavigationActions {
85102
}
86103

87104
private renderLoggedIn() {
88-
if (Utils.isLoggedIn(this.authUser)) {
105+
if (Utils.isLoggedIn(this.authUser) && this.photoUrl) {
89106
return <a class="ion-padding-end" onClick={(e: UIEvent) => this.openMenu(e)}>
90-
<app-avatar src={this.authUser.photo_url}></app-avatar>
107+
<app-avatar src={this.photoUrl}></app-avatar>
91108
</a>;
92109
} else {
93110
return undefined;

studio/src/app/components/core/app-user-info/app-user-info.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {Component, Prop, State, h} from '@stencil/core';
33
import {Subscription} from 'rxjs';
44

55
import {AuthUser} from '../../../models/auth/auth.user';
6+
import {User} from '../../../models/data/user';
67

78
import {AuthService} from '../../../services/auth/auth.service';
89
import {ApiUserService} from '../../../services/api/user/api.user.service';
910
import {ApiUser} from '../../../models/api/api.user';
11+
import {UserService} from '../../../services/data/user/user.service';
1012

1113
@Component({
1214
tag: 'app-user-info',
@@ -23,15 +25,25 @@ export class AppUserInfo {
2325
private apiUserService: ApiUserService;
2426
private apiUserSubscription: Subscription;
2527

28+
private userService: UserService;
29+
private userSubscription: Subscription;
30+
2631
@State()
2732
private authUser: AuthUser;
2833

2934
@State()
3035
private apiUser: ApiUser;
3136

37+
@State()
38+
private name: string;
39+
40+
@State()
41+
private photoUrl: string;
42+
3243
constructor() {
3344
this.authService = AuthService.getInstance();
3445
this.apiUserService = ApiUserService.getInstance();
46+
this.userService = UserService.getInstance();
3547
}
3648

3749
componentWillLoad() {
@@ -42,6 +54,11 @@ export class AppUserInfo {
4254
this.apiUserSubscription = this.apiUserService.watch().subscribe((user: ApiUser) => {
4355
this.apiUser = user;
4456
});
57+
58+
this.userSubscription = this.userService.watch().subscribe((user: User) => {
59+
this.name = user && user.data ? user.data.name : undefined;
60+
this.photoUrl = user && user.data ? user.data.photo_url : undefined;
61+
});
4562
}
4663

4764
componentDidUnload() {
@@ -52,15 +69,19 @@ export class AppUserInfo {
5269
if (this.apiUserSubscription) {
5370
this.apiUserSubscription.unsubscribe();
5471
}
72+
73+
if (this.userSubscription) {
74+
this.userSubscription.unsubscribe();
75+
}
5576
}
5677

5778
render() {
5879
if (this.authUser) {
5980
return <ion-grid>
6081
<ion-row class="ion-align-items-center">
61-
<ion-col size={'' + this.avatarColSize}><app-avatar src={this.authUser.photo_url}></app-avatar></ion-col>
82+
<ion-col size={'' + this.avatarColSize}><app-avatar src={this.photoUrl}></app-avatar></ion-col>
6283
<ion-col size={'' + (12 - this.avatarColSize)} class="user-info">
63-
<ion-label>{this.authUser.name}</ion-label>
84+
<ion-label>{this.name}</ion-label>
6485
<ion-label>{!this.authUser.anonymous && this.apiUser && this.apiUser.username ? '@' + this.apiUser.username : undefined}</ion-label>
6586
</ion-col>
6687
</ion-row>

studio/src/app/modals/editor/app-custom-images/app-custom-images.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class AppCustomImages {
173173
if (filePicker.files && filePicker.files.length > 0) {
174174
this.uploading = true;
175175

176-
const storageFile: StorageFile = await this.storageService.uploadImage(filePicker.files[0]);
176+
const storageFile: StorageFile = await this.storageService.uploadImage(filePicker.files[0], 'images');
177177

178178
if (storageFile) {
179179
await this.selectAndClose(storageFile);

studio/src/app/models/data/user.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export interface UserData {
22
anonymous: boolean;
33

44
name?: string;
5+
email?: string;
6+
newsletter?: boolean;
57
photo_url?: string;
68

79
created_at: firebase.firestore.Timestamp;

studio/src/app/pages/core/app-settings/app-settings.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,32 @@ app-settings {
55
ion-router-link {
66
cursor: pointer;
77
}
8+
9+
div.newsletter, div.avatar {
10+
padding: 8px;
11+
12+
display: flex;
13+
justify-content: flex-start;
14+
align-items: center;
15+
}
16+
17+
div.newsletter {
18+
ion-checkbox {
19+
margin-left: 8px;
20+
}
21+
}
22+
23+
div.avatar {
24+
--deckgo-avatar-size: 3rem;
25+
26+
input {
27+
padding-left: 8px;
28+
padding-right: 8px;
29+
}
30+
}
31+
32+
p.info {
33+
font-size: var(--font-size-small);
34+
}
835
}
936
}

0 commit comments

Comments
 (0)