mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Added: Device load support for Pushbullet
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
e41f884153
commit
23bc5b11cf
19 changed files with 439 additions and 27 deletions
83
frontend/src/Store/Actions/deviceActions.js
Normal file
83
frontend/src/Store/Actions/deviceActions.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
import { createAction } from 'redux-actions';
|
||||
import requestAction from 'Utilities/requestAction';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import { set } from './baseActions';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
export const section = 'devices';
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
export const defaultState = {
|
||||
items: [],
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: false
|
||||
};
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_DEVICES = 'devices/fetchDevices';
|
||||
export const CLEAR_DEVICES = 'devices/clearDevices';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchDevices = createThunk(FETCH_DEVICES);
|
||||
export const clearDevices = createAction(CLEAR_DEVICES);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
|
||||
[FETCH_DEVICES]: function(getState, payload, dispatch) {
|
||||
const actionPayload = {
|
||||
action: 'getDevices',
|
||||
...payload
|
||||
};
|
||||
|
||||
dispatch(set({
|
||||
section,
|
||||
isFetching: true
|
||||
}));
|
||||
|
||||
const promise = requestAction(actionPayload);
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isFetching: false,
|
||||
isPopulated: true,
|
||||
error: null,
|
||||
items: data.devices || []
|
||||
}));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: xhr
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[CLEAR_DEVICES]: function(state) {
|
||||
return updateSectionState(state, section, defaultState);
|
||||
}
|
||||
|
||||
}, defaultState, section);
|
|
@ -2,6 +2,7 @@ import * as addArtist from './addArtistActions';
|
|||
import * as app from './appActions';
|
||||
import * as blacklist from './blacklistActions';
|
||||
import * as captcha from './captchaActions';
|
||||
import * as devices from './deviceActions';
|
||||
import * as calendar from './calendarActions';
|
||||
import * as commands from './commandActions';
|
||||
import * as albums from './albumActions';
|
||||
|
@ -34,6 +35,7 @@ export default [
|
|||
captcha,
|
||||
calendar,
|
||||
commands,
|
||||
devices,
|
||||
albums,
|
||||
trackFiles,
|
||||
albumHistory,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue