Fixed: Selection of last added custom filter

(cherry picked from commit 1f97679868012b70beecc553557e96e6c8bc80e3)

Closes #4627
pull/4637/head
Bogdan 3 months ago
parent 3ff9b8bd85
commit 022fbf864c

@ -1,3 +1,4 @@
import { maxBy } from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import FormInputGroup from 'Components/Form/FormInputGroup'; import FormInputGroup from 'Components/Form/FormInputGroup';
@ -50,7 +51,7 @@ class FilterBuilderModalContent extends Component {
if (id) { if (id) {
dispatchSetFilter({ selectedFilterKey: id }); dispatchSetFilter({ selectedFilterKey: id });
} else { } else {
const last = customFilters[customFilters.length -1]; const last = maxBy(customFilters, 'id');
dispatchSetFilter({ selectedFilterKey: last.id }); dispatchSetFilter({ selectedFilterKey: last.id });
} }
@ -108,7 +109,7 @@ class FilterBuilderModalContent extends Component {
this.setState({ this.setState({
labelErrors: [ labelErrors: [
{ {
message: 'Label is required' message: translate('LabelIsRequired')
} }
] ]
}); });
@ -146,7 +147,7 @@ class FilterBuilderModalContent extends Component {
return ( return (
<ModalContent onModalClose={onModalClose}> <ModalContent onModalClose={onModalClose}>
<ModalHeader> <ModalHeader>
Custom Filter {translate('CustomFilter')}
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
@ -166,7 +167,9 @@ class FilterBuilderModalContent extends Component {
</div> </div>
</div> </div>
<div className={styles.label}>{translate('Filters')}</div> <div className={styles.label}>
{translate('Filters')}
</div>
<div className={styles.rows}> <div className={styles.rows}>
{ {

@ -37,8 +37,8 @@ class CustomFilter extends Component {
dispatchSetFilter dispatchSetFilter
} = this.props; } = this.props;
// Assume that delete and then unmounting means the delete was successful. // Assume that delete and then unmounting means the deletion was successful.
// Moving this check to a ancestor would be more accurate, but would have // Moving this check to an ancestor would be more accurate, but would have
// more boilerplate. // more boilerplate.
if (this.state.isDeleting && id === selectedFilterKey) { if (this.state.isDeleting && id === selectedFilterKey) {
dispatchSetFilter({ selectedFilterKey: 'all' }); dispatchSetFilter({ selectedFilterKey: 'all' });

@ -245,6 +245,7 @@
"CreateEmptyArtistFoldersHelpText": "Create missing artist folders during disk scan", "CreateEmptyArtistFoldersHelpText": "Create missing artist folders during disk scan",
"CreateGroup": "Create group", "CreateGroup": "Create group",
"Custom": "Custom", "Custom": "Custom",
"CustomFilter": "Custom Filter",
"CustomFilters": "Custom Filters", "CustomFilters": "Custom Filters",
"CustomFormat": "Custom Format", "CustomFormat": "Custom Format",
"CustomFormatRequiredHelpText": "This {0} condition must match for the custom format to apply. Otherwise a single {0} match is sufficient.", "CustomFormatRequiredHelpText": "This {0} condition must match for the custom format to apply. Otherwise a single {0} match is sufficient.",
@ -482,8 +483,8 @@
"FormatAgeHours": "hours", "FormatAgeHours": "hours",
"FormatAgeMinute": "minute", "FormatAgeMinute": "minute",
"FormatAgeMinutes": "minutes", "FormatAgeMinutes": "minutes",
"FormatDateTimeRelative": "{relativeDay}, {formattedDate} {formattedTime}",
"FormatDateTime": "{formattedDate} {formattedTime}", "FormatDateTime": "{formattedDate} {formattedTime}",
"FormatDateTimeRelative": "{relativeDay}, {formattedDate} {formattedTime}",
"FormatRuntimeHours": "{hours}h", "FormatRuntimeHours": "{hours}h",
"FormatRuntimeMinutes": "{minutes}m", "FormatRuntimeMinutes": "{minutes}m",
"FormatShortTimeSpanHours": "{hours} hour(s)", "FormatShortTimeSpanHours": "{hours} hour(s)",
@ -609,6 +610,7 @@
"ItsEasyToAddANewArtistJustStartTypingTheNameOfTheArtistYouWantToAdd": "It's easy to add a new artist, just start typing the name of the artist you want to add.", "ItsEasyToAddANewArtistJustStartTypingTheNameOfTheArtistYouWantToAdd": "It's easy to add a new artist, just start typing the name of the artist you want to add.",
"KeyboardShortcuts": "Keyboard Shortcuts", "KeyboardShortcuts": "Keyboard Shortcuts",
"Label": "Label", "Label": "Label",
"LabelIsRequired": "Label is required",
"Language": "Language", "Language": "Language",
"Large": "Large", "Large": "Large",
"LastAlbum": "Last Album", "LastAlbum": "Last Album",

Loading…
Cancel
Save