mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-10-31 16:21:46 +01:00 
			
		
		
		
	Reorganize things and do some fixes
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
		
							parent
							
								
									8c67b96a0f
								
							
						
					
					
						commit
						67a052e46a
					
				| @ -73,26 +73,30 @@ export default class CallEventGrouper extends EventEmitter { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private setCallListeners() { |     private setCallListeners() { | ||||||
|  |         if (!this.call) return; | ||||||
|         this.call.addListener(CallEvent.State, this.setCallState); |         this.call.addListener(CallEvent.State, this.setCallState); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private setCallState = () => { |     private setCallState = () => { | ||||||
|         if (SUPPORTED_STATES.includes(this.call.state)) { |         if (SUPPORTED_STATES.includes(this.call?.state)) { | ||||||
|             this.state = this.call.state; |             this.state = this.call.state; | ||||||
|             this.emit(CallEventGrouperEvent.StateChanged, this.state); |         } else { | ||||||
|  |             const lastEvent = this.events[this.events.length - 1]; | ||||||
|  |             const lastEventType = lastEvent.getType(); | ||||||
|  | 
 | ||||||
|  |             if (lastEventType === EventType.CallHangup) this.state = CallState.Ended; | ||||||
|  |             else if (lastEventType === EventType.CallReject) this.state = CallState.Ended; | ||||||
|         } |         } | ||||||
|  |         this.emit(CallEventGrouperEvent.StateChanged, this.state); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public add(event: MatrixEvent) { |     public add(event: MatrixEvent) { | ||||||
|         this.events.push(event); |  | ||||||
|         const type = event.getType(); |  | ||||||
| 
 |  | ||||||
|         if (type === EventType.CallHangup) this.state = CallState.Ended; |  | ||||||
|         else if (type === EventType.CallReject) this.state = CallState.Ended; |  | ||||||
|         const callId = event.getContent().call_id; |         const callId = event.getContent().call_id; | ||||||
|         this.call = CallHandler.sharedInstance().getCallById(callId); |         this.events.push(event); | ||||||
|         if (!this.call) return; |         if (!this.call) { | ||||||
|         this.setCallListeners(); |             this.call = CallHandler.sharedInstance().getCallById(callId); | ||||||
|  |             this.setCallListeners(); | ||||||
|  |         } | ||||||
|         this.setCallState(); |         this.setCallState(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user