mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: changed source doesn't get saved and uses the wrong once again
This commit is contained in:
parent
2ce4853fd1
commit
ccea4a003d
@ -43,7 +43,12 @@ class JioSaavnSourcedTrack extends SourcedTrack {
|
|||||||
}) async {
|
}) async {
|
||||||
final database = ref.read(databaseProvider);
|
final database = ref.read(databaseProvider);
|
||||||
final cachedSource = await (database.select(database.sourceMatchTable)
|
final cachedSource = await (database.select(database.sourceMatchTable)
|
||||||
..where((s) => s.trackId.equals(track.id!)))
|
..where((s) => s.trackId.equals(track.id!))
|
||||||
|
..limit(1)
|
||||||
|
..orderBy([
|
||||||
|
(s) =>
|
||||||
|
OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc),
|
||||||
|
]))
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
|
|
||||||
if (cachedSource == null ||
|
if (cachedSource == null ||
|
||||||
@ -215,7 +220,11 @@ class JioSaavnSourcedTrack extends SourcedTrack {
|
|||||||
trackId: id!,
|
trackId: id!,
|
||||||
sourceId: info.id,
|
sourceId: info.id,
|
||||||
sourceType: const Value(SourceType.jiosaavn),
|
sourceType: const Value(SourceType.jiosaavn),
|
||||||
|
// Because we're sorting by createdAt in the query
|
||||||
|
// we have to update it to indicate priority
|
||||||
|
createdAt: Value(DateTime.now()),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.replace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return JioSaavnSourcedTrack(
|
return JioSaavnSourcedTrack(
|
||||||
|
@ -52,7 +52,12 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
}) async {
|
}) async {
|
||||||
final database = ref.read(databaseProvider);
|
final database = ref.read(databaseProvider);
|
||||||
final cachedSource = await (database.select(database.sourceMatchTable)
|
final cachedSource = await (database.select(database.sourceMatchTable)
|
||||||
..where((s) => s.trackId.equals(track.id!)))
|
..where((s) => s.trackId.equals(track.id!))
|
||||||
|
..limit(1)
|
||||||
|
..orderBy([
|
||||||
|
(s) =>
|
||||||
|
OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc),
|
||||||
|
]))
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
final preferences = ref.read(userPreferencesProvider);
|
final preferences = ref.read(userPreferencesProvider);
|
||||||
final pipedClient = ref.read(pipedProvider);
|
final pipedClient = ref.read(pipedProvider);
|
||||||
@ -278,7 +283,11 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
trackId: id!,
|
trackId: id!,
|
||||||
sourceId: newSourceInfo.id,
|
sourceId: newSourceInfo.id,
|
||||||
sourceType: const Value(SourceType.youtube),
|
sourceType: const Value(SourceType.youtube),
|
||||||
|
// Because we're sorting by createdAt in the query
|
||||||
|
// we have to update it to indicate priority
|
||||||
|
createdAt: Value(DateTime.now()),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.replace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return PipedSourcedTrack(
|
return PipedSourcedTrack(
|
||||||
|
@ -50,8 +50,14 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
}) async {
|
}) async {
|
||||||
final database = ref.read(databaseProvider);
|
final database = ref.read(databaseProvider);
|
||||||
final cachedSource = await (database.select(database.sourceMatchTable)
|
final cachedSource = await (database.select(database.sourceMatchTable)
|
||||||
..where((s) => s.trackId.equals(track.id!)))
|
..where((s) => s.trackId.equals(track.id!))
|
||||||
.getSingleOrNull();
|
..limit(1)
|
||||||
|
..orderBy([
|
||||||
|
(s) =>
|
||||||
|
OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc),
|
||||||
|
]))
|
||||||
|
.get()
|
||||||
|
.then((s) => s.firstOrNull);
|
||||||
|
|
||||||
if (cachedSource == null || cachedSource.sourceType != SourceType.youtube) {
|
if (cachedSource == null || cachedSource.sourceType != SourceType.youtube) {
|
||||||
final siblings = await fetchSiblings(ref: ref, track: track);
|
final siblings = await fetchSiblings(ref: ref, track: track);
|
||||||
@ -287,12 +293,17 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final database = ref.read(databaseProvider);
|
final database = ref.read(databaseProvider);
|
||||||
|
|
||||||
await database.into(database.sourceMatchTable).insert(
|
await database.into(database.sourceMatchTable).insert(
|
||||||
SourceMatchTableCompanion.insert(
|
SourceMatchTableCompanion.insert(
|
||||||
trackId: id!,
|
trackId: id!,
|
||||||
sourceId: newSourceInfo.id,
|
sourceId: newSourceInfo.id,
|
||||||
sourceType: const Value(SourceType.youtube),
|
sourceType: const Value(SourceType.youtube),
|
||||||
|
// Because we're sorting by createdAt in the query
|
||||||
|
// we have to update it to indicate priority
|
||||||
|
createdAt: Value(DateTime.now()),
|
||||||
),
|
),
|
||||||
|
mode: InsertMode.replace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return YoutubeSourcedTrack(
|
return YoutubeSourcedTrack(
|
||||||
|
Loading…
Reference in New Issue
Block a user