Directly start chat from xmpp uri if only one account is active

fixes #160
This commit is contained in:
fiaxh 2017-10-22 03:39:13 +02:00
parent 555187deb9
commit 128a015d45

View file

@ -58,17 +58,24 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
dialog.present(); dialog.present();
break; break;
case "message": case "message":
AddConversation.Chat.Dialog dialog = new AddConversation.Chat.Dialog(stream_interactor, stream_interactor.get_accounts()); Gee.List<Account> accounts = stream_interactor.get_accounts();
dialog.set_filter(jid); if (accounts.size == 1) {
dialog.set_transient_for(window); Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(new Jid(jid), accounts[0], Conversation.Type.CHAT);
dialog.title = _("Start Chat");
dialog.ok_button.label = _("Start");
dialog.selected.connect((account, jid) => {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true); stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
window.on_conversation_selected(conversation); window.on_conversation_selected(conversation);
}); } else {
dialog.present(); AddConversation.Chat.Dialog dialog = new AddConversation.Chat.Dialog(stream_interactor, stream_interactor.get_accounts());
dialog.set_filter(jid);
dialog.set_transient_for(window);
dialog.title = _("Start Chat");
dialog.ok_button.label = _("Start");
dialog.selected.connect((account, jid) => {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
window.on_conversation_selected(conversation);
});
dialog.present();
}
break; break;
} }
} }