frontend: update getRoomPreferences method to accept roomId and improve error handling
This commit is contained in:
parent
eed739d32d
commit
d770b89a71
@ -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`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user