diff --git a/LICENSE b/LICENSE index a293e51..eb958df 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017-2020 LBRY Inc +Copyright (c) 2017-2019 LBRY Inc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/src/component/mediaPlayer/view.js b/src/component/mediaPlayer/view.js index e9e0acf..53af706 100644 --- a/src/component/mediaPlayer/view.js +++ b/src/component/mediaPlayer/view.js @@ -167,7 +167,7 @@ class MediaPlayer extends React.PureComponent { togglePlay = () => { this.showPlayerControls(); - this.setState({ paused: !this.state.paused }, this.updateBackgroundMediaNotification); + this.setState({ paused: !this.state.paused }, this.handlePausedState); }; handlePausedState = () => { @@ -188,7 +188,7 @@ class MediaPlayer extends React.PureComponent { }; onEnd = () => { - this.setState({ paused: true }, this.updateBackgroundMediaNotification); + this.setState({ paused: true }); if (this.props.onPlaybackFinished) { this.props.onPlaybackFinished(); } @@ -327,10 +327,6 @@ class MediaPlayer extends React.PureComponent { } }; - onFocusChanged = evt => { - this.setState({ paused: !(this.state.paused && evt.hasAudioFocus) }, this.updateBackgroundMediaNotification); - }; - onBuffer = () => { if (!this.state.paused) { this.setState({ buffering: true }, () => this.manualHidePlayerControls()); @@ -473,7 +469,6 @@ class MediaPlayer extends React.PureComponent { onEnd={this.onEnd} onError={this.onError} minLoadRetryCount={999} - onAudioFocusChanged={this.onFocusChanged} /> {this.state.firstPlay && thumbnail && ( diff --git a/src/page/invites/view.js b/src/page/invites/view.js index efdf761..098d1f4 100644 --- a/src/page/invites/view.js +++ b/src/page/invites/view.js @@ -21,6 +21,7 @@ import RewardCard from 'component/rewardCard'; import RewardEnrolment from 'component/rewardEnrolment'; import UriBar from 'component/uriBar'; import invitesStyle from 'styles/invites'; +import { fetchReferralCode, logPublish } from 'utils/helper'; class InvitesPage extends React.PureComponent { state = { @@ -47,7 +48,19 @@ class InvitesPage extends React.PureComponent { pushDrawerStack(); setPlayerVisible(); NativeModules.Firebase.setCurrentScreen('Invites').then(result => { - fetchChannelListMine(); + 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(); }); }; @@ -62,6 +75,7 @@ class InvitesPage extends React.PureComponent { const filtered = channels.filter(c => c.name === channelName); if (filtered.length > 0) { const channel = filtered[0]; + logPublish(channel); this.setState({ channelName, inviteLink: this.getLinkForChannel(channel) }); } } @@ -96,6 +110,7 @@ class InvitesPage extends React.PureComponent { if (!this.state.channelName && channels && channels.length > 0) { const firstChannel = channels[0]; + logPublish(firstChannel); this.setState({ channelName: firstChannel.name, inviteLink: this.getLinkForChannel(firstChannel) }); } diff --git a/src/utils/helper.js b/src/utils/helper.js index 49e2f62..71b7193 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -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); + } + }); +}