Merge branch 'master' of github.com:lbryio/lbry-app

This commit is contained in:
Jeremy Kauffman 2017-06-18 10:34:54 -04:00
commit eb3f1086a2
10 changed files with 53 additions and 36 deletions

View file

@ -243,3 +243,11 @@ export function doRemoveSnackBarSnack() {
type: types.REMOVE_SNACKBAR_SNACK,
};
}
export function doClearCache() {
return function(dispatch, getState) {
window.cacheStore.purge();
return Promise.resolve();
};
}

View file

@ -44,16 +44,6 @@ export function doResolveUri(uri) {
};
}
export function doCancelResolveUri(uri) {
return function(dispatch, getState) {
lbry.cancelResolve({ uri });
dispatch({
type: types.RESOLVE_URI_CANCELED,
data: { uri },
});
};
}
export function doFetchFeaturedUris() {
return function(dispatch, getState) {
const state = getState();

View file

@ -1,7 +1,7 @@
import React from "react";
import { connect } from "react-redux";
import { doNavigate } from "actions/app";
import { doResolveUri, doCancelResolveUri } from "actions/content";
import { doResolveUri } from "actions/content";
import { selectObscureNsfw } from "selectors/app";
import {
makeSelectClaimForUri,
@ -31,7 +31,6 @@ const makeSelect = () => {
const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: uri => dispatch(doResolveUri(uri)),
cancelResolveUri: uri => dispatch(doCancelResolveUri(uri)),
});
export default connect(makeSelect, perform)(FileCard);

View file

@ -23,14 +23,6 @@ class FileCard extends React.PureComponent {
}
}
componentWillUnmount() {
const { isResolvingUri, cancelResolveUri, uri } = this.props;
if (isResolvingUri) {
cancelResolveUri(uri);
}
}
handleMouseOver() {
this.setState({
hovered: true,
@ -47,13 +39,11 @@ class FileCard extends React.PureComponent {
const { claim, fileInfo, metadata, isResolvingUri, navigate } = this.props;
const uri = lbryuri.normalize(this.props.uri);
const title = !isResolvingUri && metadata && metadata.title
? metadata.title
: uri;
const title = metadata && metadata.title ? metadata.title : uri;
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
let description = "";
if (isResolvingUri) {
if (isResolvingUri && !claim) {
description = __("Loading...");
} else if (metadata && metadata.description) {
description = metadata.description;

View file

@ -21,7 +21,7 @@ class UriIndicator extends React.PureComponent {
render() {
const { claim, uri, isResolvingUri } = this.props;
if (isResolvingUri) {
if (isResolvingUri && !claim) {
return <span className="empty">Validating...</span>;
}

View file

@ -39,7 +39,6 @@ export const FETCH_FEATURED_CONTENT_COMPLETED =
"FETCH_FEATURED_CONTENT_COMPLETED";
export const RESOLVE_URI_STARTED = "RESOLVE_URI_STARTED";
export const RESOLVE_URI_COMPLETED = "RESOLVE_URI_COMPLETED";
export const RESOLVE_URI_CANCELED = "RESOLVE_URI_CANCELED";
export const FETCH_CHANNEL_CLAIMS_STARTED = "FETCH_CHANNEL_CLAIMS_STARTED";
export const FETCH_CHANNEL_CLAIMS_COMPLETED = "FETCH_CHANNEL_CLAIMS_COMPLETED";
export const FETCH_CLAIM_LIST_MINE_STARTED = "FETCH_CLAIM_LIST_MINE_STARTED";

View file

@ -1,5 +1,6 @@
import React from "react";
import { connect } from "react-redux";
import { doClearCache } from "actions/app";
import { doSetDaemonSetting } from "actions/settings";
import { selectDaemonSettings } from "selectors/settings";
import SettingsPage from "./view";
@ -10,6 +11,7 @@ const select = state => ({
const perform = dispatch => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearCache: () => dispatch(doClearCache()),
});
export default connect(select, perform)(SettingsPage);

View file

@ -2,6 +2,9 @@ import React from "react";
import { FormField, FormRow } from "component/form.js";
import SubHeader from "component/subHeader";
import lbry from "lbry.js";
import Link from "component/link";
const { remote } = require("electron");
class SettingsPage extends React.PureComponent {
constructor(props) {
@ -15,9 +18,23 @@ class SettingsPage extends React.PureComponent {
showNsfw: lbry.getClientSetting("showNsfw"),
showUnavailable: lbry.getClientSetting("showUnavailable"),
language: lbry.getClientSetting("language"),
clearingCache: false,
};
}
clearCache() {
this.setState({
clearingCache: true,
});
const success = () => {
this.setState({ clearingCache: false });
window.location.href = `${remote.app.getAppPath()}/dist/index.html`;
};
const clear = () => this.props.clearCache().then(success.bind(this));
setTimeout(clear, 1000, { once: true });
}
setDaemonSetting(name, value) {
this.props.setDaemonSetting(name, value);
}
@ -274,6 +291,27 @@ class SettingsPage extends React.PureComponent {
/>
</div>
</section>
<section className="card">
<div className="card__content">
<h3>{__("Application Cache")}</h3>
</div>
<div className="card__content">
<p>
<Link
label={
this.state.clearingCache
? __("Clearing")
: __("Clear the cache")
}
icon="icon-trash"
button="alt"
onClick={this.clearCache.bind(this)}
disabled={this.state.clearingCache}
/>
</p>
</div>
</section>
</main>
);
}

View file

@ -26,15 +26,6 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
});
};
reducers[types.RESOLVE_URI_CANCELED] = function(state, action) {
const uri = action.data.uri;
const newClaims = Object.assign({}, state.claimsByUri);
delete newClaims[uri];
return Object.assign({}, state, {
claimsByUri: newClaims,
});
};
reducers[types.FETCH_CLAIM_LIST_MINE_STARTED] = function(state, action) {
return Object.assign({}, state, {
isClaimListMinePending: true,

View file

@ -100,6 +100,6 @@ const persistOptions = {
debounce: 1000,
storage: localForage,
};
persistStore(reduxStore, persistOptions);
window.cacheStore = persistStore(reduxStore, persistOptions);
export default reduxStore;