Route group avatar snapshots separately from feedback changes
This commit is contained in:
1 parent
d969b277e1
commit
f6b5e5b42c
3 files changed
+11
-3
No files matched your search
@@ -15,6 +15,7 @@ import com.utun.chat.data.ChatEventCallback
|
||||
import com.utun.chat.data.CallController
|
||||
import com.utun.chat.data.CallVideoCodec
|
||||
import com.utun.chat.data.AvatarRepository
|
||||
import com.utun.chat.data.AvatarProtocol
|
||||
import com.utun.chat.data.MemberRepository
|
||||
import com.utun.chat.data.MemberFilesRepository
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
@@ -42,7 +43,7 @@ object AppEventHandler : ChatEventCallback {
|
||||
if (type == 13 || type in 61..64) mainHandler.post { com.utun.chat.data.LocalDiscovery.onEvent(type, data) }
|
||||
if (type == 12) mainHandler.post { com.utun.chat.headless.HeadlessService.onCoreStarted() }
|
||||
if (type == 13 || type in 49..50) mainHandler.post { ChatApplication.instance.memberFiles.onEvent(type, data) }
|
||||
if (type in listOf(4, 8, 9, 12, 13, 23, 24, 25, 31) || type in 49..53) mainHandler.post {
|
||||
if (type in listOf(4, 8, 9, 12, 13, 23, 24, 25, 31, AvatarProtocol.GROUP_SNAPSHOT_EVENT) || type in 49..52) mainHandler.post {
|
||||
ChatApplication.instance.members.onEvent(type, data)
|
||||
ChatApplication.instance.avatars.onEvent(type, data)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class AvatarRepository(context: Context, private val memberRepository: MemberRep
|
||||
if (type == 13) { reset(); return }
|
||||
if (type == 9 || type == 12) { start(); return }
|
||||
try {
|
||||
if (type in 49..53 && data != null) {
|
||||
if ((type in 49..52 || type == AvatarProtocol.GROUP_SNAPSHOT_EVENT) && data != null) {
|
||||
val reply = when (type) {
|
||||
49 -> AvatarProtocol.response(data)
|
||||
50 -> AvatarProtocol.transfer(data) ?: return
|
||||
@@ -233,7 +233,9 @@ class AvatarRepository(context: Context, private val memberRepository: MemberRep
|
||||
val epoch = generation
|
||||
scope.launch {
|
||||
try {
|
||||
val record = AvatarProtocol.group(request(53, group) { id, gid -> NativeLib.requestGroupAvatar(id, gid) })
|
||||
val record = AvatarProtocol.group(request(AvatarProtocol.GROUP_SNAPSHOT_EVENT, group) { id, gid ->
|
||||
NativeLib.requestGroupAvatar(id, gid)
|
||||
})
|
||||
require(!record.failed) { "core rejected stored group avatar" }
|
||||
val state = GroupAvatarState(record.version, record.hash, record.canEdit, hasImage = record.image.isNotEmpty())
|
||||
val bitmap = if (record.image.isEmpty()) null else cache.get(groupKey(group, state)) ?: withContext(Dispatchers.IO) {
|
||||
|
||||
@@ -22,4 +22,9 @@ class ChatEventContractTest {
|
||||
assertTrue("JNI snapshot event must have a named declaration: $emitted", emitted in events)
|
||||
assertEquals("duplicate event numbers in chat_event.h", events.size, events.values.toSet().size)
|
||||
}
|
||||
|
||||
@Test fun kotlinSnapshotNumberMatchesTheNativeRegistryAndEmitter() {
|
||||
assertEquals(events.getValue("CHAT_EVT_GROUP_AVATAR_SNAPSHOT"), AvatarProtocol.GROUP_SNAPSHOT_EVENT)
|
||||
assertEquals(snapshotEvent, AvatarProtocol.GROUP_SNAPSHOT_EVENT)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user