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.
34 lines
1.1 KiB
Swift
34 lines
1.1 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:
|
|
TypingIndicators.didStartTyping(
|
|
db,
|
|
threadId: thread.id,
|
|
threadVariant: thread.variant,
|
|
threadIsMessageRequest: thread.isMessageRequest(db),
|
|
direction: .incoming,
|
|
timestampMs: message.sentTimestamp.map { Int64($0) }
|
|
)
|
|
|
|
case .stopped:
|
|
TypingIndicators.didStopTyping(db, threadId: thread.id, direction: .incoming)
|
|
|
|
default:
|
|
SNLog("Unknown TypingIndicator Kind ignored")
|
|
return
|
|
}
|
|
}
|
|
}
|