mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: Changes to Profiles, Languages, Manual Import
This commit is contained in:
48
frontend/src/Store/Actions/Settings/languages.js
Normal file
48
frontend/src/Store/Actions/Settings/languages.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { createThunk } from 'Store/thunks';
|
||||
import createFetchHandler from 'Store/Actions/Creators/createFetchHandler';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
const section = 'settings.languages';
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_LANGUAGES = 'settings/languages/fetchLanguages';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchLanguages = createThunk(FETCH_LANGUAGES);
|
||||
|
||||
//
|
||||
// Details
|
||||
|
||||
export default {
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
defaultState: {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
items: []
|
||||
},
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
actionHandlers: {
|
||||
[FETCH_LANGUAGES]: createFetchHandler(section, '/language')
|
||||
},
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
||||
reducers: {
|
||||
|
||||
}
|
||||
|
||||
};
|
@@ -2,11 +2,9 @@ import moment from 'moment';
|
||||
import { createAction } from 'redux-actions';
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import { sortDirections } from 'Helpers/Props';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import { set, update } from './baseActions';
|
||||
|
||||
@@ -15,8 +13,6 @@ import { set, update } from './baseActions';
|
||||
|
||||
export const section = 'interactiveImport';
|
||||
|
||||
const episodesSection = `${section}.episodes`;
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
@@ -36,24 +32,15 @@ export const defaultState = {
|
||||
return relativePath.toLowerCase();
|
||||
},
|
||||
|
||||
series: function(item, direction) {
|
||||
const series = item.series;
|
||||
movie: function(item, direction) {
|
||||
const movie = item.movie;
|
||||
|
||||
return series ? series.sortTitle : '';
|
||||
return movie ? movie.sortTitle : '';
|
||||
},
|
||||
|
||||
quality: function(item, direction) {
|
||||
return item.quality ? item.quality.qualityWeight : 0;
|
||||
}
|
||||
},
|
||||
|
||||
episodes: {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'episodeNumber',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: []
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,30 +55,24 @@ export const persistState = [
|
||||
export const FETCH_INTERACTIVE_IMPORT_ITEMS = 'interactiveImport/fetchInteractiveImportItems';
|
||||
export const SET_INTERACTIVE_IMPORT_SORT = 'interactiveImport/setInteractiveImportSort';
|
||||
export const UPDATE_INTERACTIVE_IMPORT_ITEM = 'interactiveImport/updateInteractiveImportItem';
|
||||
export const UPDATE_INTERACTIVE_IMPORT_ITEMS = 'interactiveImport/updateInteractiveImportItems';
|
||||
export const CLEAR_INTERACTIVE_IMPORT = 'interactiveImport/clearInteractiveImport';
|
||||
export const ADD_RECENT_FOLDER = 'interactiveImport/addRecentFolder';
|
||||
export const REMOVE_RECENT_FOLDER = 'interactiveImport/removeRecentFolder';
|
||||
export const SET_INTERACTIVE_IMPORT_MODE = 'interactiveImport/setInteractiveImportMode';
|
||||
|
||||
export const FETCH_INTERACTIVE_IMPORT_EPISODES = 'interactiveImport/fetchInteractiveImportEpisodes';
|
||||
export const SET_INTERACTIVE_IMPORT_EPISODES_SORT = 'interactiveImport/setInteractiveImportEpisodesSort';
|
||||
export const CLEAR_INTERACTIVE_IMPORT_EPISODES = 'interactiveImport/clearInteractiveImportEpisodes';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchInteractiveImportItems = createThunk(FETCH_INTERACTIVE_IMPORT_ITEMS);
|
||||
export const setInteractiveImportSort = createAction(SET_INTERACTIVE_IMPORT_SORT);
|
||||
export const updateInteractiveImportItem = createAction(UPDATE_INTERACTIVE_IMPORT_ITEM);
|
||||
export const updateInteractiveImportItems = createAction(UPDATE_INTERACTIVE_IMPORT_ITEMS);
|
||||
export const clearInteractiveImport = createAction(CLEAR_INTERACTIVE_IMPORT);
|
||||
export const addRecentFolder = createAction(ADD_RECENT_FOLDER);
|
||||
export const removeRecentFolder = createAction(REMOVE_RECENT_FOLDER);
|
||||
export const setInteractiveImportMode = createAction(SET_INTERACTIVE_IMPORT_MODE);
|
||||
|
||||
export const fetchInteractiveImportEpisodes = createThunk(FETCH_INTERACTIVE_IMPORT_EPISODES);
|
||||
export const setInteractiveImportEpisodesSort = createAction(SET_INTERACTIVE_IMPORT_EPISODES_SORT);
|
||||
export const clearInteractiveImportEpisodes = createAction(CLEAR_INTERACTIVE_IMPORT_EPISODES);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
export const actionHandlers = handleThunks({
|
||||
@@ -129,9 +110,7 @@ export const actionHandlers = handleThunks({
|
||||
error: xhr
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
[FETCH_INTERACTIVE_IMPORT_EPISODES]: createFetchHandler('interactiveImport.episodes', '/episode')
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
@@ -152,6 +131,23 @@ export const reducers = createHandleActions({
|
||||
return newState;
|
||||
},
|
||||
|
||||
[UPDATE_INTERACTIVE_IMPORT_ITEMS]: (state, { payload }) => {
|
||||
const ids = payload.ids;
|
||||
const newState = Object.assign({}, state);
|
||||
const items = [...newState.items];
|
||||
|
||||
ids.forEach((id) => {
|
||||
const index = items.findIndex((item) => item.id === id);
|
||||
const item = Object.assign({}, items[index], payload);
|
||||
|
||||
items.splice(index, 1, item);
|
||||
});
|
||||
|
||||
newState.items = items;
|
||||
|
||||
return newState;
|
||||
},
|
||||
|
||||
[ADD_RECENT_FOLDER]: function(state, { payload }) {
|
||||
const folder = payload.folder;
|
||||
const recentFolder = { folder, lastUsed: moment().toISOString() };
|
||||
@@ -191,14 +187,6 @@ export const reducers = createHandleActions({
|
||||
|
||||
[SET_INTERACTIVE_IMPORT_MODE]: function(state, { payload }) {
|
||||
return Object.assign({}, state, { importMode: payload.importMode });
|
||||
},
|
||||
|
||||
[SET_INTERACTIVE_IMPORT_EPISODES_SORT]: createSetClientSideCollectionSortReducer(episodesSection),
|
||||
|
||||
[CLEAR_INTERACTIVE_IMPORT_EPISODES]: (state) => {
|
||||
return updateSectionState(state, episodesSection, {
|
||||
...defaultState.episodes
|
||||
});
|
||||
}
|
||||
|
||||
}, defaultState, section);
|
||||
|
@@ -8,6 +8,7 @@ import downloadClientOptions from './Settings/downloadClientOptions';
|
||||
import general from './Settings/general';
|
||||
import indexerOptions from './Settings/indexerOptions';
|
||||
import indexers from './Settings/indexers';
|
||||
import languages from './Settings/languages';
|
||||
import netImportOptions from './Settings/netImportOptions';
|
||||
import netImports from './Settings/netImports';
|
||||
import mediaManagement from './Settings/mediaManagement';
|
||||
@@ -28,6 +29,7 @@ export * from './Settings/downloadClientOptions';
|
||||
export * from './Settings/general';
|
||||
export * from './Settings/indexerOptions';
|
||||
export * from './Settings/indexers';
|
||||
export * from './Settings/languages';
|
||||
export * from './Settings/netImportOptions';
|
||||
export * from './Settings/netImports';
|
||||
export * from './Settings/mediaManagement';
|
||||
@@ -59,6 +61,7 @@ export const defaultState = {
|
||||
general: general.defaultState,
|
||||
indexerOptions: indexerOptions.defaultState,
|
||||
indexers: indexers.defaultState,
|
||||
languages: languages.defaultState,
|
||||
netImportOptions: netImportOptions.defaultState,
|
||||
netImports: netImports.defaultState,
|
||||
mediaManagement: mediaManagement.defaultState,
|
||||
@@ -98,6 +101,7 @@ export const actionHandlers = handleThunks({
|
||||
...general.actionHandlers,
|
||||
...indexerOptions.actionHandlers,
|
||||
...indexers.actionHandlers,
|
||||
...languages.actionHandlers,
|
||||
...netImportOptions.actionHandlers,
|
||||
...netImports.actionHandlers,
|
||||
...mediaManagement.actionHandlers,
|
||||
@@ -128,6 +132,7 @@ export const reducers = createHandleActions({
|
||||
...general.reducers,
|
||||
...indexerOptions.reducers,
|
||||
...indexers.reducers,
|
||||
...languages.reducers,
|
||||
...netImportOptions.reducers,
|
||||
...netImports.reducers,
|
||||
...mediaManagement.reducers,
|
||||
|
Reference in New Issue
Block a user