use of com.fernandocejas.arrow.optional.Optional in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getMessages.
private void getMessages() {
final Disposable subscription = roomRepository.getById(roomId).filter(Optional::isPresent).map(Optional::get).flatMap(messageInteractor::getAllFrom).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(messages -> view.showMessages(messages), Logger::report);
addSubscription(subscription);
}
use of com.fernandocejas.arrow.optional.Optional in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getUserPreferences.
private void getUserPreferences() {
final Disposable subscription = userRepository.getCurrent().filter(Optional::isPresent).map(Optional::get).filter(user -> user.getSettings() != null).map(User::getSettings).filter(settings -> settings.getPreferences() != null).map(Settings::getPreferences).distinctUntilChanged().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(preferences -> {
if (preferences.isAutoImageLoad()) {
view.autoloadImages();
} else {
view.manualLoadImages();
}
}, Logger::report);
addSubscription(subscription);
}
use of com.fernandocejas.arrow.optional.Optional in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getRoomHistoryStateInfo.
private void getRoomHistoryStateInfo() {
final Disposable subscription = roomRepository.getHistoryStateByRoomId(roomId).distinctUntilChanged().filter(Optional::isPresent).map(Optional::get).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(roomHistoryState -> {
int syncState = roomHistoryState.getSyncState();
view.updateHistoryState(!roomHistoryState.isComplete(), syncState == SyncState.SYNCED || syncState == SyncState.FAILED);
}, Logger::report);
addSubscription(subscription);
}
use of com.fernandocejas.arrow.optional.Optional in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method onMarkAsRead.
@Override
public void onMarkAsRead() {
final Disposable subscription = roomRepository.getById(roomId).filter(Optional::isPresent).map(Optional::get).firstElement().filter(Room::isAlert).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(room -> methodCallHelper.readMessages(room.getRoomId()).continueWith(new LogIfError()), Logger::report);
addSubscription(subscription);
}
use of com.fernandocejas.arrow.optional.Optional in project Rocket.Chat.Android by RocketChat.
the class RoomPresenter method getRoomInfo.
private void getRoomInfo() {
final Disposable subscription = roomRepository.getById(roomId).distinctUntilChanged().filter(Optional::isPresent).map(Optional::get).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(room -> view.render(room), Logger::report);
addSubscription(subscription);
}
Aggregations