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) {
let data = localStorage.getItem(key)|| "";
let data = localStorage.getItem(key) || "";
return this.decrypt(data);
}
public removeData(key: string) {

View File

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