Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 110acfd

Browse files
committed
fix: linting, firebase imports
1 parent 6019b6b commit 110acfd

6 files changed

Lines changed: 17 additions & 22 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devintent/angular-example",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"license": "UNLICENSED",
55
"repository": {
66
"type": "git",
@@ -19,7 +19,7 @@
1919
"start:sw": "http-server dist/ -p 4200 -o",
2020
"start:prod": "ng serve --prod",
2121
"deploy": "firebase deploy --project prod",
22-
"lint": "ng lint --type-check",
22+
"lint": "ng lint",
2323
"ng": "ng",
2424
"smex": "source-map-explorer",
2525
"stylelint": "stylelint 'src/**/*.scss' --config stylelint-config.json --syntax scss",

src/app/api.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import {HttpHeaders} from '@angular/common/http';
33
import {Observer} from 'rxjs/Observer';
44
import {Observable} from 'rxjs/Observable';
55
import {AngularFireAuth} from '@angular/fire/auth';
6-
import * as firebase from 'firebase/app';
6+
import {User} from 'firebase/app';
77

88
@Injectable()
99
export class ApiService {
1010
public idTokenObservable: Observable<string>;
1111

1212
constructor(private fbAuth: AngularFireAuth) {
13-
this.idTokenObservable = Observable.create((observer: Observer<string>) => {
14-
this.fbAuth.authState.subscribe((authState: firebase.User) => {
13+
this.idTokenObservable = new Observable((observer: Observer<string>) => {
14+
this.fbAuth.authState.subscribe((authState: User) => {
1515
if (authState) {
1616
authState.getIdToken().then((token: string) => {
1717
observer.next(token);

src/app/users.service.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {Injectable} from '@angular/core';
22
import {Subscription} from 'rxjs/Subscription';
33
import {AngularFireDatabase, AngularFireObject} from '@angular/fire/database';
44
import {AngularFireAuth} from '@angular/fire/auth';
5-
import * as firebase from 'firebase/app';
65
import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router';
76
import {GoogleAnalyticsService} from './google-analytics.service';
87
import {FullStoryService} from './fullstory.service';
@@ -11,16 +10,17 @@ import {BehaviorSubject} from 'rxjs/BehaviorSubject';
1110
import {Observable} from 'rxjs/Observable';
1211
import {CodeConfirmationDialog} from './code-confirmation-dialog/code-confirmation.dialog';
1312
import {MatDialog} from '@angular/material/dialog';
13+
import {auth, User as FirebaseUser} from 'firebase/app';
1414

1515
@Injectable()
1616
export class UsersService implements CanActivate {
1717
private adminSubscription: Subscription;
1818
private userSubscription: Subscription;
19-
public authState: firebase.User;
19+
public authState: FirebaseUser;
2020
public isLoggedIn: boolean = false;
2121
public isAdmin: boolean = false;
2222
public currentUser: User;
23-
private userBehaviorSubject: BehaviorSubject<User>;
23+
private readonly userBehaviorSubject: BehaviorSubject<User>;
2424
public firebaseUserObservable: Observable<User>;
2525
public firebaseUser: AngularFireObject<User>;
2626

@@ -32,7 +32,7 @@ export class UsersService implements CanActivate {
3232
this.userBehaviorSubject = new BehaviorSubject(null);
3333
this.handleRedirect();
3434

35-
this.fbAuth.authState.subscribe((authState: firebase.User) => {
35+
this.fbAuth.authState.subscribe((authState: FirebaseUser) => {
3636
this.authState = authState;
3737

3838
if (authState) {
@@ -60,7 +60,7 @@ export class UsersService implements CanActivate {
6060
login(): void {
6161
this.gaService.sendEvent('accounts', 'login');
6262
if (this.authState && this.authState.isAnonymous) {
63-
this.fbAuth.auth.currentUser.linkWithRedirect(new firebase.auth.GoogleAuthProvider())
63+
this.fbAuth.auth.currentUser.linkWithRedirect(new auth.GoogleAuthProvider())
6464
.catch((error: any) => {
6565
if (error.credential) {
6666
this.signInWithCredential(error.credential);
@@ -70,7 +70,7 @@ export class UsersService implements CanActivate {
7070
}
7171
});
7272
} else {
73-
this.fbAuth.auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider())
73+
this.fbAuth.auth.signInWithRedirect(new auth.GoogleAuthProvider())
7474
.catch((error) => {
7575
console.error(`signInWithRedirect failed: ${JSON.stringify(error)}`);
7676
this.gaService.sendEvent('accounts', 'signInWithRedirect_failure');
@@ -95,7 +95,7 @@ export class UsersService implements CanActivate {
9595
});
9696
}
9797

98-
signInWithCredential(credential: firebase.auth.AuthCredential): void {
98+
signInWithCredential(credential: auth.AuthCredential): void {
9999
this.fbAuth.auth.signInWithCredential(credential)
100100
.catch((signInError) => {
101101
console.error(`signInWithCredential failed: ${JSON.stringify(signInError)}`);
@@ -114,11 +114,11 @@ export class UsersService implements CanActivate {
114114
});
115115
}
116116

117-
private setCurrentLoggedInUser(authState: firebase.User) {
117+
private setCurrentLoggedInUser(authState: FirebaseUser) {
118118
this.isLoggedIn = !!authState && !authState.isAnonymous;
119119
this.gaService.setUserId(authState.uid);
120120
this.fullStoryService.setUser(authState.uid,
121-
authState.displayName || 'Anonymous', authState.email || 'anonymous@marketamplified.com');
121+
authState.displayName || 'Anonymous', authState.email || 'anonymous@devintent.com');
122122

123123
if (!authState.isAnonymous) {
124124
this.firebaseUser = this.db.object<User>('/users/' + authState.uid);
@@ -196,11 +196,7 @@ export class UsersService implements CanActivate {
196196
const isAdminObservable: Observable<any> = this.db.object('/admins/' + user.uid).valueChanges();
197197
this.adminSubscription = isAdminObservable.subscribe(
198198
data => {
199-
if (data) {
200-
this.isAdmin = true;
201-
} else {
202-
this.isAdmin = false;
203-
}
199+
this.isAdmin = !!data;
204200
},
205201
err => {
206202
console.error('Failed to read from ' + '/admins/' + user.uid + ': ' + err);

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<div class="toolbarShell"></div>
114114
<div class="container">
115115
<div class="feature-image-wrapper">
116-
<img src="assets/images/Market_Amplified_logo_teal.svg"/>
116+
<img src="assets/images/Market_Amplified_logo_teal.svg" alt="teal logo"/>
117117
</div>
118118
</div>
119119
<span class="loadingMsg">Loading...</span>

src/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
height: 400px;
3434
}
3535
}
36-
input[type="search"] {
36+
input[type='search'] {
3737
-webkit-appearance: textfield;
3838
}

tslint.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"variable-declaration": "nospace"
9797
}
9898
],
99-
"typeof-compare": true,
10099
"unified-signatures": true,
101100
"variable-name": false,
102101
"whitespace": [

0 commit comments

Comments
 (0)