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.
39 lines
1.3 KiB
Swift
39 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,
|
|
threadId: String,
|
|
threadVariant: SessionThread.Variant,
|
|
message: TypingIndicator
|
|
) throws {
|
|
guard let thread: SessionThread = try SessionThread.fetchOne(db, id: threadId) else { return }
|
|
|
|
switch message.kind {
|
|
case .started:
|
|
let needsToStartTypingIndicator: Bool = TypingIndicators.didStartTypingNeedsToStart(
|
|
threadId: threadId,
|
|
threadVariant: threadVariant,
|
|
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
|
|
}
|
|
}
|
|
}
|