Commit 77102f5b authored by Leonardo Aramaki's avatar Leonardo Aramaki

Check if user is currently viewing any room by looking at the cache and if so,...

Check if user is currently viewing any room by looking at the cache and if so, register to the selected room message stream
parent e090a5aa
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import chat.rocket.android.RocketChatCache;
import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
import chat.rocket.android.service.Registrable;
......@@ -19,6 +20,7 @@ public class StreamRoomMessageManager implements Registrable {
private final DDPClientRef ddpClientRef;
private final AbstractRocketChatCacheObserver cacheObserver;
private final Handler handler;
private final RocketChatCache rocketChatCache;
private StreamRoomMessage streamRoomMessage;
public StreamRoomMessageManager(Context context, String hostname,
......@@ -27,6 +29,7 @@ public class StreamRoomMessageManager implements Registrable {
this.hostname = hostname;
this.realmHelper = realmHelper;
this.ddpClientRef = ddpClientRef;
this.rocketChatCache = new RocketChatCache(context);
cacheObserver = new AbstractRocketChatCacheObserver(context, realmHelper) {
@Override
......@@ -57,6 +60,11 @@ public class StreamRoomMessageManager implements Registrable {
@Override
public void register() {
cacheObserver.register();
String selectedRoomId = rocketChatCache.getSelectedRoomId();
if (selectedRoomId == null) {
return;
}
registerStreamNotifyMessage(selectedRoomId);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment