File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
app/src/main/java/com/ismartcoding/plain Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ import androidx.compose.ui.text.AnnotatedString
3333import androidx.compose.ui.text.TextStyle
3434import androidx.compose.ui.unit.dp
3535import androidx.compose.ui.unit.sp
36- import com.ismartcoding.lib.channel.Channel
3736import com.ismartcoding.plain.R
3837import com.ismartcoding.plain.TempData
3938import com.ismartcoding.plain.clipboardManager
Original file line number Diff line number Diff line change @@ -990,6 +990,42 @@ class SXGraphQL(val schema: Schema) {
990990 true
991991 }
992992 }
993+ mutation(" reorderPlaylistAudios" ) {
994+ resolver { paths: List <String > ->
995+ val context = MainApp .instance
996+
997+ // Get current playlist
998+ val currentPlaylist = AudioPlaylistPreference .getValueAsync(context)
999+ if (currentPlaylist.isEmpty() || paths.isEmpty()) {
1000+ return @resolver true
1001+ }
1002+
1003+ // Create a map of paths to audio items
1004+ val audioMap = currentPlaylist.associateBy { it.path }
1005+
1006+ // Reorder the playlist based on the provided paths
1007+ val reorderedPlaylist = mutableListOf<DPlaylistAudio >()
1008+
1009+ // First add audio items in the new order
1010+ paths.forEach { path ->
1011+ audioMap[path]?.let { audio ->
1012+ reorderedPlaylist.add(audio)
1013+ }
1014+ }
1015+
1016+ // Add other audio items that are not in the reorder list (keep their original positions)
1017+ currentPlaylist.forEach { audio ->
1018+ if (! paths.contains(audio.path)) {
1019+ reorderedPlaylist.add(audio)
1020+ }
1021+ }
1022+
1023+ // Save the reordered playlist
1024+ AudioPlaylistPreference .putAsync(context, reorderedPlaylist)
1025+
1026+ true
1027+ }
1028+ }
9931029 mutation(" createFeed" ) {
9941030 resolver { url: String , fetchContent: Boolean ->
9951031 val syndFeed = withIO { FeedHelper .fetchAsync(url) }
You can’t perform that action at this time.
0 commit comments