Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

refactor: one reset for the lyrics page's lines, and simpler source asks

My-Name-Is-Jeffd8f9fe7f4a3a
diff --git a/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m b/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m
index 99d10848..5cc503c7 100644
--- a/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m
+++ b/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m
@@ -2034,11 +2034,14 @@ static BOOL anyUntranslated(NSArray<SGKaraokeLine *> *lines) {
});
}
-// The saved translations deleted, or Translate any song switched: the song is synced again and redrawn.
// A source picked from the player's ⋯ replaces the lines of the song playing, which the page otherwise keeps
// through any later answer: they are dropped as on a change of track, and the next tick takes the new ones.
- (void)sourceChosen:(NSNotification *)note {
if (_sample || ![note.object isEqual:_track]) return;
+ [self dropLines];
+}
+
+- (void)dropLines {
_lines = nil;
_passedOver = nil;
_builtWidth = 0;
@@ -2047,6 +2050,7 @@ static BOOL anyUntranslated(NSArray<SGKaraokeLine *> *lines) {
[self offerExtras];
}
+// The saved translations deleted, or Translate any song switched: the song is synced again and redrawn.
- (void)translationsChanged {
if (!_lines) return;
[self timeLines];
@@ -2343,12 +2347,7 @@ static BOOL anyUntranslated(NSArray<SGKaraokeLine *> *lines) {
if (!(track == _track || [track isEqualToString:_track])) {
SGLog(@"karaoke: page shows track %@, lyrics %@", track, [self linesFor:track] ? @"captured" : @"not captured yet");
_track = track;
- _lines = nil;
- _passedOver = nil;
- _builtWidth = 0;
- [self creditTo:nil];
- [self dropLineViews];
- [self offerExtras];
+ [self dropLines];
}
NSArray<SGKaraokeLine *> *kept = _lines && track ? [self linesFor:track] : nil;
if (kept && kept != _lines && kept != _passedOver) {
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsPick.m b/tweak/Sources/Shared/LyricsSources/LyricsPick.m
index e771b37b..9cb8955c 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsPick.m
+++ b/tweak/Sources/Shared/LyricsSources/LyricsPick.m
@@ -59,13 +59,12 @@ static SGLyricsOfferAsk *askAll(NSString *trackID) {
ask.order = SGLyricsOrder();
ask.answers = [NSMutableDictionary dictionary];
ask.waiting = [NSMutableArray array];
- SGLyricsQuery *named = SGLyricsQueryFor(trackID);
SGLog(@"lyrics: asking %@ at once for %@, for the player's ⋯", [ask.order componentsJoinedByString:@", "], trackID);
for (NSString *key in ask.order) {
SGLyricsProvider *provider = SGLyricsProviderFor(key);
// A query each, so what one source learns does not change what the next is asked.
SGLyricsQuery *query = SGLyricsQueryFor(trackID);
- if (provider.needsName && !(named.title.length && named.artist.length)) {
+ if (provider.needsName && !(query.title.length && query.artist.length)) {
answer(ask, key, nil);
continue;
}
diff --git a/tweak/Sources/Shared/LyricsSources/LyricsSources.h b/tweak/Sources/Shared/LyricsSources/LyricsSources.h
index 177f2fb0..42cddbdf 100644
--- a/tweak/Sources/Shared/LyricsSources/LyricsSources.h
+++ b/tweak/Sources/Shared/LyricsSources/LyricsSources.h
@@ -235,8 +235,8 @@ UIViewController *SGLyricsSourcesPage(void); // the ordered list on the Lyrics
// than the one that answered (issue #67). The pick is a track's id against a source's key, kept until Spotify
// quits; a track's walk asks its picked source first, the rest of the order after it. Main queue.
NSString *SGLyricsChosenSource(NSString *trackID);
-// Every source in the order is asked for the track at once, each once a launch, and `done` gets the ones with
-// lines, by key, when all have answered or `wait` has passed.
+// Every source in the order is asked for the track at once, the answers kept for the last few tracks, and
+// `done` gets the ones with lines, by key, when all have answered or `wait` has passed.
void SGLyricsOffers(NSString *trackID, NSTimeInterval wait, void (^done)(NSDictionary<NSString *, SGLyricsResult *> *offers));
// Makes the offer of `key` the track's lyrics now, everywhere they show, and posts
// SGLyricsSourceChosenNotification (object the track's id) once its lines are kept.