Unverified Commit 12d7fbd4 authored by Akinwale Ariwodola's avatar Akinwale Ariwodola Committed by GitHub
Browse files

lbry.tv hybrid mode (#132)

* use lbry.tv for resolve and claim_search
* gracefully handle dynamic sdk ready state
* update pinned lbry-redux commit
* use empty state view when sdk is not ready
* traditional mode if dht is enabled
parent 4645a8f4
......@@ -3,11 +3,12 @@ import { selectFollowedTags, doToggleTagFollow } from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import { selectSdkReady, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import TagPage from './view';
const select = state => ({
currentRoute: selectCurrentRoute(state),
sdkReady: selectSdkReady(state),
sortByItem: selectSortByItem(state),
timeItem: selectTimeItem(state),
followedTags: selectFollowedTags(state),
......@@ -21,7 +22,4 @@ const perform = dispatch => ({
toggleTagFollow: tag => dispatch(doToggleTagFollow(tag)),
});
export default connect(
select,
perform
)(TagPage);
export default connect(select, perform)(TagPage);
......@@ -14,6 +14,7 @@ import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import FloatingWalletBalance from 'component/floatingWalletBalance';
import Link from 'component/link';
import ModalPicker from 'component/modalPicker';
import SdkLoadingStatus from 'component/sdkLoadingStatus';
import UriBar from 'component/uriBar';
class TagPage extends React.PureComponent {
......@@ -127,7 +128,7 @@ class TagPage extends React.PureComponent {
};
render() {
const { navigation, sortByItem, timeItem } = this.props;
const { navigation, sdkReady, sortByItem, timeItem } = this.props;
const { tag, showSortPicker, showTimePicker } = this.state;
return (
......@@ -144,7 +145,7 @@ class TagPage extends React.PureComponent {
orientation={Constants.ORIENTATION_VERTICAL}
/>
)}
{!showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
{sdkReady && !showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
{showSortPicker && (
<ModalPicker
title={__('Sort content by')}
......@@ -163,6 +164,7 @@ class TagPage extends React.PureComponent {
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
{!sdkReady && <SdkLoadingStatus />}
</View>
);
}
......
import { connect } from 'react-redux';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectSdkReady } from 'redux/selectors/settings';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import { selectBalance } from 'lbry-redux';
......@@ -15,6 +15,7 @@ const select = state => ({
deviceWalletSynced: makeSelectClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED)(state),
hasSyncedWallet: selectHasSyncedWallet(state),
rewardsNotInterested: makeSelectClientSetting(Constants.SETTING_REWARDS_NOT_INTERESTED)(state),
sdkReady: selectSdkReady(state),
understandsRisks: makeSelectClientSetting(Constants.SETTING_ALPHA_UNDERSTANDS_RISKS)(state),
user: selectUser(state),
});
......@@ -27,7 +28,4 @@ const perform = dispatch => ({
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
});
export default connect(
select,
perform
)(WalletPage);
export default connect(select, perform)(WalletPage);
import React from 'react';
import { NativeModules, ScrollView, Text, View } from 'react-native';
import EmptyStateView from 'component/emptyStateView';
import TransactionListRecent from 'component/transactionListRecent';
import WalletAddress from 'component/walletAddress';
import WalletBalance from 'component/walletBalance';
......@@ -8,8 +9,6 @@ import WalletSend from 'component/walletSend';
import WalletRewardsDriver from 'component/walletRewardsDriver';
import WalletSignIn from 'component/walletSignIn';
import WalletSyncDriver from 'component/walletSyncDriver';
import Button from 'component/button';
import Link from 'component/link';
import UriBar from 'component/uriBar';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import walletStyle from 'styles/wallet';
......@@ -60,16 +59,20 @@ class WalletPage extends React.PureComponent {
};
render() {
const {
balance,
backupDismissed,
hasSyncedWallet,
rewardsNotInterested,
understandsRisks,
setClientSetting,
navigation,
user,
} = this.props;
const { balance, rewardsNotInterested, understandsRisks, navigation, sdkReady, user } = this.props;
if (!sdkReady) {
return (
<View style={walletStyle.container}>
<UriBar navigation={navigation} />
<EmptyStateView
message={__(
'The background service is still initializing. You can still explore and watch content during the initialization process.',
)}
/>
</View>
);
}
const signedIn = user && user.has_verified_email;
if (!signedIn && !understandsRisks) {
......
......@@ -17,6 +17,14 @@ export function doSetClientSetting(key, value) {
};
}
export function doSetSdkReady() {
return dispatch => {
dispatch({
type: Constants.ACTION_SDK_READY,
});
};
}
export function doSetSortByItem(item) {
return dispatch => {
dispatch({
......
......@@ -4,6 +4,7 @@ import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
const reducers = {};
const defaultState = {
clientSettings: {},
sdkReady: false,
sortByItemName: Constants.SORT_BY_HOT,
timeItemName: Constants.TIME_WEEK,
fullscreenMode: false,
......@@ -20,6 +21,11 @@ reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
});
};
reducers[Constants.ACTION_SDK_READY] = (state, action) =>
Object.assign({}, state, {
sdkReady: true,
});
reducers[Constants.ACTION_SORT_BY_ITEM_CHANGED] = (state, action) =>
Object.assign({}, state, {
sortByItemName: action.data.name,
......
......@@ -4,38 +4,22 @@ import { getSortByItemForName, getTimeItemForName } from 'utils/helper';
const selectState = state => state.settings || {};
export const selectDaemonSettings = createSelector(
selectState,
state => state.daemonSettings
);
export const selectClientSettings = createSelector(
selectState,
state => state.clientSettings || {}
);
export const selectSortByItem = createSelector(
selectState,
state => getSortByItemForName(state.sortByItemName)
);
export const selectTimeItem = createSelector(
selectState,
state => getTimeItemForName(state.timeItemName)
);
export const selectDaemonSettings = createSelector(selectState, state => state.daemonSettings);
export const selectClientSettings = createSelector(selectState, state => state.clientSettings || {});
export const selectSortByItem = createSelector(selectState, state => getSortByItemForName(state.sortByItemName));
export const selectTimeItem = createSelector(selectState, state => getTimeItemForName(state.timeItemName));
export const makeSelectClientSetting = setting =>
createSelector(
selectClientSettings,
settings => (settings ? settings[setting] : undefined)
);
createSelector(selectClientSettings, settings => (settings ? settings[setting] : undefined));
// refactor me
export const selectShowNsfw = makeSelectClientSetting(SETTINGS.SHOW_NSFW);
export const selectKeepDaemonRunning = makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING);
export const selectFullscreenMode = createSelector(
selectState,
state => state.fullscreenMode
);
export const selectFullscreenMode = createSelector(selectState, state => state.fullscreenMode);
export const selectSdkReady = createSelector(selectState, state => state.sdkReady);
......@@ -398,6 +398,23 @@ const discoverStyle = StyleSheet.create({
fontSize: 14,
textAlign: 'center',
},
sdkLoading: {
position: 'absolute',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
bottom: 0,
left: 0,
right: 0,
padding: 8,
backgroundColor: Colors.LbryGreen,
},
sdkLoadingText: {
fontFamily: 'Inter-Regular',
fontSize: 14,
color: Colors.White,
marginLeft: 8,
},
});
export default discoverStyle;
......@@ -4591,17 +4591,17 @@ latest-version@^3.0.0:
dependencies:
package-json "^4.0.0"
lbry-redux@lbryio/lbry-redux#84e697079968364fe526020086c8a44f4d2ef391:
lbry-redux@lbryio/lbry-redux#69ffd110dbf3633e5847f61f008751edec033017:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/84e697079968364fe526020086c8a44f4d2ef391"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/69ffd110dbf3633e5847f61f008751edec033017"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"
uuid "^3.3.2"
lbryinc@lbryio/lbryinc#28afb9b06c3d142bad8347939c043a21b6cb1ae1:
lbryinc@lbryio/lbryinc#021ac75d9aa2db488cfff8e9be320402f038f955:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/28afb9b06c3d142bad8347939c043a21b6cb1ae1"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/021ac75d9aa2db488cfff8e9be320402f038f955"
dependencies:
reselect "^3.0.0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment