mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
* feat: Menu redesign * Add bottomsheet * Handle default peek height * Smooth out setting peek height * Move contacts prep to util * Dialog layout tweaks * Contact grouping tweaks * Add new message dialog * Add public key input delegate * Add create group dialog * Add join community dialog * Handle dialog back navigation * Enter community url tab tweaks * Scan QR code tab refactor * Scan qr code refactor * Direct and community tabs refactor * Add session id copy context menu item * Set dialog background colours * Set full dialog background colour * Minor tweaks * Add closed group contact search * Cleanup * Add content descriptions * Resize community chips * Fix new conversation screen paddings * Fix fade in/out of join community screen * Prevent creating conversation with empty public key * Resize and position create group loader * Fix back nav after creating direct message conversation * Fix inter-screen transitions * Fix new conversation background colours * Fix background colours * Rename contact list header for clarity * Bug fixes * Enable scrolling of Enter Session ID tab of the new message dialog * Minor refactor * Switch to child fragment manager * Fix member search on create group screen Co-authored-by: charles <charles@oxen.io>
36 lines
1.2 KiB
Kotlin
36 lines
1.2 KiB
Kotlin
package org.thoughtcrime.securesms.conversation.start
|
|
|
|
import androidx.lifecycle.LiveData
|
|
import androidx.lifecycle.MutableLiveData
|
|
import androidx.lifecycle.ViewModel
|
|
import androidx.lifecycle.viewModelScope
|
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.withContext
|
|
import org.session.libsession.utilities.recipients.Recipient
|
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
|
import javax.inject.Inject
|
|
|
|
@HiltViewModel
|
|
class NewConversationHomeViewModel @Inject constructor(private val threadDb: ThreadDatabase): ViewModel() {
|
|
|
|
private val _recipients = MutableLiveData<List<Recipient>>()
|
|
val recipients: LiveData<List<Recipient>> = _recipients
|
|
|
|
init {
|
|
viewModelScope.launch {
|
|
threadDb.approvedConversationList.use { openCursor ->
|
|
val reader = threadDb.readerFor(openCursor)
|
|
val threads = mutableListOf<Recipient>()
|
|
while (true) {
|
|
threads += reader.next?.recipient ?: break
|
|
}
|
|
withContext(Dispatchers.Main) {
|
|
_recipients.value = threads
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|