SponsorBlock: Fixed an issue where the whitelist would not persist

This commit is contained in:
polymorphicshade 2020-12-15 14:09:24 -07:00
parent 34591d5834
commit bbf4233788

View file

@ -882,26 +882,19 @@ public class VideoPlayerImpl extends VideoPlayer
return true; return true;
} }
final Set<String> uploaderWhitelist = final Set<String> uploaderWhitelist = new HashSet<>(mPrefs.getStringSet(
mPrefs.getStringSet(
context.getString(R.string.sponsor_block_whitelist_key), context.getString(R.string.sponsor_block_whitelist_key),
new HashSet<>()); new HashSet<>()));
final String toastText; final String toastText;
if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) { if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) {
if (uploaderWhitelist != null) {
uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName()); uploaderWhitelist.remove(currentMetadata.getMetadata().getUploaderName());
}
setSponsorBlockMode(SponsorBlockMode.ENABLED); setSponsorBlockMode(SponsorBlockMode.ENABLED);
toastText = context toastText = context
.getString(R.string.sponsor_block_uploader_removed_from_whitelist_toast); .getString(R.string.sponsor_block_uploader_removed_from_whitelist_toast);
} else { } else {
if (uploaderWhitelist != null) {
uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName()); uploaderWhitelist.add(currentMetadata.getMetadata().getUploaderName());
}
setSponsorBlockMode(SponsorBlockMode.IGNORE); setSponsorBlockMode(SponsorBlockMode.IGNORE);
toastText = context toastText = context
.getString(R.string.sponsor_block_uploader_added_to_whitelist_toast); .getString(R.string.sponsor_block_uploader_added_to_whitelist_toast);
@ -910,7 +903,7 @@ public class VideoPlayerImpl extends VideoPlayer
mPrefs.edit() mPrefs.edit()
.putStringSet( .putStringSet(
context.getString(R.string.sponsor_block_whitelist_key), context.getString(R.string.sponsor_block_whitelist_key),
uploaderWhitelist) new HashSet<>(uploaderWhitelist))
.apply(); .apply();
setBlockSponsorsButton(blockSponsorsButton); setBlockSponsorsButton(blockSponsorsButton);