Splitting out helpers into separate files
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
|
||||
import { formatImages } from '../../util/format';
|
||||
import { generateGuid } from '../../util/helpers';
|
||||
|
||||
const coreActions = require('../core/actions');
|
||||
const uiActions = require('../ui/actions');
|
||||
const helpers = require('../../helpers');
|
||||
|
||||
export function set(data) {
|
||||
return {
|
||||
@ -36,7 +38,7 @@ const sendRequest = (dispatch, getState, params, signed = false) => new Promise(
|
||||
timeout: 30000,
|
||||
};
|
||||
|
||||
const loader_key = helpers.generateGuid();
|
||||
const loader_key = generateGuid();
|
||||
dispatch(uiActions.startLoading(loader_key, `lastfm_${method}`));
|
||||
|
||||
function status(response) {
|
||||
@ -76,7 +78,7 @@ const sendSignedRequest = (dispatch, getState, params) => new Promise((resolve,
|
||||
});
|
||||
}
|
||||
|
||||
const loader_key = helpers.generateGuid();
|
||||
const loader_key = generateGuid();
|
||||
let method = params.substring(params.indexOf('method=') + 7, params.length);
|
||||
method = method.substring(0, method.indexOf('&'));
|
||||
|
||||
@ -311,7 +313,7 @@ export function getImages(context, uri) {
|
||||
.then(
|
||||
(response) => {
|
||||
if (response.album) {
|
||||
const images = helpers.formatImages(response.album.image);
|
||||
const images = formatImages(response.album.image);
|
||||
dispatch(coreActions.trackLoaded({ uri, images }));
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
|
||||
const helpers = require('./../../helpers');
|
||||
import { formatUser } from '../../util/format';
|
||||
const coreActions = require('../core/actions');
|
||||
const lastfmActions = require('./actions');
|
||||
|
||||
const LastfmMiddleware = (function () {
|
||||
const LastfmMiddleware = (function () {
|
||||
return (store) => (next) => (action) => {
|
||||
switch (action.type) {
|
||||
switch (action.type) {
|
||||
case 'LASTFM_ME_LOADED':
|
||||
var me = helpers.formatUser(action.me);
|
||||
var me = formatUser(action.me);
|
||||
Object.assign(
|
||||
me,
|
||||
{
|
||||
@ -34,4 +34,4 @@ const LastfmMiddleware = (function () {
|
||||
};
|
||||
}());
|
||||
|
||||
export default LastfmMiddleware;
|
||||
export default LastfmMiddleware;
|
||||
|
||||
Reference in New Issue
Block a user