From bbf423378831743a239105c6a52eaffef2bf62c0 Mon Sep 17 00:00:00 2001 From: polymorphicshade Date: Tue, 15 Dec 2020 14:09:24 -0700 Subject: [PATCH] SponsorBlock: Fixed an issue where the whitelist would not persist --- .../newpipe/player/VideoPlayerImpl.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index a6e16b0bb..080c89e3f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -882,26 +882,19 @@ public class VideoPlayerImpl extends VideoPlayer return true; } - final Set uploaderWhitelist = - mPrefs.getStringSet( - context.getString(R.string.sponsor_block_whitelist_key), - new HashSet<>()); + final Set uploaderWhitelist = new HashSet<>(mPrefs.getStringSet( + context.getString(R.string.sponsor_block_whitelist_key), + new HashSet<>())); final String toastText; if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) { - if (uploaderWhitelist != null) { - uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName()); - } - + uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName()); setSponsorBlockMode(SponsorBlockMode.ENABLED); toastText = context .getString(R.string.sponsor_block_uploader_removed_from_whitelist_toast); } else { - if (uploaderWhitelist != null) { - uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName()); - } - + uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName()); setSponsorBlockMode(SponsorBlockMode.IGNORE); toastText = context .getString(R.string.sponsor_block_uploader_added_to_whitelist_toast); @@ -910,7 +903,7 @@ public class VideoPlayerImpl extends VideoPlayer mPrefs.edit() .putStringSet( context.getString(R.string.sponsor_block_whitelist_key), - uploaderWhitelist) + new HashSet<>(uploaderWhitelist)) .apply(); setBlockSponsorsButton(blockSponsorsButton);