Merge pull request #4757 from vector-im/feature/fre/minor_code_enhancements

Some code enhancements
This commit is contained in:
Benoit Marty 2021-12-30 11:33:57 +01:00 committed by GitHub
commit 753d704c69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 9 deletions

View file

@ -152,6 +152,13 @@ class FlowSession(private val session: Session) {
}
}
fun liveUserAccountData(type: String): Flow<Optional<UserAccountDataEvent>> {
return session.accountDataService().getLiveUserAccountDataEvent(type).asFlow()
.startWith(session.coroutineDispatchers.io) {
session.accountDataService().getUserAccountDataEvent(type).toOptional()
}
}
fun liveRoomAccountData(types: Set<String>): Flow<List<RoomAccountDataEvent>> {
return session.accountDataService().getLiveRoomAccountDataEvents(types).asFlow()
.startWith(session.coroutineDispatchers.io) {

View file

@ -168,11 +168,8 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
}
}
private fun renderCreationSuccess(roomId: String?) {
// Navigate to freshly created room
if (roomId != null) {
navigator.openRoom(this, roomId)
}
private fun renderCreationSuccess(roomId: String) {
navigator.openRoom(this, roomId)
finish()
}

View file

@ -53,10 +53,10 @@ import timber.log.Timber
class RoomListViewModel @AssistedInject constructor(
@Assisted initialState: RoomListViewState,
private val session: Session,
private val stringProvider: StringProvider,
private val appStateHandler: AppStateHandler,
private val vectorPreferences: VectorPreferences,
private val autoAcceptInvites: AutoAcceptInvites
stringProvider: StringProvider,
appStateHandler: AppStateHandler,
vectorPreferences: VectorPreferences,
autoAcceptInvites: AutoAcceptInvites
) : VectorViewModel<RoomListViewState, RoomListAction, RoomListViewEvents>(initialState) {
@AssistedFactory

View file

@ -44,6 +44,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
const val SETTINGS_HOME_SERVER_PREFERENCE_KEY = "SETTINGS_HOME_SERVER_PREFERENCE_KEY"
const val SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY = "SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY"
const val SETTINGS_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY"
const val SETTINGS_EMAILS_AND_PHONE_NUMBERS_PREFERENCE_KEY = "SETTINGS_EMAILS_AND_PHONE_NUMBERS_PREFERENCE_KEY"
const val SETTINGS_CLEAR_CACHE_PREFERENCE_KEY = "SETTINGS_CLEAR_CACHE_PREFERENCE_KEY"
const val SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY = "SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY"