frontend: update loadPreferences method to load room preferences and set feature configuration without caching

This commit is contained in:
juancarmore 2025-08-13 17:48:08 +02:00
parent 5f672c86b3
commit e926dc2de7
2 changed files with 8 additions and 18 deletions

View File

@ -257,7 +257,7 @@ export class MeetingComponent implements OnInit {
try { try {
await this.generateParticipantToken(); await this.generateParticipantToken();
await this.addParticipantNameToUrl(); await this.addParticipantNameToUrl();
await this.roomService.loadPreferences(this.roomId); await this.roomService.loadRoomPreferences(this.roomId);
this.showMeeting = true; this.showMeeting = true;
// Subscribe to remote participants updates for showing/hiding the share meeting link component // Subscribe to remote participants updates for showing/hiding the share meeting link component
this.componentParticipantService.remoteParticipants$ this.componentParticipantService.remoteParticipants$
@ -332,7 +332,6 @@ export class MeetingComponent implements OnInit {
if (topic === MeetSignalType.MEET_ROOM_PREFERENCES_UPDATED) { if (topic === MeetSignalType.MEET_ROOM_PREFERENCES_UPDATED) {
const { preferences } = event as MeetRoomPreferencesUpdatedPayload; const { preferences } = event as MeetRoomPreferencesUpdatedPayload;
this.featureConfService.setRoomPreferences(preferences); this.featureConfService.setRoomPreferences(preferences);
// TODO: Update local state with new room preferences
} else if (topic === MeetSignalType.MEET_PARTICIPANT_ROLE_UPDATED) { } else if (topic === MeetSignalType.MEET_PARTICIPANT_ROLE_UPDATED) {
const { participantIdentity, newRole, secret } = event as MeetParticipantRoleUpdatedPayload; const { participantIdentity, newRole, secret } = event as MeetParticipantRoleUpdatedPayload;

View File

@ -18,7 +18,6 @@ export class RoomService {
protected roomId: string = ''; protected roomId: string = '';
protected roomSecret: string = ''; protected roomSecret: string = '';
protected roomPreferences?: MeetRoomPreferences;
protected log; protected log;
@ -169,24 +168,16 @@ export class RoomService {
} }
/** /**
* Loads the room preferences, either from cache or by fetching from the server. * Loads the room preferences and updates the feature configuration service.
* *
* @param roomId - The unique identifier of the room * @param roomId - The unique identifier of the room
* @param forceUpdate - Whether to force an update from the server
* @returns A promise that resolves to the MeetRoomPreferences object
*/ */
async loadPreferences(roomId: string, forceUpdate: boolean = false): Promise<MeetRoomPreferences> { async loadRoomPreferences(roomId: string): Promise<void> {
if (this.roomPreferences && !forceUpdate) {
this.log.d('Returning cached room preferences');
return this.roomPreferences;
}
this.log.d('Fetching room preferences from server'); this.log.d('Fetching room preferences from server');
try { try {
this.roomPreferences = await this.getRoomPreferences(roomId); const preferences = await this.getRoomPreferences(roomId);
this.featureConfService.setRoomPreferences(this.roomPreferences); this.featureConfService.setRoomPreferences(preferences);
console.log('Room preferences loaded:', this.roomPreferences); console.log('Room preferences loaded:', preferences);
return this.roomPreferences;
} catch (error) { } catch (error) {
this.log.e('Error loading room preferences', error); this.log.e('Error loading room preferences', error);
throw new Error('Failed to load room preferences'); throw new Error('Failed to load room preferences');
@ -194,8 +185,9 @@ export class RoomService {
} }
/** /**
* Saves the room preferences. * Saves new room preferences.
* *
* @param roomId - The unique identifier of the room
* @param preferences - The room preferences to be saved. * @param preferences - The room preferences to be saved.
* @returns A promise that resolves when the preferences have been saved. * @returns A promise that resolves when the preferences have been saved.
*/ */
@ -203,7 +195,6 @@ export class RoomService {
this.log.d('Saving room preferences', preferences); this.log.d('Saving room preferences', preferences);
const path = `${this.ROOMS_API}/${roomId}`; const path = `${this.ROOMS_API}/${roomId}`;
await this.httpService.putRequest(path, preferences); await this.httpService.putRequest(path, preferences);
this.roomPreferences = preferences;
} }
/** /**