fix: stop message load on channel switch
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
87bedf0553
commit
4de3190507
|
|
@ -101,8 +101,11 @@ class ChannelScreenViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private var loadMessagesJob: Job? = null
|
||||
|
||||
fun switchChannel(id: String) {
|
||||
// Reset state
|
||||
this.loadMessagesJob?.cancel()
|
||||
this.channel = RevoltAPI.channelCache[id]
|
||||
this.items = mutableStateListOf(ChannelScreenItem.Loading)
|
||||
this.activePane = ChannelScreenActivePane.None
|
||||
|
|
@ -395,7 +398,7 @@ class ChannelScreenViewModel @Inject constructor(
|
|||
ignoreExisting: Boolean = false
|
||||
) {
|
||||
channel?.id?.let { channelId ->
|
||||
viewModelScope.launch {
|
||||
loadMessagesJob = viewModelScope.launch {
|
||||
try {
|
||||
val messages = arrayListOf<Message>()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue