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;
}
final Set<String> uploaderWhitelist =
mPrefs.getStringSet(
final Set<String> uploaderWhitelist = new HashSet<>(mPrefs.getStringSet(
context.getString(R.string.sponsor_block_whitelist_key),
new HashSet<>());
new HashSet<>()));
final String toastText;
if (getSponsorBlockMode() == SponsorBlockMode.IGNORE) {
if (uploaderWhitelist != null) {
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());
}
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);