first commit

This commit is contained in:
2025-09-14 23:05:30 -04:00
commit 2866d74b32
122 changed files with 95474 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import { Injectable, signal } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import type { AuthUser } from './auth.service';
export interface UserPreferences {
language?: string | null;
defaultProvider?: string | null;
theme?: 'light' | 'dark' | 'black' | 'system' | string | null;
videoQuality?: string | null;
region?: string | null;
version?: number | null;
}
@Injectable({ providedIn: 'root' })
export class UserService {
private _preferences = signal<UserPreferences | null>(null);
constructor(private http: HttpClient) {}
preferences() {
return this._preferences();
}
loadPreferences(): Observable<UserPreferences> {
return this.http.get<UserPreferences>('/proxy/api/user/preferences', { withCredentials: true }).pipe(
tap(p => this._preferences.set(p || {}))
);
}
updatePreferences(patch: Partial<UserPreferences>): Observable<UserPreferences> {
return this.http.patch<UserPreferences>('/proxy/api/user/preferences', patch, { withCredentials: true }).pipe(
tap(p => this._preferences.set(p || {}))
);
}
loadMe(): Observable<AuthUser> {
return this.http.get<AuthUser>('/proxy/api/user/me', { withCredentials: true });
}
}