Compare commits

...

3 commits

Author SHA1 Message Date
Akinwale Ariwodola
8ae6b88410 fix downloads. file page tweaks. 2019-12-28 10:59:30 +01:00
Akinwale Ariwodola
a32c7f32f8 download button tweaks 2019-12-28 01:12:07 +01:00
Akinwale Ariwodola
c1f73c2766 streamlined first run 2019-12-28 00:46:11 +01:00
10 changed files with 597 additions and 554 deletions

View file

@ -51,6 +51,7 @@ import {
selectHashChanged, selectHashChanged,
selectUser, selectUser,
} from 'lbryinc'; } from 'lbryinc';
import { doStartDownload, doUpdateDownload, doCompleteDownload } from 'redux/actions/file';
import { makeSelectClientSetting, selectFullscreenMode } from 'redux/selectors/settings'; import { makeSelectClientSetting, selectFullscreenMode } from 'redux/selectors/settings';
import { decode as atob } from 'base-64'; import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper'; import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
@ -311,6 +312,10 @@ class AppWithNavigationState extends React.Component {
this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000); this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000);
Linking.addEventListener('url', this._handleUrl); Linking.addEventListener('url', this._handleUrl);
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted);
// call /sync/get with interval // call /sync/get with interval
this.syncGetInterval = setInterval(() => { this.syncGetInterval = setInterval(() => {
this.setState({ syncHashChanged: false }); // reset local state this.setState({ syncHashChanged: false }); // reset local state
@ -345,7 +350,29 @@ class AppWithNavigationState extends React.Component {
); );
}; };
handleDownloadStarted = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo } = evt;
dispatch(doStartDownload(uri, outpoint, fileInfo));
};
handleDownloadUpdated = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo, progress } = evt;
dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress));
};
handleDownloadCompleted = evt => {
const { dispatch } = this.props;
const { uri, outpoint, fileInfo } = evt;
dispatch(doCompleteDownload(uri, outpoint, fileInfo));
};
componentWillUnmount() { componentWillUnmount() {
DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.removeListener('onDownloadCompleted', this.handleDownloadCompleted);
AppState.removeEventListener('change', this._handleAppStateChange); AppState.removeEventListener('change', this._handleAppStateChange);
BackHandler.removeEventListener('hardwareBackPress'); BackHandler.removeEventListener('hardwareBackPress');
Linking.removeEventListener('url', this._handleUrl); Linking.removeEventListener('url', this._handleUrl);

View file

@ -11,11 +11,6 @@ class FileDownloadButton extends React.PureComponent {
} }
} }
componentWillReceiveProps(nextProps) {
// this.checkAvailability(nextProps.uri);
// this.restartDownload(nextProps);
}
restartDownload(props) { restartDownload(props) {
const { downloading, fileInfo, uri, restartDownload } = props; const { downloading, fileInfo, uri, restartDownload } = props;
@ -45,6 +40,7 @@ class FileDownloadButton extends React.PureComponent {
doPause, doPause,
style, style,
openFile, openFile,
onFileActionPress,
onButtonLayout, onButtonLayout,
} = this.props; } = this.props;
@ -72,19 +68,7 @@ class FileDownloadButton extends React.PureComponent {
text={isPlayable ? __('Play') : isViewable ? __('View') : __('Download')} text={isPlayable ? __('Play') : isViewable ? __('View') : __('Download')}
onLayout={onButtonLayout} onLayout={onButtonLayout}
style={[style, fileDownloadButtonStyle.container]} style={[style, fileDownloadButtonStyle.container]}
onPress={() => { onPress={onFileActionPress}
NativeModules.Firebase.track('purchase_uri', { uri: uri });
purchaseUri(uri, costInfo, !isPlayable);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.checkDownloads();
}
if (isPlayable && onPlay) {
this.props.onPlay();
}
if (isViewable && onView) {
this.props.onView();
}
}}
/> />
); );
} else if (fileInfo && fileInfo.download_path) { } else if (fileInfo && fileInfo.download_path) {

View file

@ -158,7 +158,13 @@ class FileListItem extends React.PureComponent {
</View> </View>
)} )}
{fileInfo && fileInfo.completed && fileInfo.download_path && ( {fileInfo && fileInfo.completed && fileInfo.download_path && (
<Icon style={fileListStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} /> <Icon
style={featuredResult ? fileListStyle.featuredDownloadedIcon : fileListStyle.downloadedIcon}
solid
color={Colors.NextLbryGreen}
name={'folder'}
size={16}
/>
)} )}
<View style={fileListStyle.detailsContainer}> <View style={fileListStyle.detailsContainer}>
{featuredResult && ( {featuredResult && (

View file

@ -8,18 +8,11 @@ import fileListStyle from 'styles/fileList';
import relatedContentStyle from 'styles/relatedContent'; import relatedContentStyle from 'styles/relatedContent';
export default class RelatedContent extends React.PureComponent { export default class RelatedContent extends React.PureComponent {
state = { componentDidMount() {
urlsResolved: false,
};
componentDidUpdate(prevProps) {
const { resolveUris, recommendedContent } = this.props; const { resolveUris, recommendedContent } = this.props;
if (recommendedContent && recommendedContent.length > 0) {
if (recommendedContent && recommendedContent.length > 0 && !this.state.urisResolved) { // batch resolve the uris
this.setState({ urisResolved: true }, () => { resolveUris(recommendedContent);
// batch resolve the uris
resolveUris(recommendedContent);
});
} }
} }

View file

@ -52,8 +52,9 @@ function checkMessageAndSave(message, messagesFilePath) {
); */ ); */
}) })
.catch(err => { .catch(err => {
if (err) { if (err && !isProduction) {
throw err; // only do this when not in production
console.error(err);
} }
}); });
} }

