1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/actions/piece_list_actions.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
import alt from '../alt';
import PieceListFetcher from '../fetchers/piece_list_fetcher';
class PieceListActions {
constructor() {
this.generateActions(
2015-07-01 19:05:47 +02:00
'updatePieceList',
2015-07-09 15:44:20 +02:00
'updatePieceListRequestActions',
2015-07-10 13:54:25 +02:00
'updatePropertyForPiece'
);
}
2015-05-22 11:33:38 +02:00
fetchPieceList(page, pageSize, search, orderBy, orderAsc) {
2015-07-01 19:05:47 +02:00
return new Promise((resolve, reject) => {
PieceListFetcher
.fetch(page, pageSize, search, orderBy, orderAsc)
.then((res) => {
this.actions.updatePieceList({
page,
pageSize,
search,
orderBy,
orderAsc,
'pieceList': res.pieces,
'pieceListCount': res.count
});
resolve();
2015-07-07 09:22:46 +02:00
})
.catch((err) => reject(err));
2015-07-01 19:05:47 +02:00
});
}
2015-07-09 15:44:20 +02:00
2015-07-01 19:05:47 +02:00
fetchPieceRequestActions() {
PieceListFetcher
2015-07-01 19:05:47 +02:00
.fetchRequestActions()
.then((res) => {
2015-07-01 19:05:47 +02:00
this.actions.updatePieceListRequestActions(res.piece_ids);
});
}
}
export default alt.createActions(PieceListActions);