Skip to content

Commit

Permalink
refactor(app): remove strict casing when unecessary + improve online …
Browse files Browse the repository at this point in the history
…ghost loading request
  • Loading branch information
mathieuher committed Dec 15, 2024
1 parent f184e1b commit d04fcbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/app/common/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { catchError, from, map, of, type Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import type { HealthCheckResponse, RecordAuthResponse, RecordModel } from 'pocketbase';
import type { RecordAuthResponse, RecordModel } from 'pocketbase';
import { User } from '../models/user';
import { FormatterUtils } from '../utils/formatter.utils';

Expand Down Expand Up @@ -29,14 +29,18 @@ export class AuthService {
}

public login$(email: string, password: string): Observable<RecordAuthResponse> {
return from(environment.pb.collection('users').authWithPassword(FormatterUtils.valueFormatter(email, 'lower')!, password));
return from(
environment.pb
.collection('users')
.authWithPassword(FormatterUtils.valueFormatter(email, 'lower')!, password)
);
}

public register$(email: string, name: string, password: string): Observable<User> {
return from(
environment.pb.collection('users').create({
email: FormatterUtils.valueFormatter(email, 'lower'),
name: FormatterUtils.valueFormatter(name, 'name'),
name: name,
password,
passwordConfirm: password
})
Expand Down
7 changes: 1 addition & 6 deletions src/app/common/services/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { combineLatest, concatMap, from, map, mergeAll, reduce, type Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import type { RecordModel } from 'pocketbase';
import { FormatterUtils } from '../utils/formatter.utils';
import type { User } from '../models/user';
import type { Server } from '../models/server';
import type { ServerRider } from '../models/server-rider';
Expand All @@ -18,11 +17,7 @@ export class ServerService {
}

public createServer$(name: string, user: User): Observable<RecordModel> {
return from(
environment.pb
.collection('servers')
.create({ name: FormatterUtils.valueFormatter(name, 'name'), owner: user.id })
);
return from(environment.pb.collection('servers').create({ name: name, owner: user.id }));
}

public getUserServers$(): Observable<Server[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/app/common/services/track.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export class TrackService {

private getOnlineTrackGhost$(trackId: string, eventId?: string): Observable<StockableGhost | undefined> {
const query = { track: trackId, event: eventId || undefined };
return from(environment.pb.collection('ghosts').getFullList({ query: query, sort: 'totalTime' })).pipe(
map(records => records[0]),
return from(environment.pb.collection('ghosts').getList(1, 1, { query: query, sort: 'totalTime' })).pipe(
map(records => records.items[0]),
map(record => {
if (!record) {
return undefined;
Expand Down

0 comments on commit d04fcbf

Please sign in to comment.