@@ -98,15 +98,25 @@ export class Launcher extends Observable implements DefaultLauncher {
98
98
} ) ;
99
99
100
100
this . activeComponents . push ( component . name ) ;
101
- this . activeComponentsInstances . push ( component ) ;
101
+
102
+ if ( this . activeComponentsInstances . some ( ( c ) => c . name === component . name ) ) {
103
+ this . activeComponentsInstances = this . activeComponentsInstances . map ( ( ac ) => {
104
+ if ( ac . name === component . name ) {
105
+ return component ;
106
+ }
107
+ return ac ;
108
+ } ) ;
109
+ } else {
110
+ this . activeComponentsInstances . push ( component ) ;
111
+ }
102
112
103
113
localParticipant . publish ( {
104
- ...this . participant ,
114
+ ...localParticipant . value ,
105
115
activeComponents : this . activeComponents ,
106
116
} ) ;
107
117
108
118
this . room . presence . update ( {
109
- ...this . participant ,
119
+ ...localParticipant . value ,
110
120
slot : this . slotService . slot ,
111
121
activeComponents : this . activeComponents ,
112
122
} ) ;
@@ -141,7 +151,7 @@ export class Launcher extends Observable implements DefaultLauncher {
141
151
*/
142
152
public removeComponent = ( component : Partial < BaseComponent > ) : void => {
143
153
if ( ! this . activeComponents . includes ( component . name ) ) {
144
- const message = `Component ${ component . name } is not initialized yet.` ;
154
+ const message = `[SuperViz] Component ${ component . name } is not initialized yet.` ;
145
155
this . logger . log ( message ) ;
146
156
console . error ( message ) ;
147
157
return ;
@@ -176,15 +186,14 @@ export class Launcher extends Observable implements DefaultLauncher {
176
186
this . activeComponents = [ ] ;
177
187
this . activeComponentsInstances = [ ] ;
178
188
179
- useGlobalStore ( ) . destroy ( ) ;
189
+ useGlobalStore ( ) ? .destroy ( ) ;
180
190
181
- this . eventBus . destroy ( ) ;
191
+ this . eventBus ? .destroy ( ) ;
182
192
this . eventBus = undefined ;
183
193
184
194
this . room ?. presence . off ( Socket . PresenceEvents . JOINED_ROOM ) ;
185
195
this . room ?. presence . off ( Socket . PresenceEvents . LEAVE ) ;
186
196
this . room ?. presence . off ( Socket . PresenceEvents . UPDATE ) ;
187
- this . ioc . stateSubject . unsubscribe ( ) ;
188
197
this . ioc ?. destroy ( ) ;
189
198
190
199
this . isDestroyed = true ;
@@ -207,20 +216,20 @@ export class Launcher extends Observable implements DefaultLauncher {
207
216
const verifications = [
208
217
{
209
218
isValid : isProvidedFeature ,
210
- message : `Component ${ component . name } is not enabled in the room` ,
219
+ message : `[SuperViz] Component ${ component . name } is not enabled in the room` ,
211
220
} ,
212
221
{
213
222
isValid : ! this . isDestroyed ,
214
223
message :
215
- 'Component can not be added because the superviz room is destroyed. Initialize a new room to add and use components.' ,
224
+ '[SuperViz] Component can not be added because the superviz room is destroyed. Initialize a new room to add and use components.' ,
216
225
} ,
217
226
{
218
227
isValid : ! isComponentActive ,
219
- message : `Component ${ component . name } is already active. Please remove it first` ,
228
+ message : `[SuperViz] Component ${ component . name } is already active. Please remove it first` ,
220
229
} ,
221
230
{
222
231
isValid : componentLimit . canUse ,
223
- message : `You reached the limit usage of ${ component . name } ` ,
232
+ message : `[SuperViz] You reached the limit usage of ${ component . name } ` ,
224
233
} ,
225
234
] ;
226
235
@@ -252,16 +261,6 @@ export class Launcher extends Observable implements DefaultLauncher {
252
261
) ;
253
262
} ;
254
263
255
- private onLocalParticipantUpdate = ( participant : Participant ) : void => {
256
- this . activeComponents = participant . activeComponents || [ ] ;
257
-
258
- if ( this . activeComponents . length ) {
259
- this . activeComponentsInstances = this . activeComponentsInstances . filter ( ( ac ) => {
260
- return this . activeComponents . includes ( ac . name ) ;
261
- } ) ;
262
- }
263
- } ;
264
-
265
264
/**
266
265
* @function onLocalParticipantUpdateOnStore
267
266
* @description handles the update of the local participant in the store.
@@ -271,12 +270,6 @@ export class Launcher extends Observable implements DefaultLauncher {
271
270
private onLocalParticipantUpdateOnStore = ( participant : Participant ) : void => {
272
271
this . participant = participant ;
273
272
this . activeComponents = participant . activeComponents || [ ] ;
274
-
275
- if ( this . activeComponents . length ) {
276
- this . activeComponentsInstances = this . activeComponentsInstances . filter ( ( component ) => {
277
- return this . activeComponents . includes ( component . name ) ;
278
- } ) ;
279
- }
280
273
} ;
281
274
282
275
private onSameAccount = ( ) : void => {
0 commit comments