commit
7f0db55879
8 changed files with 112 additions and 38 deletions
|
@ -50,7 +50,7 @@
|
|||
"hast-util-sanitize": "^1.1.2",
|
||||
"keytar": "^4.2.1",
|
||||
"lbry-redux": "lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404",
|
||||
"lbryinc": "lbryio/lbryinc#26adc910bf0bbe4cd24bc7c195a5aa88b1a69a9f",
|
||||
"lbryinc": "lbryio/lbryinc#68c8ce6b7608dabc9180fff9b4841d10e1c62284",
|
||||
"localforage": "^1.7.1",
|
||||
"mammoth": "^1.4.6",
|
||||
"mime": "^2.3.1",
|
||||
|
|
|
@ -64,7 +64,8 @@ if (isDev) {
|
|||
}
|
||||
|
||||
app.on('ready', async () => {
|
||||
const processListArgs = process.platform === 'win32' ? 'lbrynet.exe' : 'lbrynet start';
|
||||
// Windows WMIC returns lbrynet start with 2 spaces. https://github.com/yibn2008/find-process/issues/18
|
||||
const processListArgs = process.platform === 'win32' ? 'lbrynet start' : 'lbrynet start';
|
||||
const processList = await findProcess('name', processListArgs);
|
||||
|
||||
const isDaemonRunning = processList.length > 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @flow
|
||||
import * as React from 'react';
|
||||
import React, { PureComponent } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { DARK_THEME, LIGHT_THEME } from 'constants/themes';
|
||||
|
||||
|
@ -8,32 +8,78 @@ type Props = {
|
|||
light?: boolean, // always a light spinner
|
||||
theme: string,
|
||||
type: ?string,
|
||||
delayed: boolean,
|
||||
};
|
||||
|
||||
const Spinner = (props: Props) => {
|
||||
const { dark, light, theme, type } = props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('spinner', {
|
||||
'spinner--dark': !light && (dark || theme === LIGHT_THEME),
|
||||
'spinner--light': !dark && (light || theme === DARK_THEME),
|
||||
'spinner--splash': type === 'splash',
|
||||
'spinner--small': type === 'small',
|
||||
})}
|
||||
>
|
||||
<div className="rect rect1" />
|
||||
<div className="rect rect2" />
|
||||
<div className="rect rect3" />
|
||||
<div className="rect rect4" />
|
||||
<div className="rect rect5" />
|
||||
</div>
|
||||
);
|
||||
type State = {
|
||||
show: boolean,
|
||||
};
|
||||
|
||||
Spinner.defaultProps = {
|
||||
dark: false,
|
||||
light: false,
|
||||
};
|
||||
class Spinner extends PureComponent<Props, State> {
|
||||
static defaultProps = {
|
||||
// We may want a dark/light spinner regardless of the current theme
|
||||
dark: false,
|
||||
light: false,
|
||||
delayed: false,
|
||||
};
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.state = { show: false };
|
||||
this.delayedTimeout = null;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { delayed } = this.props;
|
||||
if (!delayed) {
|
||||
// We can disable this because the default state is to render nothing so there won't be any content thrashing
|
||||
// eslint-disable-next-line react/no-did-mount-set-state
|
||||
this.setState({ show: true });
|
||||
} else {
|
||||
// If the delayed prop is passed in, wait some time before showing the loading indicator
|
||||
// We don't want the spinner to just flash for a fraction of a second
|
||||
this.delayedTimeout = setTimeout(() => {
|
||||
// eslint-disable-next-line react/no-did-mount-set-state
|
||||
this.setState({ show: true });
|
||||
}, 750);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.delayedTimeout) {
|
||||
clearTimeout(this.delayedTimeout);
|
||||
this.delayedTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
delayedTimeout: ?TimeoutID;
|
||||
|
||||
render() {
|
||||
const { dark, light, theme, type } = this.props;
|
||||
const { show } = this.state;
|
||||
|
||||
if (!show) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('spinner', {
|
||||
'spinner--dark': !light && (dark || theme === LIGHT_THEME),
|
||||
'spinner--light': !dark && (light || theme === DARK_THEME),
|
||||
'spinner--splash': type === 'splash',
|
||||
'spinner--small': type === 'small',
|
||||
})}
|
||||
>
|
||||
<div className="rect rect1" />
|
||||
<div className="rect rect2" />
|
||||
<div className="rect rect3" />
|
||||
<div className="rect rect4" />
|
||||
<div className="rect rect5" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Spinner;
|
||||
|
|
|
@ -52,7 +52,12 @@ export class SplashScreen extends React.PureComponent<Props, State> {
|
|||
|
||||
this.adjustErrorTimeout();
|
||||
Lbry.connect()
|
||||
.then(checkDaemonVersion)
|
||||
.then(() => {
|
||||
this.setState({
|
||||
isRunning: true,
|
||||
});
|
||||
checkDaemonVersion();
|
||||
})
|
||||
.then(() => {
|
||||
this.updateStatus();
|
||||
})
|
||||
|
@ -89,9 +94,12 @@ export class SplashScreen extends React.PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
updateStatus() {
|
||||
Lbry.status().then(status => {
|
||||
this.updateStatusCallback(status);
|
||||
});
|
||||
const { daemonVersionMatched } = this.props;
|
||||
if (daemonVersionMatched) {
|
||||
Lbry.status().then(status => {
|
||||
this.updateStatusCallback(status);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updateStatusCallback(status: Status) {
|
||||
|
@ -114,14 +122,19 @@ export class SplashScreen extends React.PureComponent<Props, State> {
|
|||
|
||||
// If the wallet is locked, stop doing anything and make the user input their password
|
||||
if (wallet && wallet.is_locked) {
|
||||
this.setState({
|
||||
isRunning: true,
|
||||
});
|
||||
// Clear the error timeout, it might sit on this step for a while until someone enters their password
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
|
||||
if (launchedModal === false) {
|
||||
this.setState({ launchedModal: true }, () => notifyUnlockWallet());
|
||||
}
|
||||
} else if (status.is_running) {
|
||||
// If we cleared the error timout due to a wallet being locked, make sure to start it back up
|
||||
if (!this.timeout) {
|
||||
this.adjustErrorTimeout();
|
||||
}
|
||||
// Wait until we are able to resolve a name before declaring
|
||||
// that we are done.
|
||||
// TODO: This is a hack, and the logic should live in the daemon
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { selectSuggestedChannels } from 'redux/selectors/subscriptions';
|
||||
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'redux/selectors/subscriptions';
|
||||
import SuggestedSubscriptions from './view';
|
||||
|
||||
const select = state => ({
|
||||
suggested: selectSuggestedChannels(state),
|
||||
loading: selectIsFetchingSuggested(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
// @flow
|
||||
import React, { PureComponent } from 'react';
|
||||
import CategoryList from 'component/categoryList';
|
||||
import Spinner from 'component/spinner';
|
||||
|
||||
type Props = {
|
||||
suggested: Array<{ label: string, uri: string }>,
|
||||
loading: boolean,
|
||||
};
|
||||
|
||||
class SuggestedSubscriptions extends PureComponent<Props> {
|
||||
render() {
|
||||
const { suggested } = this.props;
|
||||
const { suggested, loading } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="page__empty">
|
||||
<Spinner delayed />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return suggested ? (
|
||||
<div className="card__content subscriptions__suggested">
|
||||
|
|
|
@ -24,7 +24,10 @@ export const selectViewMode = createSelector(selectState, state => state.viewMod
|
|||
|
||||
// Suggested subscriptions from internal apis
|
||||
export const selectSuggested = createSelector(selectState, state => state.suggested);
|
||||
export const selectLoadingSuggested = createSelector(selectState, state => state.loadingSuggested);
|
||||
export const selectIsFetchingSuggested = createSelector(
|
||||
selectState,
|
||||
state => state.loadingSuggested
|
||||
);
|
||||
export const selectSuggestedChannels = createSelector(
|
||||
selectSubscriptions,
|
||||
selectSuggested,
|
||||
|
|
|
@ -5671,9 +5671,9 @@ lbry-redux@lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404:
|
|||
reselect "^3.0.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
lbryinc@lbryio/lbryinc#26adc910bf0bbe4cd24bc7c195a5aa88b1a69a9f:
|
||||
lbryinc@lbryio/lbryinc#68c8ce6b7608dabc9180fff9b4841d10e1c62284:
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/26adc910bf0bbe4cd24bc7c195a5aa88b1a69a9f"
|
||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/68c8ce6b7608dabc9180fff9b4841d10e1c62284"
|
||||
dependencies:
|
||||
lbry-redux lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404
|
||||
reselect "^3.0.0"
|
||||
|
|
Loading…
Add table
Reference in a new issue