Skip to content

Commit

Permalink
fix: #81
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jan 23, 2024
1 parent 0d7dd49 commit c697dad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import com.m3u.core.Contracts
import com.m3u.core.architecture.pref.Pref
import com.m3u.core.architecture.pref.observeAsFlow
import com.m3u.data.database.model.Stream
import com.m3u.data.manager.PlayerManager
import com.m3u.data.repository.MediaRepository
import com.m3u.data.repository.StreamRepository
import com.m3u.data.repository.observeAll
import com.m3u.data.manager.PlayerManager
import com.m3u.ui.Sort
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
Expand Down Expand Up @@ -82,8 +82,13 @@ class FavouriteViewModel @Inject constructor(
.combine(sort) { all, sort ->
when (sort) {
Sort.UNSPECIFIED -> all
Sort.ASC -> all.sortedBy { it.title }
Sort.DESC -> all.sortedByDescending { it.title }
Sort.ASC -> all.sortedWith(
compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }
)

Sort.DESC -> all.sortedWith(
compareByDescending(String.CASE_INSENSITIVE_ORDER) { it.title }
)
}
.toPersistentList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import com.m3u.core.wrapper.Resource
import com.m3u.core.wrapper.eventOf
import com.m3u.data.database.model.Playlist
import com.m3u.data.database.model.Stream
import com.m3u.data.manager.MessageManager
import com.m3u.data.manager.PlayerManager
import com.m3u.data.repository.MediaRepository
import com.m3u.data.repository.PlaylistRepository
import com.m3u.data.repository.StreamRepository
import com.m3u.data.repository.refresh
import com.m3u.data.manager.MessageManager
import com.m3u.data.manager.PlayerManager
import com.m3u.features.playlist.PlaylistMessage.StreamCoverSaved
import com.m3u.features.playlist.navigation.PlaylistNavigation
import com.m3u.ui.Sort
Expand Down Expand Up @@ -284,8 +284,14 @@ class PlaylistViewModel @Inject constructor(
recommend
) { all, sort, recommend ->
when (sort) {
Sort.ASC -> all.sortedBy { it.title }.toSingleChannel()
Sort.DESC -> all.sortedByDescending { it.title }.toSingleChannel()
Sort.ASC -> all.sortedWith(
compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }
).toSingleChannel()

Sort.DESC -> all.sortedWith(
compareByDescending(String.CASE_INSENSITIVE_ORDER) { it.title }
).toSingleChannel()

Sort.UNSPECIFIED -> all.toChannels(recommend)
}
.toPersistentList()
Expand Down

0 comments on commit c697dad

Please sign in to comment.