better threading
This commit is contained in:
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Fluffytrix
|
||||||
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -6,7 +6,7 @@
|
|||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="#JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class MainViewModel(
|
|||||||
MxcUrlHelper.mxcToThumbnailUrl(baseUrl, mxcUri, size)
|
MxcUrlHelper.mxcToThumbnailUrl(baseUrl, mxcUri, size)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
syncService = authRepository.getOrStartSync()
|
syncService = authRepository.getOrStartSync()
|
||||||
loadRooms()
|
loadRooms()
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ class MainViewModel(
|
|||||||
private fun loadRooms() {
|
private fun loadRooms() {
|
||||||
val client = authRepository.getClient() ?: return
|
val client = authRepository.getClient() ?: return
|
||||||
roomPollJob?.cancel()
|
roomPollJob?.cancel()
|
||||||
roomPollJob = viewModelScope.launch {
|
roomPollJob = viewModelScope.launch(Dispatchers.IO) {
|
||||||
// Poll until rooms appear, then keep polling for updates
|
// Poll until rooms appear, then keep polling for updates
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
@@ -403,7 +403,7 @@ class MainViewModel(
|
|||||||
|
|
||||||
private fun loadChannelName(roomId: String) {
|
private fun loadChannelName(roomId: String) {
|
||||||
val client = authRepository.getClient() ?: return
|
val client = authRepository.getClient() ?: return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val room = client.getRoom(roomId)
|
val room = client.getRoom(roomId)
|
||||||
val name = room?.displayName() ?: roomId
|
val name = room?.displayName() ?: roomId
|
||||||
@@ -415,7 +415,7 @@ class MainViewModel(
|
|||||||
|
|
||||||
private fun loadTimeline(roomId: String): Job {
|
private fun loadTimeline(roomId: String): Job {
|
||||||
val client = authRepository.getClient() ?: return Job()
|
val client = authRepository.getClient() ?: return Job()
|
||||||
return viewModelScope.launch {
|
return viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val room = client.getRoom(roomId) ?: return@launch
|
val room = client.getRoom(roomId) ?: return@launch
|
||||||
val timeline = room.timeline()
|
val timeline = room.timeline()
|
||||||
@@ -691,7 +691,7 @@ class MainViewModel(
|
|||||||
|
|
||||||
private fun loadMembers(roomId: String): Job {
|
private fun loadMembers(roomId: String): Job {
|
||||||
val client = authRepository.getClient() ?: return Job()
|
val client = authRepository.getClient() ?: return Job()
|
||||||
return viewModelScope.launch {
|
return viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val room = client.getRoom(roomId) ?: return@launch
|
val room = client.getRoom(roomId) ?: return@launch
|
||||||
val iterator = room.members()
|
val iterator = room.members()
|
||||||
@@ -749,7 +749,7 @@ class MainViewModel(
|
|||||||
|
|
||||||
fun sendMessage(body: String) {
|
fun sendMessage(body: String) {
|
||||||
val timeline = activeTimeline ?: return
|
val timeline = activeTimeline ?: return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
timeline.send(messageEventContentFromMarkdown(body))
|
timeline.send(messageEventContentFromMarkdown(body))
|
||||||
} catch (_: Exception) { }
|
} catch (_: Exception) { }
|
||||||
@@ -829,7 +829,7 @@ class MainViewModel(
|
|||||||
|
|
||||||
private fun preloadAllSpaceChildren() {
|
private fun preloadAllSpaceChildren() {
|
||||||
val client = authRepository.getClient() ?: return
|
val client = authRepository.getClient() ?: return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val spaceService = client.spaceService()
|
val spaceService = client.spaceService()
|
||||||
val map = mutableMapOf<String, Set<String>>()
|
val map = mutableMapOf<String, Set<String>>()
|
||||||
@@ -913,7 +913,7 @@ class MainViewModel(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val client = authRepository.getClient() ?: return
|
val client = authRepository.getClient() ?: return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val spaceService = client.spaceService()
|
val spaceService = client.spaceService()
|
||||||
val allSpacedRoomIds = mutableSetOf<String>()
|
val allSpacedRoomIds = mutableSetOf<String>()
|
||||||
@@ -965,7 +965,7 @@ class MainViewModel(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val client = authRepository.getClient() ?: return
|
val client = authRepository.getClient() ?: return
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val spaceService = client.spaceService()
|
val spaceService = client.spaceService()
|
||||||
val allRoomIds = mutableSetOf<String>()
|
val allRoomIds = mutableSetOf<String>()
|
||||||
|
|||||||
Reference in New Issue
Block a user