Code Cleanup

This commit is contained in:
abdellah
2022-11-03 19:31:15 +01:00
parent 1314b9a822
commit 37706f2716
2 changed files with 8 additions and 11 deletions

View File

@@ -13,7 +13,7 @@ export class LocalStorageService {
} }
public getData(key: string) { public getData(key: string) {
let data = localStorage.getItem(key)|| ""; let data = localStorage.getItem(key) || "";
return this.decrypt(data); return this.decrypt(data);
} }
public removeData(key: string) { public removeData(key: string) {

View File

@@ -21,18 +21,18 @@ export class VotesService {
return this.voteRef; return this.voteRef;
} }
getVotesCount(): Observable<number> { getVotesCount(): Observable<number> {
return this.voteRef.snapshotChanges().pipe(map(c=>{return c.length})); return this.voteRef.snapshotChanges().pipe(map(c => { return c.length }));
} }
addVote(vote: Vote): void { addVote(vote: Vote): void {
this.voteRef.add({...vote}); this.voteRef.add({ ...vote });
} }
vote(candidateID: number): void {
vote(candidateID: number): void {
try { try {
this.ipGeoLocationService.getIP().subscribe((IPData: any) => { this.ipGeoLocationService.getIP().subscribe((IPData: any) => {
const vote:Vote = { const vote: Vote = {
candidate: candidateID, candidate: candidateID,
timestamp: new Date(), timestamp: new Date(),
ip: IPData.ip_address, ip: IPData.ip_address,
@@ -42,7 +42,7 @@ export class VotesService {
this.addVote(vote); this.addVote(vote);
}); });
} catch (e) { } catch (e) {
const vote:Vote = { const vote: Vote = {
candidate: candidateID, candidate: candidateID,
timestamp: new Date(), timestamp: new Date(),
city: 'unknown', city: 'unknown',
@@ -51,9 +51,6 @@ export class VotesService {
}; };
this.addVote(vote); this.addVote(vote);
} }
} }
} }