Skip to content

Commit

Permalink
Removed closest stations filter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlixH committed Nov 22, 2021
1 parent d511894 commit b91e384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
19 changes: 6 additions & 13 deletions src/screens/charging-stations/list/ChargingStations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
this.siteArea = Utils.getParamFromNavigation(route, 'siteArea', null) as unknown as SiteArea;
// Enable swipe for opening sidebar
this.parent = navigation.getParent();
this.parent.setOptions({
this.parent?.setOptions({
swipeEnabled: !this.siteArea
});
// Bind the back button to the onBack method (Android)
Expand All @@ -105,7 +105,7 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
// Unbind the back button and reset its default behavior (Android)
this.backHandler.remove();
// Disable swipe for opening sidebar
this.parent.setOptions({
this.parent?.setOptions({
swipeEnabled: false
});
}
Expand All @@ -115,7 +115,7 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.onBack.bind(this));
this.refresh();
// Enable swipe for opening sidebar
this.parent.setOptions({
this.parent?.setOptions({
swipeEnabled: !this.siteArea
});
}
Expand All @@ -124,7 +124,7 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
// Unbind the back button and reset its default behavior (Android)
this.backHandler.remove();
// Disable swipe for opening sidebar
this.parent.setOptions({
this.parent?.setOptions({
swipeEnabled: false
});
}
Expand All @@ -143,24 +143,17 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State
GlobalFilters.ONLY_AVAILABLE_CHARGING_STATIONS
)) as ChargePointStatus;
const connectorType = await SecuredStorage.loadFilterValue(centralServerProvider.getUserInfo(), GlobalFilters.CONNECTOR_TYPES);
const location = Utils.convertToBoolean(
await SecuredStorage.loadFilterValue(centralServerProvider.getUserInfo(), GlobalFilters.LOCATION)
);
this.setState({
initialFilters: { connectorStatus, connectorType, location: location ?? true },
filters: { connectorStatus, connectorType, location: location ?? true }
initialFilters: { connectorStatus, connectorType, location: true },
filters: { connectorStatus, connectorType, location: true }
});
}

public async getCurrentLocation(): Promise<Location> {
const { filters } = this.state;
// Get the current location
let currentLocation = (await LocationManager.getInstance()).getLocation();
this.locationEnabled = !!currentLocation;
// Bypass location
if (!filters.location) {
currentLocation = null;
}
return currentLocation;
}

Expand Down
15 changes: 1 addition & 14 deletions src/screens/charging-stations/list/ChargingStationsFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface State extends ScreenFiltersState {
}

export interface ChargingStationsFiltersDef {
location?: boolean;
connectorStatus?: ChargePointStatus;
connectorType?: string;
}
Expand Down Expand Up @@ -58,7 +57,7 @@ export default class ChargingStationsFilters extends ScreenFilters {
};

public render = () => {
const { initialFilters, locationEnabled } = this.props;
const { initialFilters } = this.props;
const { filters } = this.state;
const style = computeStyleSheet();
const controlStyle = computeControlStyleSheet();
Expand All @@ -81,18 +80,6 @@ export default class ChargingStationsFilters extends ScreenFilters {
) => this.addVisibleFilter(onlyAvailableChargingStationSwitchFilterControlComponent)}
/>
<Animatable.View style={style.filtersHidden} ref={this.setExpandableView}>
{locationEnabled && (
<LocationSwitchFilterControlComponent
filterID={'location'}
internalFilterID={GlobalFilters.LOCATION}
initialValue={filters.hasOwnProperty('location') ? filters.location : initialFilters.location}
label={I18n.t('general.location')}
onFilterChanged={async (id: string, value: boolean) => this.getFilterVisibleContainerComponent().setFilter(id, value)}
ref={async (locationSwitchFilterControlComponent: LocationSwitchFilterControlComponent) =>
this.addVisibleFilter(locationSwitchFilterControlComponent)
}
/>
)}
<ConnectorTypeFilterControlComponent
filterID={'connectorType'}
internalFilterID={GlobalFilters.CONNECTOR_TYPES}
Expand Down

0 comments on commit b91e384

Please sign in to comment.