mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Refactor Indexer index to use react-window
(cherry picked from commit d022679b7dcbce3cec98e6a1fd0879e3c0d92523)
This commit is contained in:
@@ -17,6 +17,7 @@ export const section = 'commands';
|
||||
let lastCommand = null;
|
||||
let lastCommandTimeout = null;
|
||||
const removeCommandTimeoutIds = {};
|
||||
const commandFinishedCallbacks = {};
|
||||
|
||||
//
|
||||
// State
|
||||
@@ -119,7 +120,7 @@ function scheduleRemoveCommand(command, dispatch) {
|
||||
}, 60000 * 5);
|
||||
}
|
||||
|
||||
export function executeCommandHelper( payload, dispatch) {
|
||||
export function executeCommandHelper(payload, dispatch) {
|
||||
// TODO: show a message for the user
|
||||
if (lastCommand && isSameCommand(lastCommand, payload)) {
|
||||
console.warn('Please wait at least 5 seconds before running this command again');
|
||||
@@ -136,14 +137,23 @@ export function executeCommandHelper( payload, dispatch) {
|
||||
lastCommand = null;
|
||||
}, 5000);
|
||||
|
||||
const {
|
||||
commandFinished,
|
||||
...requestPayload
|
||||
} = payload;
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/command',
|
||||
method: 'POST',
|
||||
data: JSON.stringify(payload),
|
||||
data: JSON.stringify(requestPayload),
|
||||
dataType: 'json'
|
||||
}).request;
|
||||
|
||||
return promise.then((data) => {
|
||||
if (commandFinished) {
|
||||
commandFinishedCallbacks[data.id] = commandFinished;
|
||||
}
|
||||
|
||||
dispatch(addCommand(data));
|
||||
});
|
||||
}
|
||||
@@ -183,12 +193,20 @@ export const actionHandlers = handleThunks({
|
||||
}
|
||||
});
|
||||
|
||||
const commandFinished = commandFinishedCallbacks[payload.id];
|
||||
|
||||
if (commandFinished) {
|
||||
commandFinished(payload);
|
||||
}
|
||||
|
||||
delete commandFinishedCallbacks[payload.id];
|
||||
|
||||
dispatch(updateItem({ section: 'commands', ...payload }));
|
||||
scheduleRemoveCommand(payload, dispatch);
|
||||
showCommandMessage(payload, dispatch);
|
||||
},
|
||||
|
||||
[ADD_COMMAND]: function(getState, payload, dispatch) {
|
||||
[REMOVE_COMMAND]: function(getState, payload, dispatch) {
|
||||
dispatch(removeItem({ section: 'commands', ...payload }));
|
||||
}
|
||||
|
||||
|
@@ -34,14 +34,6 @@ export const defaultState = {
|
||||
},
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'select',
|
||||
columnLabel: translate('Select'),
|
||||
isSortable: false,
|
||||
isVisible: true,
|
||||
isModifiable: false,
|
||||
isHidden: true
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
columnLabel: translate('ReleaseStatus'),
|
||||
@@ -178,20 +170,20 @@ export const persistState = [
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const SET_MOVIE_SORT = 'indexerIndex/setMovieSort';
|
||||
export const SET_MOVIE_FILTER = 'indexerIndex/setMovieFilter';
|
||||
export const SET_MOVIE_VIEW = 'indexerIndex/setMovieView';
|
||||
export const SET_MOVIE_TABLE_OPTION = 'indexerIndex/setMovieTableOption';
|
||||
export const SET_INDEXER_SORT = 'indexerIndex/setIndexerSort';
|
||||
export const SET_INDEXER_FILTER = 'indexerIndex/setIndexerFilter';
|
||||
export const SET_INDEXER_VIEW = 'indexerIndex/setIndexerView';
|
||||
export const SET_INDEXER_TABLE_OPTION = 'indexerIndex/setIndexerTableOption';
|
||||
export const SAVE_INDEXER_EDITOR = 'indexerIndex/saveIndexerEditor';
|
||||
export const BULK_DELETE_INDEXERS = 'indexerIndex/bulkDeleteIndexers';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const setMovieSort = createAction(SET_MOVIE_SORT);
|
||||
export const setMovieFilter = createAction(SET_MOVIE_FILTER);
|
||||
export const setMovieView = createAction(SET_MOVIE_VIEW);
|
||||
export const setMovieTableOption = createAction(SET_MOVIE_TABLE_OPTION);
|
||||
export const setIndexerSort = createAction(SET_INDEXER_SORT);
|
||||
export const setIndexerFilter = createAction(SET_INDEXER_FILTER);
|
||||
export const setIndexerView = createAction(SET_INDEXER_VIEW);
|
||||
export const setIndexerTableOption = createAction(SET_INDEXER_TABLE_OPTION);
|
||||
export const saveIndexerEditor = createThunk(SAVE_INDEXER_EDITOR);
|
||||
export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS);
|
||||
|
||||
@@ -281,13 +273,13 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[SET_MOVIE_SORT]: createSetClientSideCollectionSortReducer(section),
|
||||
[SET_MOVIE_FILTER]: createSetClientSideCollectionFilterReducer(section),
|
||||
[SET_INDEXER_SORT]: createSetClientSideCollectionSortReducer(section),
|
||||
[SET_INDEXER_FILTER]: createSetClientSideCollectionFilterReducer(section),
|
||||
|
||||
[SET_MOVIE_VIEW]: function(state, { payload }) {
|
||||
[SET_INDEXER_VIEW]: function(state, { payload }) {
|
||||
return Object.assign({}, state, { view: payload.view });
|
||||
},
|
||||
|
||||
[SET_MOVIE_TABLE_OPTION]: createSetTableOptionReducer(section)
|
||||
[SET_INDEXER_TABLE_OPTION]: createSetTableOptionReducer(section)
|
||||
|
||||
}, defaultState, section);
|
||||
|
Reference in New Issue
Block a user