commit
ec26a1ff9c
6 changed files with 263 additions and 483 deletions
705
dist/bundle.js
vendored
705
dist/bundle.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -131,4 +131,5 @@ export {
|
||||||
selectUserInviteStatusFailed,
|
selectUserInviteStatusFailed,
|
||||||
selectUserInviteNewIsPending,
|
selectUserInviteNewIsPending,
|
||||||
selectUserInviteNewErrorMessage,
|
selectUserInviteNewErrorMessage,
|
||||||
|
selectUserInviteReferralLink,
|
||||||
} from 'redux/selectors/user';
|
} from 'redux/selectors/user';
|
||||||
|
|
|
@ -5,12 +5,12 @@ import querystring from 'querystring';
|
||||||
const Lbryio = {
|
const Lbryio = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
authenticationPromise: null,
|
authenticationPromise: null,
|
||||||
|
CONNECTION_STRING: 'https://api.lbry.io/',
|
||||||
};
|
};
|
||||||
|
|
||||||
// We can't use env's because they aren't passed into node_modules
|
// We can't use env's because they aren't passed into node_modules
|
||||||
let CONNECTION_STRING = 'https://api.lbry.io/';
|
|
||||||
Lbryio.setLocalApi = endpoint => {
|
Lbryio.setLocalApi = endpoint => {
|
||||||
CONNECTION_STRING = endpoint.replace(/\/*$/, '/'); // exactly one slash at the end;
|
Lbryio.CONNECTION_STRING = endpoint.replace(/\/*$/, '/'); // exactly one slash at the end;
|
||||||
};
|
};
|
||||||
|
|
||||||
Lbryio.call = (resource, action, params = {}, method = 'get') => {
|
Lbryio.call = (resource, action, params = {}, method = 'get') => {
|
||||||
|
@ -45,7 +45,7 @@ Lbryio.call = (resource, action, params = {}, method = 'get') => {
|
||||||
return Lbryio.getAuthToken().then(token => {
|
return Lbryio.getAuthToken().then(token => {
|
||||||
const fullParams = { auth_token: token, ...params };
|
const fullParams = { auth_token: token, ...params };
|
||||||
const qs = querystring.stringify(fullParams);
|
const qs = querystring.stringify(fullParams);
|
||||||
let url = `${CONNECTION_STRING}${resource}/${action}?${qs}`;
|
let url = `${Lbryio.CONNECTION_STRING}${resource}/${action}?${qs}`;
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -59,7 +59,7 @@ Lbryio.call = (resource, action, params = {}, method = 'get') => {
|
||||||
},
|
},
|
||||||
body: qs,
|
body: qs,
|
||||||
};
|
};
|
||||||
url = `${CONNECTION_STRING}${resource}/${action}`;
|
url = `${Lbryio.CONNECTION_STRING}${resource}/${action}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeRequest(url, options).then(response => response.data);
|
return makeRequest(url, options).then(response => response.data);
|
||||||
|
@ -174,7 +174,7 @@ Lbryio.authenticate = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
Lbryio.getStripeToken = () =>
|
Lbryio.getStripeToken = () =>
|
||||||
CONNECTION_STRING.startsWith('http://localhost:')
|
Lbryio.CONNECTION_STRING.startsWith('http://localhost:')
|
||||||
? 'pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
|
? 'pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
|
||||||
: 'pk_live_e8M4dRNnCCbmpZzduEUZBgJO';
|
: 'pk_live_e8M4dRNnCCbmpZzduEUZBgJO';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
} from 'redux/selectors/user';
|
} from 'redux/selectors/user';
|
||||||
import rewards from 'rewards';
|
import rewards from 'rewards';
|
||||||
import Lbryio from 'lbryio';
|
import Lbryio from 'lbryio';
|
||||||
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
export function doFetchInviteStatus() {
|
export function doFetchInviteStatus() {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
|
@ -14,8 +15,8 @@ export function doFetchInviteStatus() {
|
||||||
type: ACTIONS.USER_INVITE_STATUS_FETCH_STARTED,
|
type: ACTIONS.USER_INVITE_STATUS_FETCH_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbryio.call('user', 'invite_status')
|
Promise.all([Lbryio.call('user', 'invite_status'), Lbryio.call('user_referral_code', 'list')])
|
||||||
.then(status => {
|
.then(([status, code]) => {
|
||||||
dispatch(doRewardList());
|
dispatch(doRewardList());
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -23,6 +24,7 @@ export function doFetchInviteStatus() {
|
||||||
data: {
|
data: {
|
||||||
invitesRemaining: status.invites_remaining ? status.invites_remaining : 0,
|
invitesRemaining: status.invites_remaining ? status.invites_remaining : 0,
|
||||||
invitees: status.invitees,
|
invitees: status.invitees,
|
||||||
|
referralLink: `${Lbryio.CONNECTION_STRING}user/refer?r=${code}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -193,6 +193,7 @@ reducers[ACTIONS.USER_INVITE_STATUS_FETCH_SUCCESS] = (state, action) =>
|
||||||
inviteStatusIsPending: false,
|
inviteStatusIsPending: false,
|
||||||
invitesRemaining: action.data.invitesRemaining,
|
invitesRemaining: action.data.invitesRemaining,
|
||||||
invitees: action.data.invitees,
|
invitees: action.data.invitees,
|
||||||
|
referralLink: action.data.referralLink,
|
||||||
});
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.USER_INVITE_NEW_STARTED] = state =>
|
reducers[ACTIONS.USER_INVITE_NEW_STARTED] = state =>
|
||||||
|
|
|
@ -126,3 +126,8 @@ export const selectUserInviteNewErrorMessage = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.inviteNewErrorMessage
|
state => state.inviteNewErrorMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectUserInviteReferralLink = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.referralLink
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in a new issue