🐛 Fix cross source swap siblings issue
This commit is contained in:
parent
e0c9edad78
commit
873ad1cf8c
@ -5,6 +5,7 @@ import 'package:rhythm_box/providers/database.dart';
|
|||||||
import 'package:rhythm_box/providers/error_notifier.dart';
|
import 'package:rhythm_box/providers/error_notifier.dart';
|
||||||
import 'package:rhythm_box/providers/user_preferences.dart';
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
|
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||||
import 'package:rhythm_box/services/utils.dart';
|
import 'package:rhythm_box/services/utils.dart';
|
||||||
@ -81,14 +82,16 @@ abstract class SourcedTrack extends Track {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Type getTrackBySourceInfo(SourceInfo info) {
|
Future<SourcedTrack?> reRoutineSwapSiblings(SourceInfo info) {
|
||||||
final sourceInfoTrackMap = {
|
final sourceInfoTrackMap = {
|
||||||
YoutubeSourceInfo: YoutubeSourcedTrack,
|
YoutubeSourceInfo: YoutubeSourcedTrack.fetchFromTrack,
|
||||||
PipedSourceInfo: PipedSourcedTrack,
|
PipedSourceInfo: PipedSourcedTrack.fetchFromTrack,
|
||||||
NeteaseSourceInfo: NeteaseSourcedTrack,
|
NeteaseSourceInfo: NeteaseSourcedTrack.fetchFromTrack,
|
||||||
KugouSourceInfo: KugouSourcedTrack,
|
KugouSourceInfo: KugouSourcedTrack.fetchFromTrack,
|
||||||
};
|
};
|
||||||
return sourceInfoTrackMap[info.runtimeType]!;
|
return sourceInfoTrackMap[info.runtimeType]!(
|
||||||
|
track: Get.find<ActiveSourcedTrackProvider>().state.value!,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getSearchTerm(Track track) {
|
static String getSearchTerm(Track track) {
|
||||||
|
@ -77,6 +77,7 @@ class KugouSourcedTrack extends SourcedTrack {
|
|||||||
sourceId: siblings.first.info.id,
|
sourceId: siblings.first.info.id,
|
||||||
sourceType: const Value(SourceType.kugou),
|
sourceType: const Value(SourceType.kugou),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.insertOrReplace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
return KugouSourcedTrack(
|
||||||
@ -171,8 +172,7 @@ class KugouSourcedTrack extends SourcedTrack {
|
|||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! KugouSourceInfo) {
|
if (sibling is! KugouSourceInfo) {
|
||||||
return (SourcedTrack.getTrackBySourceInfo(sibling) as SourcedTrack)
|
return reRoutineSwapSiblings(sibling);
|
||||||
.swapWithSibling(sibling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
|
@ -105,6 +105,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
sourceId: siblings.first.info.id,
|
sourceId: siblings.first.info.id,
|
||||||
sourceType: const Value(SourceType.netease),
|
sourceType: const Value(SourceType.netease),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.insertOrReplace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return NeteaseSourcedTrack(
|
return NeteaseSourcedTrack(
|
||||||
@ -202,8 +203,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! NeteaseSourceInfo) {
|
if (sibling is! NeteaseSourceInfo) {
|
||||||
return (SourcedTrack.getTrackBySourceInfo(sibling) as SourcedTrack)
|
return reRoutineSwapSiblings(sibling);
|
||||||
.swapWithSibling(sibling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
|
@ -73,6 +73,7 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
: SourceType.youtubeMusic,
|
: SourceType.youtubeMusic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.insertOrReplace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return PipedSourcedTrack(
|
return PipedSourcedTrack(
|
||||||
@ -256,8 +257,7 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! PipedSourceInfo) {
|
if (sibling is! PipedSourceInfo) {
|
||||||
return (SourcedTrack.getTrackBySourceInfo(sibling) as SourcedTrack)
|
return reRoutineSwapSiblings(sibling);
|
||||||
.swapWithSibling(sibling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
|
@ -271,8 +271,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! YoutubeSourceInfo) {
|
if (sibling is! YoutubeSourceInfo) {
|
||||||
return (SourcedTrack.getTrackBySourceInfo(sibling) as SourcedTrack)
|
return reRoutineSwapSiblings(sibling);
|
||||||
.swapWithSibling(sibling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user