add bookmark when clicking on channel search result
This commit is contained in:
parent
76fb17c972
commit
dc70b7e28a
|
@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.databinding.ActivityChannelDiscoveryBinding;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Bookmark;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.http.services.MuclumbusService;
|
||||
import eu.siacs.conversations.services.ChannelDiscoveryService;
|
||||
|
@ -198,8 +199,20 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
|
|||
}
|
||||
|
||||
public void joinChannelSearchResult(String accountJid, MuclumbusService.Room result) {
|
||||
final boolean syncAutojoin = getBooleanPreference("autojoin", R.bool.autojoin);
|
||||
Account account = xmppConnectionService.findAccountByJid(Jid.of(accountJid));
|
||||
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, result.getRoom(), true, true, true);
|
||||
if (conversation.getBookmark() != null) {
|
||||
if (!conversation.getBookmark().autojoin() && syncAutojoin) {
|
||||
conversation.getBookmark().setAutojoin(true);
|
||||
xmppConnectionService.pushBookmarks(account);
|
||||
}
|
||||
} else {
|
||||
final Bookmark bookmark = new Bookmark(account, conversation.getJid().asBareJid());
|
||||
bookmark.setAutojoin(syncAutojoin);
|
||||
account.getBookmarks().add(bookmark);
|
||||
xmppConnectionService.pushBookmarks(account);
|
||||
}
|
||||
switchToConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue