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

fix: Delete saved translations waits for the writes still queued

My-Name-Is-Jeff652674eb1a4b
diff --git a/tweak/Sources/Shared/LyricsTranslation/SavedTranslations.m b/tweak/Sources/Shared/LyricsTranslation/SavedTranslations.m
index 98e78c28..793b5e87 100644
--- a/tweak/Sources/Shared/LyricsTranslation/SavedTranslations.m
+++ b/tweak/Sources/Shared/LyricsTranslation/SavedTranslations.m
@@ -133,10 +133,15 @@ SGModRow *SGSavedTranslationsRow(void) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Delete saved translations?"
message:@"Songs translated before are translated again the next time you ask." preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- [NSFileManager.defaultManager removeItemAtURL:folder() error:nil];
SGLyricsForgetAITranslation(nil, nil);
- SGLog(@"translation: saved translations deleted");
- [NSNotificationCenter.defaultCenter postNotificationName:SGLyricsTranslationsDidChangeNotification object:nil];
+ // After any write still queued, so it cannot bring a song's file back.
+ dispatch_async(writes(), ^{
+ [NSFileManager.defaultManager removeItemAtURL:folder() error:nil];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ SGLog(@"translation: saved translations deleted");
+ [NSNotificationCenter.defaultCenter postNotificationName:SGLyricsTranslationsDidChangeNotification object:nil];
+ });
+ });
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[SGTopController() presentViewController:alert animated:YES completion:nil];