Skip to content

Commit

Permalink
Store alternative source resources in cache; implements KRTirtho#1195
Browse files Browse the repository at this point in the history
  • Loading branch information
equationslayer12 authored Feb 3, 2024
1 parent 56219c4 commit 24955aa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/provider/proxy_playlist/proxy_playlist_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:spotube/models/local_track.dart';
import 'package:spotube/models/logger.dart';

import 'package:spotube/models/skip_segment.dart';
import 'package:spotube/models/source_match.dart';

import 'package:spotube/provider/blacklist_provider.dart';
import 'package:spotube/provider/palette_provider.dart';
Expand Down Expand Up @@ -448,6 +449,18 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
audioPlayer.currentSource!,
makeAppropriateSource(newTrack),
);

// update cache: first remove track, then add the new source
await SourceMatch.box.delete(state.activeTrack?.id);
await SourceMatch.box.put(
newTrack.id,
SourceMatch(
id: newTrack.id!,
sourceType: SourceType.youtube,
createdAt: DateTime.now(),
sourceId: sibling.id,
),
);
}
}

Expand Down

0 comments on commit 24955aa

Please sign in to comment.