New: AutoFocus search and Search on 'Enter'

Fixes #113
pull/133/head
Qstick 4 years ago
parent 63b6adf0e1
commit 4a851c37d5

@ -50,7 +50,7 @@ class TagsModalContent extends Component {
render() { render() {
const { const {
movieTags, indexerTags,
tagList, tagList,
onModalClose onModalClose
} = this.props; } = this.props;
@ -108,7 +108,7 @@ class TagsModalContent extends Component {
<div className={styles.result}> <div className={styles.result}>
{ {
movieTags.map((t) => { indexerTags.map((t) => {
const tag = _.find(tagList, { id: t }); const tag = _.find(tagList, { id: t });
if (!tag) { if (!tag) {
@ -140,7 +140,7 @@ class TagsModalContent extends Component {
return null; return null;
} }
if (movieTags.indexOf(t) > -1) { if (indexerTags.indexOf(t) > -1) {
return null; return null;
} }
@ -179,7 +179,7 @@ class TagsModalContent extends Component {
} }
TagsModalContent.propTypes = { TagsModalContent.propTypes = {
movieTags: PropTypes.arrayOf(PropTypes.number).isRequired, indexerTags: PropTypes.arrayOf(PropTypes.number).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired, tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
onApplyTagsPress: PropTypes.func.isRequired onApplyTagsPress: PropTypes.func.isRequired

@ -10,15 +10,15 @@ function createMapStateToProps() {
(state, { indexerIds }) => indexerIds, (state, { indexerIds }) => indexerIds,
createAllIndexersSelector(), createAllIndexersSelector(),
createTagsSelector(), createTagsSelector(),
(indexerIds, allMovies, tagList) => { (indexerIds, allIndexers, tagList) => {
const movies = _.intersectionWith(allMovies, indexerIds, (s, id) => { const indexers = _.intersectionWith(allIndexers, indexerIds, (s, id) => {
return s.id === id; return s.id === id;
}); });
const movieTags = _.uniq(_.concat(..._.map(movies, 'tags'))); const indexerTags = _.uniq(_.concat(..._.map(indexers, 'tags')));
return { return {
movieTags, indexerTags,
tagList tagList
}; };
} }

@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import withScrollPosition from 'Components/withScrollPosition'; import withScrollPosition from 'Components/withScrollPosition';
import { testAllIndexers } from 'Store/Actions/indexerActions'; import { testAllIndexers } from 'Store/Actions/indexerActions';
import { saveMovieEditor, setMovieFilter, setMovieSort, setMovieTableOption } from 'Store/Actions/indexerIndexActions'; import { saveIndexerEditor, setMovieFilter, setMovieSort, setMovieTableOption } from 'Store/Actions/indexerIndexActions';
import scrollPositions from 'Store/scrollPositions'; import scrollPositions from 'Store/scrollPositions';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import createIndexerClientSideCollectionItemsSelector from 'Store/Selectors/createIndexerClientSideCollectionItemsSelector'; import createIndexerClientSideCollectionItemsSelector from 'Store/Selectors/createIndexerClientSideCollectionItemsSelector';
@ -40,8 +40,8 @@ function createMapDispatchToProps(dispatch, props) {
dispatch(setMovieFilter({ selectedFilterKey })); dispatch(setMovieFilter({ selectedFilterKey }));
}, },
dispatchSaveMovieEditor(payload) { dispatchSaveIndexerEditor(payload) {
dispatch(saveMovieEditor(payload)); dispatch(saveIndexerEditor(payload));
}, },
onTestAllPress() { onTestAllPress() {
@ -56,7 +56,7 @@ class IndexerIndexConnector extends Component {
// Listeners // Listeners
onSaveSelected = (payload) => { onSaveSelected = (payload) => {
this.props.dispatchSaveMovieEditor(payload); this.props.dispatchSaveIndexerEditor(payload);
} }
onScroll = ({ scrollTop }) => { onScroll = ({ scrollTop }) => {
@ -79,7 +79,7 @@ class IndexerIndexConnector extends Component {
IndexerIndexConnector.propTypes = { IndexerIndexConnector.propTypes = {
isSmallScreen: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired,
dispatchSaveMovieEditor: PropTypes.func.isRequired, dispatchSaveIndexerEditor: PropTypes.func.isRequired,
items: PropTypes.arrayOf(PropTypes.object) items: PropTypes.arrayOf(PropTypes.object)
}; };

@ -4,6 +4,7 @@ import React, { Component } from 'react';
import IndexersSelectInputConnector from 'Components/Form/IndexersSelectInputConnector'; import IndexersSelectInputConnector from 'Components/Form/IndexersSelectInputConnector';
import NewznabCategorySelectInputConnector from 'Components/Form/NewznabCategorySelectInputConnector'; import NewznabCategorySelectInputConnector from 'Components/Form/NewznabCategorySelectInputConnector';
import TextInput from 'Components/Form/TextInput'; import TextInput from 'Components/Form/TextInput';
import keyboardShortcuts from 'Components/keyboardShortcuts';
import SpinnerButton from 'Components/Link/SpinnerButton'; import SpinnerButton from 'Components/Link/SpinnerButton';
import PageContentFooter from 'Components/Page/PageContentFooter'; import PageContentFooter from 'Components/Page/PageContentFooter';
import SearchFooterLabel from './SearchFooterLabel'; import SearchFooterLabel from './SearchFooterLabel';
@ -41,6 +42,8 @@ class SearchFooter extends Component {
if (searchQuery !== '' || searchCategories !== [] || searchIndexerIds !== []) { if (searchQuery !== '' || searchCategories !== [] || searchIndexerIds !== []) {
this.onSearchPress(); this.onSearchPress();
} }
this.props.bindShortcut('enter', this.onSearchPress, { isGlobal: true });
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
@ -114,6 +117,7 @@ class SearchFooter extends Component {
<TextInput <TextInput
name='searchQuery' name='searchQuery'
autoFocus={true}
value={searchQuery} value={searchQuery}
isDisabled={isFetching} isDisabled={isFetching}
onChange={onInputChange} onChange={onInputChange}
@ -181,7 +185,8 @@ SearchFooter.propTypes = {
onSearchPress: PropTypes.func.isRequired, onSearchPress: PropTypes.func.isRequired,
hasIndexers: PropTypes.bool.isRequired, hasIndexers: PropTypes.bool.isRequired,
onInputChange: PropTypes.func.isRequired, onInputChange: PropTypes.func.isRequired,
searchError: PropTypes.object searchError: PropTypes.object,
bindShortcut: PropTypes.func.isRequired
}; };
export default SearchFooter; export default keyboardShortcuts(SearchFooter);

@ -176,7 +176,7 @@ export const SET_MOVIE_SORT = 'indexerIndex/setMovieSort';
export const SET_MOVIE_FILTER = 'indexerIndex/setMovieFilter'; export const SET_MOVIE_FILTER = 'indexerIndex/setMovieFilter';
export const SET_MOVIE_VIEW = 'indexerIndex/setMovieView'; export const SET_MOVIE_VIEW = 'indexerIndex/setMovieView';
export const SET_MOVIE_TABLE_OPTION = 'indexerIndex/setMovieTableOption'; export const SET_MOVIE_TABLE_OPTION = 'indexerIndex/setMovieTableOption';
export const SAVE_MOVIE_EDITOR = 'indexerIndex/saveMovieEditor'; export const SAVE_INDEXER_EDITOR = 'indexerIndex/saveIndexerEditor';
export const BULK_DELETE_INDEXERS = 'indexerIndex/bulkDeleteIndexers'; export const BULK_DELETE_INDEXERS = 'indexerIndex/bulkDeleteIndexers';
// //
@ -186,14 +186,14 @@ export const setMovieSort = createAction(SET_MOVIE_SORT);
export const setMovieFilter = createAction(SET_MOVIE_FILTER); export const setMovieFilter = createAction(SET_MOVIE_FILTER);
export const setMovieView = createAction(SET_MOVIE_VIEW); export const setMovieView = createAction(SET_MOVIE_VIEW);
export const setMovieTableOption = createAction(SET_MOVIE_TABLE_OPTION); export const setMovieTableOption = createAction(SET_MOVIE_TABLE_OPTION);
export const saveMovieEditor = createThunk(SAVE_MOVIE_EDITOR); export const saveIndexerEditor = createThunk(SAVE_INDEXER_EDITOR);
export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS); export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS);
// //
// Action Handlers // Action Handlers
export const actionHandlers = handleThunks({ export const actionHandlers = handleThunks({
[SAVE_MOVIE_EDITOR]: function(getState, payload, dispatch) { [SAVE_INDEXER_EDITOR]: function(getState, payload, dispatch) {
dispatch(set({ dispatch(set({
section, section,
isSaving: true isSaving: true

Loading…
Cancel
Save