mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
| // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
 | |
| 
 | |
| import Foundation
 | |
| import GRDB
 | |
| import SessionUtilitiesKit
 | |
| 
 | |
| extension MessageReceiver {
 | |
|     internal static func handleTypingIndicator(_ db: Database, message: TypingIndicator) throws {
 | |
|         guard
 | |
|             let senderPublicKey: String = message.sender,
 | |
|             let thread: SessionThread = try SessionThread.fetchOne(db, id: senderPublicKey)
 | |
|         else { return }
 | |
|         
 | |
|         switch message.kind {
 | |
|             case .started:
 | |
|                 let needsToStartTypingIndicator: Bool = TypingIndicators.didStartTypingNeedsToStart(
 | |
|                     threadId: thread.id,
 | |
|                     threadVariant: thread.variant,
 | |
|                     threadIsMessageRequest: thread.isMessageRequest(db),
 | |
|                     direction: .incoming,
 | |
|                     timestampMs: message.sentTimestamp.map { Int64($0) }
 | |
|                 )
 | |
|                 
 | |
|                 if needsToStartTypingIndicator {
 | |
|                     TypingIndicators.start(db, threadId: thread.id, direction: .incoming)
 | |
|                 }
 | |
|                 
 | |
|             case .stopped:
 | |
|                 TypingIndicators.didStopTyping(db, threadId: thread.id, direction: .incoming)
 | |
|             
 | |
|             default:
 | |
|                 SNLog("Unknown TypingIndicator Kind ignored")
 | |
|                 return
 | |
|         }
 | |
|     }
 | |
| }
 |