Skip to content

Commit

Permalink
Revert "add persistent prefs for mod search"
Browse files Browse the repository at this point in the history
This reverts commit 06622f0.
  • Loading branch information
obydog002 committed Jun 1, 2024
1 parent 06622f0 commit 16fc9a2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 244 deletions.
42 changes: 6 additions & 36 deletions src/main/java/com/faforever/client/mod/ModVaultController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@
import com.faforever.client.main.event.OpenModVaultEvent;
import com.faforever.client.notification.NotificationService;
import com.faforever.client.preferences.ForgedAlliancePrefs;
import com.faforever.client.preferences.ModSearchPrefs;
import com.faforever.client.preferences.VaultPrefs;
import com.faforever.client.query.BinaryFilterController;
import com.faforever.client.query.DateRangeFilterController;
import com.faforever.client.query.RangeFilterController;
import com.faforever.client.query.SearchablePropertyMappings;
import com.faforever.client.query.TextFilterController;
import com.faforever.client.query.ToggleFilterController;
import com.faforever.client.reporting.ReportingService;
import com.faforever.client.theme.UiService;
import com.faforever.client.ui.dialog.Dialog;
Expand Down Expand Up @@ -153,38 +147,14 @@ protected void initSearchController() {
searchController.setVaultRoot(vaultRoot);
searchController.setSavedQueries(vaultPrefs.getSavedModQueries());

ModSearchPrefs modSearch = vaultPrefs.getModSearch();
searchController.addTextFilter("displayName", i18n.get("mod.displayName"), false);
searchController.addTextFilter("author", i18n.get("mod.author"), false);
searchController.addDateRangeFilter("latestVersion.updateTime", i18n.get("mod.uploadedDateTime"), 0);
searchController.addRangeFilter("reviewsSummary.averageScore", i18n.get("reviews.averageScore"), 0, 5, 10, 4, 1);

TextFilterController textFilterController = searchController.addTextFilter("displayName", i18n.get("mod.displayName"), false);
textFilterController.setText(modSearch.getModNameField());
modSearch.modNameFieldProperty().bind(textFilterController.textFieldProperty().when(showing));
textFilterController = searchController.addTextFilter("author", i18n.get("mod.author"), false);
textFilterController.setText(modSearch.getModAuthorField());
modSearch.modAuthorFieldProperty().bind(textFilterController.textFieldProperty().when(showing));

DateRangeFilterController dateRangeFilterController = searchController.addDateRangeFilter("latestVersion.updateTime", i18n.get("mod.uploadedDateTime"), 0);
dateRangeFilterController.setBeforeDate(modSearch.getUploadedBeforeDate());
dateRangeFilterController.setAfterDate(modSearch.getUploadedAfterDate());
modSearch.uploadedBeforeDateProperty().bind(dateRangeFilterController.beforeDateProperty().when(showing));
modSearch.uploadedAfterDateProperty().bind(dateRangeFilterController.afterDateProperty().when(showing));

RangeFilterController rangeFilter = searchController.addRangeFilter("reviewsSummary.averageScore", i18n.get("reviews.averageScore"), 0, 5, 10, 4, 1);
rangeFilter.setLowValue(modSearch.getAverageReviewScoresMin());
rangeFilter.setHighValue(modSearch.getAverageReviewScoresMax());
modSearch.averageReviewScoresMinProperty().bind(rangeFilter.lowValueProperty().asObject().when(showing));
modSearch.averageReviewScoresMaxProperty().bind(rangeFilter.highValueProperty().asObject().when(showing));


BinaryFilterController binaryFilter = searchController.addBinaryFilter("latestVersion.type", i18n.get("mod.type"),
searchController.addBinaryFilter("latestVersion.type", i18n.get("mod.type"),
ModType.UI.toString(), ModType.SIM.toString(), i18n.get("modType.ui"), i18n.get("modType.sim"));
binaryFilter.setFirstSelected(modSearch.getUiMod());
binaryFilter.setSecondSelected(modSearch.getSimMod());
modSearch.uiModProperty().bind(binaryFilter.firstSelectedProperty().when(showing));
modSearch.simModProperty().bind(binaryFilter.secondSelectedProperty().when(showing));

ToggleFilterController toggleFilterController = searchController.addToggleFilter("latestVersion.ranked", i18n.get("mod.onlyRanked"), "true");
toggleFilterController.setSelected(modSearch.getOnlyRanked());
modSearch.onlyRankedProperty().bind(toggleFilterController.selectedProperty().when(showing));
searchController.addToggleFilter("latestVersion.ranked", i18n.get("mod.onlyRanked"), "true");
}

@Override
Expand Down
130 changes: 0 additions & 130 deletions src/main/java/com/faforever/client/preferences/ModSearchPrefs.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public class VaultPrefs {
@JsonMerge
@Getter
private final MapSearchPrefs mapSearch = new MapSearchPrefs();
@JsonMerge
@Getter
private final ModSearchPrefs modSearch = new ModSearchPrefs();

public SortConfig getOnlineReplaySortConfig() {
return onlineReplaySortConfig.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.rutledgepaulv.qbuilders.conditions.Condition;
import com.github.rutledgepaulv.qbuilders.properties.concrete.StringProperty;
import javafx.beans.InvalidationListener;
import javafx.beans.property.BooleanProperty;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -81,20 +80,4 @@ public Node getRoot() {
return binaryFilter;
}

public BooleanProperty firstSelectedProperty() {
return this.firstCheckBox.selectedProperty();
}

public void setFirstSelected(boolean isSelected) {
firstCheckBox.setSelected(isSelected);
}

public BooleanProperty secondSelectedProperty() {
return this.secondCheckBox.selectedProperty();
}

public void setSecondSelected(boolean isSelected) {
secondCheckBox.setSelected(isSelected);
}

}
37 changes: 0 additions & 37 deletions src/test/java/com/faforever/client/mod/ModVaultControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
import com.faforever.client.i18n.I18n;
import com.faforever.client.notification.NotificationService;
import com.faforever.client.preferences.VaultPrefs;
import com.faforever.client.query.BinaryFilterController;
import com.faforever.client.query.DateRangeFilterController;
import com.faforever.client.query.LogicalNodeController;
import com.faforever.client.query.RangeFilterController;
import com.faforever.client.query.SpecificationController;
import com.faforever.client.query.TextFilterController;
import com.faforever.client.query.ToggleFilterController;
import com.faforever.client.reporting.ReportingService;
import com.faforever.client.test.PlatformTest;
import com.faforever.client.theme.UiService;
Expand All @@ -20,10 +15,6 @@
import com.faforever.client.vault.search.SearchController;
import com.faforever.client.vault.search.SearchController.SearchConfig;
import com.faforever.client.vault.search.SearchController.SortConfig;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.layout.Pane;
import org.instancio.Instancio;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -34,14 +25,10 @@
import reactor.core.publisher.Mono;

import java.net.MalformedURLException;
import java.time.LocalDate;
import java.util.List;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
Expand All @@ -68,16 +55,6 @@ public class ModVaultControllerTest extends PlatformTest {
@Mock
private SpecificationController specificationController;
@Mock
private BinaryFilterController binaryFilterController;
@Mock
private DateRangeFilterController dateRangeFilterController;
@Mock
private RangeFilterController rangeFilterController;
@Mock
private TextFilterController textFilterController;
@Mock
private ToggleFilterController toggleFilterController;
@Mock
private ReportingService reportingService;
@Mock
private PlatformService platformService;
Expand All @@ -97,20 +74,6 @@ public void setUp() throws Exception {
Mono.zip(Mono.just(List.of()), Mono.just(0)));
when(i18n.get(anyString())).thenReturn("test");
when(modDetailController.getRoot()).thenReturn(new Pane());
when(searchController.addBinaryFilter(anyString(), anyString(), anyString(), anyString(), anyString(), anyString())).thenReturn(binaryFilterController);
when(binaryFilterController.firstSelectedProperty()).thenReturn(new SimpleBooleanProperty());
when(binaryFilterController.secondSelectedProperty()).thenReturn(new SimpleBooleanProperty());
when(searchController.addTextFilter(anyString(), anyString(), anyBoolean())).thenReturn(textFilterController);
when(textFilterController.textFieldProperty()).thenReturn(new SimpleStringProperty());
when(searchController.addRangeFilter(anyString(), anyString(), anyDouble(), anyDouble(), anyInt(), anyInt(), anyInt())).thenReturn(rangeFilterController);
when(searchController.addRangeFilter(anyString(), anyString(), anyDouble(), anyDouble(), anyInt(), anyInt(), anyInt(), any())).thenReturn(rangeFilterController);
when(rangeFilterController.lowValueProperty()).thenReturn(new SimpleDoubleProperty());
when(rangeFilterController.highValueProperty()).thenReturn(new SimpleDoubleProperty());
when(searchController.addToggleFilter(anyString(), anyString(), anyString())).thenReturn(toggleFilterController);
when(toggleFilterController.selectedProperty()).thenReturn(new SimpleBooleanProperty());
when(searchController.addDateRangeFilter(anyString(), anyString(), anyInt())).thenReturn(dateRangeFilterController);
when(dateRangeFilterController.beforeDateProperty()).thenReturn(new SimpleObjectProperty<LocalDate>());
when(dateRangeFilterController.afterDateProperty()).thenReturn(new SimpleObjectProperty<LocalDate>());

when(uiService.loadFxml("theme/vault/mod/mod_detail.fxml")).thenReturn(modDetailController);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.github.rutledgepaulv.qbuilders.properties.concrete.StringProperty;
import com.github.rutledgepaulv.qbuilders.visitors.RSQLVisitor;
import javafx.beans.InvalidationListener;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.layout.GridPane;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -18,7 +16,6 @@
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -103,22 +100,4 @@ public void testGetConditionOneChecked() throws Exception {
assertTrue(result.isPresent());
assertEquals(result.get().getFirst().query(new RSQLVisitor()), property.in(secondValue).query(new RSQLVisitor()));
}

@Test
public void testPersistentPropertiesGetValue() {
BooleanProperty firstProperty = new SimpleBooleanProperty();
BooleanProperty secondProperty = new SimpleBooleanProperty();
firstProperty.bind(instance.firstSelectedProperty());
secondProperty.bind(instance.secondSelectedProperty());

instance.firstCheckBox.setSelected(true);
instance.secondCheckBox.setSelected(true);
assertTrue(firstProperty.get());
assertTrue(secondProperty.get());

instance.firstCheckBox.setSelected(false);
instance.secondCheckBox.setSelected(false);
assertFalse(firstProperty.get());
assertFalse(secondProperty.get());
}
}

0 comments on commit 16fc9a2

Please sign in to comment.