test live update NA filtering

This commit is contained in:
J62 2025-03-15 16:06:56 -07:00
parent 9c1cd6b073
commit 4cf096ff1a
2 changed files with 21 additions and 3 deletions

View File

@ -209,7 +209,11 @@ public class SettingsTab extends Tab implements TabSelectionListener {
fastScrollSpeed = new SimpleBooleanProperty(null, "fastScrollSpeed", settings.fastScrollSpeed);
confirmationDialogs = new SimpleBooleanProperty(null, "confirmationForDangerousActions", settings.confirmationForDangerousActions);
naCamsOnly = new SimpleBooleanProperty(null, "filterNAcamsOnly", settings.filterNAcamsOnly);
naCamsOnly.addListener((obs, oldValue, newValue) -> { settings.filterNAcamsOnly = newValue; saveConfig();});
naCamsOnly.addListener((obs, oldValue, newValue) -> {
settings.filterNAcamsOnly = newValue;
saveConfig();
refreshChaturbateTabs(); // Refresh tabs when the setting changes
});
useHlsdl = new SimpleBooleanProperty(null, "useHlsdl", settings.useHlsdl);
hlsdlExecutable = new SimpleFileProperty(null, "hlsdlExecutable", settings.hlsdlExecutable);
recentlyWatched = new SimpleBooleanProperty(null, "recentlyWatched", settings.recentlyWatched);
@ -233,6 +237,19 @@ public class SettingsTab extends Tab implements TabSelectionListener {
httpClientMaxRequestsPerHost = new SimpleIntegerProperty(null, "httpClientMaxRequestsPerHost", settings.httpClientMaxRequestsPerHost);
}
private void refreshChaturbateTabs() {
getTabPane().getTabs().forEach(tab -> {
if (tab.getContent() instanceof ThumbOverviewTab overviewTab) {
if (overviewTab.getUpdateService() instanceof ChaturbateTabProvider updateService) {
// Fetch the latest setting dynamically and rebuild the URL
boolean filterNA = settings.filterNAcamsOnly;
updateService.setUrl(updateService.buildUrl(updateService.getEndpoint(), filterNA));
updateService.restart(); // Refresh tab content
}
}
});
}
private void createGui() {
var postProcessingStepPanel = new PostProcessingStepPanel(config);
var variablesHelpButton = createHelpButton("Variables", "http://localhost:5689/docs/PostProcessing.md#variables");

View File

@ -79,8 +79,9 @@ public class ChaturbateTabProvider extends AbstractTabProvider {
return createTab(title, updateService);
}
// Helper function to append region filter if enabled
private String buildUrl(String endpoint) {
return apiUrl + endpoint + (regionNAEnabled ? "&regions=NA" : "");
boolean filterNA = Config.getInstance().isFilterNAcamsOnlyEnabled(); // Fetch latest setting
return apiUrl + endpoint + (filterNA ? "&regions=NA" : "");
}
}