diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-05-03 21:21:00 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-05-03 21:21:00 +0200 |
commit | 90e17f7b65ccd77f04f5e0904a9cd2c4e1236eb1 (patch) | |
tree | 636a052a7d89efed2ca9b6d4cc04c407a8578aab /src/main/java/de/pixart/messenger | |
parent | 88a275a433c8115bf26f9fba1a8578a3bc865487 (diff) |
add bookmark when clicking on channel search result
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java index e0b70b6ac..3233aa35c 100644 --- a/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ChannelDiscoveryActivity.java @@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicReference; import de.pixart.messenger.R; import de.pixart.messenger.databinding.ActivityChannelDiscoveryBinding; import de.pixart.messenger.entities.Account; +import de.pixart.messenger.entities.Bookmark; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.http.services.MuclumbusService; import de.pixart.messenger.services.ChannelDiscoveryService; @@ -189,8 +190,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); } }
\ No newline at end of file |