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