Splitting out helpers into separate files

This commit is contained in:
James Barnsley
2020-03-03 16:39:37 +13:00
parent 57dd18e870
commit 5a1f08fdf0
105 changed files with 5456 additions and 5574 deletions

View File

@ -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 }));
}
},

View File

@ -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;