lbry-desktop/ui/js/actions/availability.js

33 lines
757 B
JavaScript
Raw Normal View History

2017-06-06 23:19:12 +02:00
import * as types from "constants/action_types";
import lbry from "lbry";
import { selectFetchingAvailability } from "selectors/availability";
2017-05-15 05:50:59 +02:00
export function doFetchAvailability(uri) {
return function(dispatch, getState) {
/*
this is disabled atm - Jeremy
*/
return;
2017-06-06 23:19:12 +02:00
const state = getState();
const alreadyFetching = !!selectFetchingAvailability(state)[uri];
2017-05-15 05:50:59 +02:00
if (!alreadyFetching) {
dispatch({
2017-05-15 05:50:59 +02:00
type: types.FETCH_AVAILABILITY_STARTED,
2017-06-06 23:19:12 +02:00
data: { uri },
});
2017-06-06 23:19:12 +02:00
lbry.get_availability({ uri }).then(availability => {
2017-05-15 05:50:59 +02:00
dispatch({
type: types.FETCH_AVAILABILITY_COMPLETED,
data: {
availability,
uri,
2017-06-06 23:19:12 +02:00
},
});
});
}
2017-06-06 23:19:12 +02:00
};
2017-06-06 06:21:55 +02:00
}