Add default param values

This commit is contained in:
Benoit Marty 2019-12-04 20:22:04 +01:00
parent 411afb0bf3
commit 6d82ac7c59
10 changed files with 34 additions and 19 deletions

View File

@ -57,7 +57,8 @@ class RxRoom(private val room: Room) {
room.loadRoomMembersIfNeeded(MatrixCallbackSingle(it)).toSingle(it)
}
fun joinRoom(reason: String?, viaServers: List<String> = emptyList()): Single<Unit> = Single.create {
fun joinRoom(reason: String? = null,
viaServers: List<String> = emptyList()): Single<Unit> = Single.create {
room.join(reason, viaServers, MatrixCallbackSingle(it)).toSingle(it)
}

View File

@ -76,7 +76,9 @@ class RxSession(private val session: Session) {
session.searchUsersDirectory(search, limit, excludedUserIds, MatrixCallbackSingle(it)).toSingle(it)
}
fun joinRoom(roomId: String, reason: String?, viaServers: List<String> = emptyList()): Single<Unit> = Single.create {
fun joinRoom(roomId: String,
reason: String? = null,
viaServers: List<String> = emptyList()): Single<Unit> = Single.create {
session.joinRoom(roomId, reason, viaServers, MatrixCallbackSingle(it)).toSingle(it)
}
}

View File

@ -30,12 +30,16 @@ interface RoomDirectoryService {
/**
* Get rooms from directory
*/
fun getPublicRooms(server: String?, publicRoomsParams: PublicRoomsParams, callback: MatrixCallback<PublicRoomsResponse>): Cancelable
fun getPublicRooms(server: String?,
publicRoomsParams: PublicRoomsParams,
callback: MatrixCallback<PublicRoomsResponse>): Cancelable
/**
* Join a room by id
*/
fun joinRoom(roomId: String, reason: String?, callback: MatrixCallback<Unit>): Cancelable
fun joinRoom(roomId: String,
reason: String? = null,
callback: MatrixCallback<Unit>): Cancelable
/**
* Fetches the overall metadata about protocols supported by the homeserver.

View File

@ -30,7 +30,8 @@ interface RoomService {
/**
* Create a room asynchronously
*/
fun createRoom(createRoomParams: CreateRoomParams, callback: MatrixCallback<String>): Cancelable
fun createRoom(createRoomParams: CreateRoomParams,
callback: MatrixCallback<String>): Cancelable
/**
* Join a room by id
@ -39,7 +40,7 @@ interface RoomService {
* @param viaServers the servers to attempt to join the room through. One of the servers must be participating in the room.
*/
fun joinRoom(roomId: String,
reason: String?,
reason: String? = null,
viaServers: List<String> = emptyList(),
callback: MatrixCallback<Unit>): Cancelable
@ -71,5 +72,6 @@ interface RoomService {
/**
* Mark all rooms as read
*/
fun markAllAsRead(roomIds: List<String>, callback: MatrixCallback<Unit>): Cancelable
fun markAllAsRead(roomIds: List<String>,
callback: MatrixCallback<Unit>): Cancelable
}

View File

@ -52,16 +52,21 @@ interface MembershipService {
/**
* Invite a user in the room
*/
fun invite(userId: String, reason: String?, callback: MatrixCallback<Unit>): Cancelable
fun invite(userId: String,
reason: String? = null,
callback: MatrixCallback<Unit>): Cancelable
/**
* Join the room, or accept an invitation.
*/
fun join(reason: String?, viaServers: List<String> = emptyList(), callback: MatrixCallback<Unit>): Cancelable
fun join(reason: String? = null,
viaServers: List<String> = emptyList(),
callback: MatrixCallback<Unit>): Cancelable
/**
* Leave the room, or reject an invitation.
*/
fun leave(reason: String?, callback: MatrixCallback<Unit>): Cancelable
fun leave(reason: String? = null,
callback: MatrixCallback<Unit>): Cancelable
}

View File

@ -200,9 +200,10 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
invisibleEventsObservable.accept(action)
}
fun getMember(userId: String) : RoomMember? {
return room.getRoomMember(userId)
fun getMember(userId: String): RoomMember? {
return room.getRoomMember(userId)
}
/**
* Convert a send mode to a draft and save the draft
*/
@ -266,7 +267,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
}
}
session.rx()
.joinRoom(roomId, null, viaServer)
.joinRoom(roomId, viaServers = viaServer)
.map { roomId }
.execute {
copy(tombstoneEventHandling = it)
@ -557,7 +558,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
}
private fun handleAcceptInvite() {
room.join(null, callback = object : MatrixCallback<Unit> {})
room.join(callback = object : MatrixCallback<Unit> {})
}
private fun handleEditAction(action: RoomDetailAction.EnterEditMode) {

View File

@ -123,7 +123,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
)
}
session.getRoom(roomId)?.join(null, emptyList(), object : MatrixCallback<Unit> {
session.getRoom(roomId)?.join(callback = object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.
// Instead, we wait for the room to be joined

View File

@ -74,14 +74,14 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
private fun handleJoinRoom(roomId: String) {
activeSessionHolder.getSafeActiveSession()?.let { session ->
session.getRoom(roomId)
?.join(null, emptyList(), object : MatrixCallback<Unit> {})
?.join(callback = object : MatrixCallback<Unit> {})
}
}
private fun handleRejectRoom(roomId: String) {
activeSessionHolder.getSafeActiveSession()?.let { session ->
session.getRoom(roomId)
?.leave(null, object : MatrixCallback<Unit> {})
?.leave(callback = object : MatrixCallback<Unit> {})
}
}

View File

@ -214,7 +214,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState:
)
}
session.joinRoom(action.roomId, null, emptyList(), object : MatrixCallback<Unit> {
session.joinRoom(action.roomId, callback = object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.
// Instead, we wait for the room to be joined

View File

@ -97,7 +97,7 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted initialState: R
)
}
session.joinRoom(state.roomId, null, emptyList(), object : MatrixCallback<Unit> {
session.joinRoom(state.roomId, callback = object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.
// Instead, we wait for the room to be joined