import types from '../types' import actions from '../actions' import util from '../util' export const load = () => (dispatch) => { util.allProgress([ actions.task.index({ limit: 40, orderBy: 'created_at desc', }), actions.folder.index({ activity: 'dataset', }), actions.file.index({ module: 'samplernn', generated: 1, limit: 15, orderBy: 'created_at desc', }), actions.file.index({ module: 'pix2pixhd', generated: 1, limit: 15, orderBy: 'created_at desc', }), actions.file.index({ module: 'morph', generated: 1, limit: 15, orderBy: 'created_at desc', }), ], (percent, i, n) => { // console.log('dashboard load progress', i, n) dispatch({ type: types.app.load_progress, progress: { i, n }, data: { module: 'dashboard' } }) }).then(res => { const [ tasks, folders, samplernn, pix2pixhd, morph ] = res const { mapFn, sortFn } = util.sort.orderByFn('date desc') const foldersByModule = folders.map(mapFn).sort(sortFn).reduce((a,b) => { const module = b[1].module a[module] = a[module] || [] a[module].push(b[1]) return a }, {}) dispatch({ type: types.dashboard.load, data: { tasks, folders, foldersByModule, renders: { samplernn, pix2pixhd, morph, }, }, }) }) }