View file

@ -57,7 +57,7 @@ window.__ = __;
const globalExceptionHandler = (error, isFatal) => { const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) { if (error && NativeModules.Firebase) {
NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
} }
}; };
setJSExceptionHandler(globalExceptionHandler, true); setJSExceptionHandler(globalExceptionHandler, true);

View file

@ -8,6 +8,7 @@ import {
doPurchaseUri, doPurchaseUri,
doDeletePurchasedUri, doDeletePurchasedUri,
doResolveUri, doResolveUri,
doResolveUris,
doSearch, doSearch,
doSendTip, doSendTip,
doToast, doToast,
@ -28,6 +29,7 @@ import {
selectPurchasedUris, selectPurchasedUris,
selectFailedPurchaseUris, selectFailedPurchaseUris,
selectPurchaseUriErrorMessage, selectPurchaseUriErrorMessage,
selectResolvingUris,
selectIsSearching, selectIsSearching,
} from 'lbry-redux'; } from 'lbry-redux';
import { import {
@ -39,13 +41,7 @@ import {
selectRewardContentClaimIds, selectRewardContentClaimIds,
selectBlackListedOutpoints, selectBlackListedOutpoints,
} from 'lbryinc'; } from 'lbryinc';
import { import { doDeleteFile, doStopDownloadingFile } from 'redux/actions/file';
doStartDownload,
doUpdateDownload,
doCompleteDownload,
doDeleteFile,
doStopDownloadingFile,
} from 'redux/actions/file';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer'; import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doToggleFullscreenMode } from 'redux/actions/settings'; import { doToggleFullscreenMode } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer'; import { selectDrawerStack } from 'redux/selectors/drawer';
@ -77,6 +73,7 @@ const select = (state, props) => {
thumbnail: makeSelectThumbnailForUri(contentUri)(state), thumbnail: makeSelectThumbnailForUri(contentUri)(state),
title: makeSelectTitleForUri(contentUri)(state), title: makeSelectTitleForUri(contentUri)(state),
recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state), recommendedContent: makeSelectRecommendedContentForUri(contentUri)(state),
resolvingUris: selectResolvingUris(state),
isSearchingRecommendContent: selectIsSearching(state), isSearchingRecommendContent: selectIsSearching(state),
viewCount: makeSelectViewCountForUri(contentUri)(state), viewCount: makeSelectViewCountForUri(contentUri)(state),
}; };
@ -100,14 +97,12 @@ const perform = dispatch => ({
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)), purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)), deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)),
resolveUri: uri => dispatch(doResolveUri(uri)), resolveUri: uri => dispatch(doResolveUri(uri)),
resolveUris: uris => dispatch(doResolveUris(uris)),
searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)), searchRecommended: query => dispatch(doSearch(query, 20, undefined, true)),
sendTip: (amount, claimId, isSupport, successCallback, errorCallback) => sendTip: (amount, claimId, isSupport, successCallback, errorCallback) =>
dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)), dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)), setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)), stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)),
startDownload: (uri, outpoint, fileInfo) => dispatch(doStartDownload(uri, outpoint, fileInfo)),
updateDownload: (uri, outpoint, fileInfo, progress) => dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress)),
completeDownload: (uri, outpoint, fileInfo) => dispatch(doCompleteDownload(uri, outpoint, fileInfo)),
toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)), toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)),
}); });

File diff suppressed because it is too large Load diff

View file

@ -228,7 +228,13 @@ class FirstRunScreen extends React.PureComponent {
handleContinuePressed = () => { handleContinuePressed = () => {
const { notify, user, hasSyncedWallet } = this.props; const { notify, user, hasSyncedWallet } = this.props;
const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage); const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage);
if (Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage) {
if (Constants.FIRST_RUN_PAGE_WELCOME === this.state.currentPage) {
// only show the welcome screen on first run
this.closeFinalPage();
}
/* if (Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage) {
// do apply sync to check if the password is valid // do apply sync to check if the password is valid
if (hasSyncedWallet) { if (hasSyncedWallet) {
this.checkWalletPassword(); this.checkWalletPassword();
@ -256,7 +262,7 @@ class FirstRunScreen extends React.PureComponent {
} else { } else {
this.showNextPage(); this.showNextPage();
} }
} } */
}; };
handleEmailCollectPageContinue() { handleEmailCollectPageContinue() {
@ -500,7 +506,12 @@ class FirstRunScreen extends React.PureComponent {
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage && {Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage &&
Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && ( Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && (
<Text style={firstRunStyle.buttonText}> <Text style={firstRunStyle.buttonText}>
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? __('Use LBRY') : __('Continue')} » {[Constants.FIRST_RUN_PAGE_WALLET, Constants.FIRST_RUN_PAGE_WELCOME].includes(
this.state.currentPage
)
? __('Use LBRY')
: __('Continue')}{' '}
»
</Text> </Text>
)} )}
</TouchableOpacity> </TouchableOpacity>

View file

@ -94,6 +94,11 @@ const fileListStyle = StyleSheet.create({
top: 8, top: 8,
left: 8, left: 8,
}, },
featuredDownloadedIcon: {
position: 'absolute',
left: 16,
top: 16,
},
fileItem: { fileItem: {
marginLeft: 24, marginLeft: 24,
marginRight: 24, marginRight: 24,