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-04-29 11:50:29 +02:00
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
export function doFetchAvailability(uri) {
|
2017-04-29 11:50:29 +02:00
|
|
|
return function(dispatch, getState) {
|
2017-09-20 14:47:08 +02:00
|
|
|
/*
|
|
|
|
this is disabled atm - Jeremy
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
|
|
|
const alreadyFetching = !!selectFetchingAvailability(state)[uri];
|
2017-04-29 11:50:29 +02:00
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
if (!alreadyFetching) {
|
2017-04-29 11:50:29 +02:00
|
|
|
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-04-29 19:02:25 +02:00
|
|
|
|
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-04-29 19:02:25 +02:00
|
|
|
}
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-06-06 06:21:55 +02:00
|
|
|
}
|