frontend: update getRoomPreferences method to accept roomId and improve error handling

This commit is contained in:
Carlos Santos 2025-06-11 18:02:02 +02:00
parent eed739d32d
commit d770b89a71
2 changed files with 19 additions and 5 deletions

View File

@ -72,13 +72,12 @@ export class HttpService {
} }
/** /**
* TODO: Delete this method
* Retrieves the room preferences. * Retrieves the room preferences.
* *
* @returns {Promise<MeetRoomPreferences>} A promise that resolves to the room preferences. * @returns {Promise<MeetRoomPreferences>} A promise that resolves to the room preferences.
*/ */
getRoomPreferences(): Promise<MeetRoomPreferences> { getRoomPreferences(roomId: string): Promise<MeetRoomPreferences> {
return this.getRequest(`${this.API_PATH_PREFIX}/preferences/room`); return this.getRequest(`${this.INTERNAL_API_PATH_PREFIX}/rooms/${roomId}/preferences`);
} }
/** /**

View File

@ -41,6 +41,22 @@ export class RoomService {
return this.httpService.getRoom(roomId); return this.httpService.getRoom(roomId);
} }
async getRoomPreferences(roomId: string): Promise<MeetRoomPreferences> {
this.log.d('Fetching room preferences for roomId:', roomId);
try {
const preferences = await this.httpService.getRoomPreferences(roomId);
if (!preferences) {
this.log.w('Room preferences not found for roomId:', roomId);
throw new Error(`Preferences not found for roomId: ${roomId}`);
}
return preferences;
} catch (error) {
this.log.e('Error fetching room preferences', error);
throw new Error(`Failed to fetch room preferences for roomId: ${roomId}`);
}
}
async loadPreferences(roomId: string, forceUpdate: boolean = false): Promise<MeetRoomPreferences> { async loadPreferences(roomId: string, forceUpdate: boolean = false): Promise<MeetRoomPreferences> {
if (this.roomPreferences && !forceUpdate) { if (this.roomPreferences && !forceUpdate) {
this.log.d('Returning cached room preferences'); this.log.d('Returning cached room preferences');
@ -49,8 +65,7 @@ export class RoomService {
this.log.d('Fetching room preferences from server'); this.log.d('Fetching room preferences from server');
try { try {
const room = await this.getRoom(roomId); this.roomPreferences = await this.getRoomPreferences(roomId);
this.roomPreferences = room.preferences! as MeetRoomPreferences;
this.featureConfService.setRoomPreferences(this.roomPreferences); this.featureConfService.setRoomPreferences(this.roomPreferences);
console.log('Room preferences loaded:', this.roomPreferences); console.log('Room preferences loaded:', this.roomPreferences);
return this.roomPreferences; return this.roomPreferences;