Commit 242e0c9b authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update classes to work with UserRepository.kt

parent 55e95336
......@@ -29,7 +29,7 @@ class AutocompleteUserInteractor(private val room: Room,
return Flowable.zip<String, List<Message>, List<SpotlightUser>, Triple<String, List<Message>, List<SpotlightUser>>>(
Flowable.just(name),
messageRepository.getAllFrom(room),
userRepository.getSortedLikeName(name, SortDirection.DESC, 5).map { it.toSpotlightUsers() },
userRepository.getSortedLikeName(name, 5).map { it.toSpotlightUsers() },
Function3 { a, b, c -> Triple.create(a, b, c) }
)
.flatMap { triple ->
......
......@@ -14,7 +14,7 @@ class CanCreateRoomInteractor(private val userRepository: UserRepository,
fun canCreate(roomId: String): Single<Boolean> {
return Flowable.zip<Optional<User>, Optional<Session>, String, Boolean>(
userRepository.current,
userRepository.getCurrent(),
sessionInteractor.getDefault(),
Flowable.just(roomId),
Function3 { user, session, room -> user.isPresent && session.isPresent && room != null }
......
......@@ -17,7 +17,7 @@ class EditMessageInteractor(private val permissionInteractor: PermissionInteract
fun isAllowed(message: Message): Single<Boolean> {
return Single.zip<Optional<User>, Optional<Room>, Optional<PublicSetting>, Optional<PublicSetting>, Pair<Optional<Room>, Boolean>>(
userRepository.current.first(Optional.absent()),
userRepository.getCurrent().first(Optional.absent()),
roomRepository.getById(message.roomId).first(Optional.absent()),
publicSettingRepository.getById(PublicSettingsConstants.Message.ALLOW_EDITING),
publicSettingRepository.getById(PublicSettingsConstants.Message.ALLOW_EDITING_BLOCK_TIMEOUT),
......
......@@ -14,7 +14,7 @@ class PermissionInteractor(private val userRepository: UserRepository,
private val permissionRepository: PermissionRepository) {
fun isAllowed(permissionId: String, room: Room): Single<Boolean> {
return userRepository.current
return userRepository.getCurrent()
.first(Optional.absent())
.flatMap {
if (!it.isPresent) {
......
......@@ -3,7 +3,6 @@ package chat.rocket.core.interactors;
import io.reactivex.Flowable;
import java.util.List;
import chat.rocket.core.SortDirection;
import chat.rocket.core.models.User;
import chat.rocket.core.repositories.UserRepository;
......@@ -16,6 +15,6 @@ public class UserInteractor {
}
public Flowable<List<User>> getUserAutocompleteSuggestions(String name) {
return userRepository.getSortedLikeName(name, SortDirection.DESC, 5);
return userRepository.getSortedLikeName(name, 5);
}
}
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