Skip to content

Commit 82edea4

Browse files
committed
[wip] fix: calls
[skip ci] Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent e875fc1 commit 82edea4

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/composables/useGetMessages.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import { useStore } from 'vuex'
2323
import { CHAT, CONFIG, MESSAGE } from '../constants.ts'
2424
import { getTalkConfig } from '../services/CapabilitiesManager.ts'
2525
import { EventBus } from '../services/EventBus.ts'
26+
import { useActorStore } from '../stores/actor.ts'
2627
import { useChatStore } from '../stores/chat.ts'
2728
import { useChatExtrasStore } from '../stores/chatExtras.ts'
2829
import { debugTimer } from '../utils/debugTimer.ts'
30+
import { tryLocalizeSystemMessage } from '../utils/message.ts'
2931
import { useGetThreadId } from './useGetThreadId.ts'
3032
import { useGetToken } from './useGetToken.ts'
3133

@@ -65,6 +67,7 @@ let chatRelaySupported: boolean | null = null
6567
export function useGetMessagesProvider() {
6668
const store = useStore()
6769
const route = useRoute()
70+
const actorStore = useActorStore()
6871
const chatStore = useChatStore()
6972
const chatExtrasStore = useChatExtrasStore()
7073

@@ -628,6 +631,27 @@ export function useGetMessagesProvider() {
628631
return
629632
}
630633

634+
if (message.systemMessage !== '') {
635+
// Attempt to localize non-system messages
636+
try {
637+
// FIXME
638+
console.log('[Chat Relay] New message received via signaling >>', message.message, message, actorStore.actorId, actorStore.actorType)
639+
640+
message.message = tryLocalizeSystemMessage({
641+
message,
642+
conversationType: conversation.value!.type,
643+
selfActorId: actorStore.actorId!,
644+
selfActorType: actorStore.actorType!,
645+
})
646+
647+
// FIXME
648+
console.log('[Chat Relay] New message localized fr signaling <<', message.message)
649+
} catch (exception) {
650+
tryPollNewMessages()
651+
return
652+
}
653+
}
654+
631655
chatStore.processChatBlocks(token, [message], { mergeBy: chatStore.getLastKnownId(token) })
632656
store.dispatch('processMessage', { token, message, fromRealtime: true })
633657
}

src/utils/message.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,27 @@ export function tryLocalizeSystemMessage({
200200

201201
switch (message.systemMessage) {
202202
case MESSAGE.SYSTEM_TYPE.CALL_STARTED: {
203-
throw new Error()
203+
if (callIsSilent(message)) {
204+
if (selfIsActor(message, selfActorId, selfActorType)) {
205+
return conversationIsOneToOne(conversationType)
206+
? t('spreed', 'Outgoing silent call')
207+
: t('spreed', 'You started a silent call')
208+
} else {
209+
return conversationIsOneToOne(conversationType)
210+
? t('spreed', '{actor} started a silent call')
211+
: t('spreed', 'Incoming silent call')
212+
}
213+
} else {
214+
if (selfIsActor(message, selfActorId, selfActorType)) {
215+
return conversationIsOneToOne(conversationType)
216+
? t('spreed', 'Outgoing call')
217+
: t('spreed', 'You started a call')
218+
} else {
219+
return conversationIsOneToOne(conversationType)
220+
? t('spreed', '{actor} started a call')
221+
: t('spreed', 'Incoming call')
222+
}
223+
}
204224
}
205225
case MESSAGE.SYSTEM_TYPE.CALL_JOINED: {
206226
throw new Error()

0 commit comments

Comments
 (0)