Start conversation if closed when receiving an audio or video call (#1485)

* Start conversation if closed when receiving an audio or video call

* Fix starting conversation on new calls, move setting conversation.last_active

---------

Co-authored-by: fiaxh <git@lightrise.org>
This commit is contained in:
eerielili 2023-10-08 11:51:30 +00:00 committed by GitHub
parent 8cb195a274
commit 86b101900c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -39,12 +39,12 @@ public interface Application : GLib.Application {
PresenceManager.start(stream_interactor); PresenceManager.start(stream_interactor);
CounterpartInteractionManager.start(stream_interactor); CounterpartInteractionManager.start(stream_interactor);
BlockingManager.start(stream_interactor); BlockingManager.start(stream_interactor);
Calls.start(stream_interactor, db);
ConversationManager.start(stream_interactor, db); ConversationManager.start(stream_interactor, db);
MucManager.start(stream_interactor); MucManager.start(stream_interactor);
AvatarManager.start(stream_interactor, db); AvatarManager.start(stream_interactor, db);
RosterManager.start(stream_interactor, db); RosterManager.start(stream_interactor, db);
FileManager.start(stream_interactor, db); FileManager.start(stream_interactor, db);
Calls.start(stream_interactor, db);
CallStore.start(stream_interactor, db); CallStore.start(stream_interactor, db);
ContentItemStore.start(stream_interactor, db); ContentItemStore.start(stream_interactor, db);
ChatInteraction.start(stream_interactor); ChatInteraction.start(stream_interactor);

View file

@ -61,8 +61,6 @@ namespace Dino {
call_state.initiate_groupchat_call.begin(conversation.counterpart); call_state.initiate_groupchat_call.begin(conversation.counterpart);
} }
conversation.last_active = call.time;
call_outgoing(call, call_state, conversation); call_outgoing(call, call_state, conversation);
return call_state; return call_state;
@ -221,7 +219,6 @@ namespace Dino {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(call.counterpart.bare_jid, account, Conversation.Type.CHAT); Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(call.counterpart.bare_jid, account, Conversation.Type.CHAT);
stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation); stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation);
conversation.last_active = call.time;
var call_state = new CallState(call, stream_interactor); var call_state = new CallState(call, stream_interactor);
connect_call_state_signals(call_state); connect_call_state_signals(call_state);
@ -294,7 +291,6 @@ namespace Dino {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(inviter_jid.bare_jid, account); Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(inviter_jid.bare_jid, account);
if (conversation == null) return null; if (conversation == null) return null;
stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation); stream_interactor.get_module(CallStore.IDENTITY).add_call(call, conversation);
conversation.last_active = call.time;
CallState call_state = new CallState(call, stream_interactor); CallState call_state = new CallState(call, stream_interactor);
connect_call_state_signals(call_state); connect_call_state_signals(call_state);
@ -465,7 +461,6 @@ namespace Dino {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(from_jid, to_jid, account, message_stanza.type_); Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(from_jid, to_jid, account, message_stanza.type_);
if (conversation == null) return; if (conversation == null) return;
conversation.last_active = call_state.call.time;
if (call_state.call.direction == Call.DIRECTION_INCOMING) { if (call_state.call.direction == Call.DIRECTION_INCOMING) {
call_incoming(call_state.call, call_state, conversation, video_requested, multiparty); call_incoming(call_state.call, call_state, conversation, video_requested, multiparty);

View file

@ -29,6 +29,8 @@ public class ConversationManager : StreamInteractionModule, Object {
stream_interactor.account_removed.connect(on_account_removed); stream_interactor.account_removed.connect(on_account_removed);
stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new MessageListener(stream_interactor)); stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(new MessageListener(stream_interactor));
stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(handle_sent_message); stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(handle_sent_message);
stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect(handle_new_call);
stream_interactor.get_module(Calls.IDENTITY).call_outgoing.connect(handle_new_call);
} }
public Conversation create_conversation(Jid jid, Account account, Conversation.Type? type = null) { public Conversation create_conversation(Jid jid, Account account, Conversation.Type? type = null) {
@ -194,6 +196,11 @@ public class ConversationManager : StreamInteractionModule, Object {
} }
} }
private void handle_new_call(Call call, CallState state, Conversation conversation) {
conversation.last_active = call.time;
start_conversation(conversation);
}
private void add_conversation(Conversation conversation) { private void add_conversation(Conversation conversation) {
if (!conversations[conversation.account].has_key(conversation.counterpart)) { if (!conversations[conversation.account].has_key(conversation.counterpart)) {
conversations[conversation.account][conversation.counterpart] = new ArrayList<Conversation>(Conversation.equals_func); conversations[conversation.account][conversation.counterpart] = new ArrayList<Conversation>(Conversation.equals_func);