generate default invite link if no channels are present
This commit is contained in:
parent
81bdd37576
commit
f81e2d7441
2 changed files with 28 additions and 2 deletions
|
@ -21,7 +21,7 @@ import RewardCard from 'component/rewardCard';
|
|||
import RewardEnrolment from 'component/rewardEnrolment';
|
||||
import UriBar from 'component/uriBar';
|
||||
import invitesStyle from 'styles/invites';
|
||||
import { logPublish } from 'utils/helper';
|
||||
import { fetchReferralCode, logPublish } from 'utils/helper';
|
||||
|
||||
class InvitesPage extends React.PureComponent {
|
||||
state = {
|
||||
|
@ -48,7 +48,19 @@ class InvitesPage extends React.PureComponent {
|
|||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
NativeModules.Firebase.setCurrentScreen('Invites').then(result => {
|
||||
fetchReferralCode(
|
||||
response => {
|
||||
if (response && response.length > 0) {
|
||||
// only need to use the first referral code.
|
||||
// inviteLink will be updated after channels are loaded (if the user has created at least one channel)
|
||||
this.setState({ inviteLink: `https://lbry.tv/$/invite/${response[0]}` });
|
||||
}
|
||||
fetchChannelListMine();
|
||||
},
|
||||
error => {
|
||||
fetchChannelListMine();
|
||||
},
|
||||
);
|
||||
fetchInviteStatus();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -400,3 +400,17 @@ export function formatTitle(title) {
|
|||
|
||||
return title.length > 80 ? title.substring(0, 77).trim() + '...' : title;
|
||||
}
|
||||
|
||||
export function fetchReferralCode(successCallback, errorCallback) {
|
||||
Lbryio.call('user_referral_code', 'list')
|
||||
.then(response => {
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (errorCallback) {
|
||||
errorCallback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue