From 736ab5581b7bd7f90019e7ef606b55cdebfe2c90 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 30 Oct 2018 05:37:26 +0200 Subject: [PATCH 1/4] Add GitHub pull request template (#2069) --- .github/PULL_REQUEST_TEMPLATE.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..2c671cae4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ + +### Description + + + + +### Fixes # \ No newline at end of file -- 2.45.2 From 2536d46cdf2f1ecef8c715d69db356d3c6073597 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 30 Oct 2018 13:07:55 -0400 Subject: [PATCH 2/4] remove async/await code --- src/renderer/redux/actions/subscriptions.js | 135 ++++++++++---------- webpack.renderer.additions.js | 1 - 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/renderer/redux/actions/subscriptions.js b/src/renderer/redux/actions/subscriptions.js index 5ad5ba103..465b0faa2 100644 --- a/src/renderer/redux/actions/subscriptions.js +++ b/src/renderer/redux/actions/subscriptions.js @@ -205,7 +205,7 @@ export const doRemoveUnreadSubscription = (channelUri: string, readUri: string) dispatch(doRemoveUnreadSubscriptions(channelUri, [readUri])); }; -export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: boolean) => async ( +export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: boolean) => ( dispatch: ReduxDispatch, getState: GetState ) => { @@ -223,85 +223,86 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool ); } - const claimListByChannel = await Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 }); - const claimResult = claimListByChannel[subscriptionUri] || {}; - const { claims_in_channel: claimsInChannel } = claimResult; + Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 }).then(claimListByChannel => { + const claimResult = claimListByChannel[subscriptionUri] || {}; + const { claims_in_channel: claimsInChannel } = claimResult; - // may happen if subscribed to an abandoned channel or an empty channel - if (!claimsInChannel || !claimsInChannel.length) { - return; - } + // may happen if subscribed to an abandoned channel or an empty channel + if (!claimsInChannel || !claimsInChannel.length) { + return; + } - // Determine if the latest subscription currently saved is actually the latest subscription - const latestIndex = claimsInChannel.findIndex( - claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest - ); + // Determine if the latest subscription currently saved is actually the latest subscription + const latestIndex = claimsInChannel.findIndex( + claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest + ); - // If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed - const latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex; + // If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed + const latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex; - // If latest is 0, nothing has changed - // Do not download/notify about new content, it would download/notify 10 claims per channel - if (latestIndex !== 0 && savedSubscription.latest) { - let downloadCount = 0; + // If latest is 0, nothing has changed + // Do not download/notify about new content, it would download/notify 10 claims per channel + if (latestIndex !== 0 && savedSubscription.latest) { + let downloadCount = 0; - const newUnread = []; - claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => { - const uri = buildURI({ contentName: claim.name, claimId: claim.claim_id }, true); - const shouldDownload = - shouldAutoDownload && - Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee); + const newUnread = []; + claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => { + const uri = buildURI({ contentName: claim.name, claimId: claim.claim_id }, true); + const shouldDownload = + shouldAutoDownload && + Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee); - // Add the new content to the list of "un-read" subscriptions - if (shouldNotify) { - newUnread.push(uri); - } + // Add the new content to the list of "un-read" subscriptions + if (shouldNotify) { + newUnread.push(uri); + } - if (shouldDownload) { - downloadCount += 1; - dispatch(doPurchaseUri(uri, { cost: 0 }, true)); - } - }); + if (shouldDownload) { + downloadCount += 1; + dispatch(doPurchaseUri(uri, { cost: 0 }, true)); + } + }); + dispatch( + doUpdateUnreadSubscriptions( + subscriptionUri, + newUnread, + downloadCount > 0 ? NOTIFICATION_TYPES.DOWNLOADING : NOTIFICATION_TYPES.NOTIFY_ONLY + ) + ); + } + + // Set the latest piece of content for a channel + // This allows the app to know if there has been new content since it was last set dispatch( - doUpdateUnreadSubscriptions( - subscriptionUri, - newUnread, - downloadCount > 0 ? NOTIFICATION_TYPES.DOWNLOADING : NOTIFICATION_TYPES.NOTIFY_ONLY + setSubscriptionLatest( + { + channelName: claimsInChannel[0].channel_name, + uri: buildURI( + { + channelName: claimsInChannel[0].channel_name, + claimId: claimsInChannel[0].claim_id, + }, + false + ), + }, + buildURI( + { contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id }, + false + ) ) ); - } - // Set the latest piece of content for a channel - // This allows the app to know if there has been new content since it was last set - dispatch( - setSubscriptionLatest( - { - channelName: claimsInChannel[0].channel_name, - uri: buildURI( - { - channelName: claimsInChannel[0].channel_name, - claimId: claimsInChannel[0].claim_id, - }, - false - ), + // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED + // means it will delete a non-existant fetchingChannelClaims[uri] + dispatch({ + type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED, + data: { + uri: subscriptionUri, + claims: claimsInChannel || [], + page: 1, }, - buildURI( - { contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id }, - false - ) - ) - ); - - // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED - // means it will delete a non-existant fetchingChannelClaims[uri] - dispatch({ - type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED, - data: { - uri: subscriptionUri, - claims: claimsInChannel || [], - page: 1, - }, + }); }); }; diff --git a/webpack.renderer.additions.js b/webpack.renderer.additions.js index c3acec336..cb9523c55 100644 --- a/webpack.renderer.additions.js +++ b/webpack.renderer.additions.js @@ -13,7 +13,6 @@ const isDev = PROCESS_ARGV && PROCESS_ARGV.original && module.exports = { // This rule is temporarily necessary until https://github.com/electron-userland/electron-webpack/issues/60 is fixed. - entry: ['babel-polyfill', `${ELECTRON_RENDERER_PROCESS_ROOT}/index.js`], module: { rules: [ { -- 2.45.2 From b42d673258a4907890a2b9bb231ddaf9544cb90d Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 30 Oct 2018 13:12:21 -0400 Subject: [PATCH 3/4] fix card subtitle spacing --- src/renderer/scss/component/_card.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer/scss/component/_card.scss b/src/renderer/scss/component/_card.scss index 62371173c..4a127c9c0 100644 --- a/src/renderer/scss/component/_card.scss +++ b/src/renderer/scss/component/_card.scss @@ -227,8 +227,7 @@ .card__subtitle { color: $lbry-gray-5; - font-size: .9em; - line-height: .9em; + font-size: 0.9em; padding-top: $spacing-vertical * 1/3; @media (min-width: $large-breakpoint) { -- 2.45.2 From 06c16cdf2797ab5e9d7d1fc714694886de3aa37f Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 30 Oct 2018 13:35:47 -0400 Subject: [PATCH 4/4] Revert "Improve type checking for card verify" (#2074) --- src/renderer/component/cardVerify/view.jsx | 71 +++++++--------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/src/renderer/component/cardVerify/view.jsx b/src/renderer/component/cardVerify/view.jsx index 5d3f3e007..0f3ff4fe0 100644 --- a/src/renderer/component/cardVerify/view.jsx +++ b/src/renderer/component/cardVerify/view.jsx @@ -7,20 +7,6 @@ let scriptLoading = false; let scriptLoaded = false; let scriptDidError = false; -declare class CardVerify { - static stripeHandler: { - open: Function, - close: Function, - }; -} - -declare class StripeCheckout { - static configure({}): { - open: Function, - close: Function, - }; -} - type Props = { disabled: boolean, label: ?string, @@ -41,20 +27,14 @@ type Props = { // token.id can be used to create a charge or customer. // token.email contains the email address entered by the user. token: string, - email: string, }; -type State = { - open: boolean, -}; - -class CardVerifyComponent extends React.Component { - constructor(props: Props) { +class CardVerify extends React.Component { + constructor(props) { super(props); this.state = { open: false, }; - this.onClick = this.onClick.bind(this); } componentDidMount() { @@ -85,14 +65,12 @@ class CardVerifyComponent extends React.Component { scriptDidError = true; scriptLoading = false; reject(event); - this.onScriptError(); + this.onScriptError(event); }; }); const wrappedPromise = new Promise((accept, cancel) => { - promise.then(() => (canceled ? cancel(new Error({ isCanceled: true })) : accept())); - promise.catch( - error => (canceled ? cancel(new Error({ isCanceled: true })) : cancel(error)) - ); + promise.then(() => (canceled ? cancel({ isCanceled: true }) : accept())); + promise.catch(error => (canceled ? cancel({ isCanceled: true }) : cancel(error))); }); return { @@ -105,9 +83,7 @@ class CardVerifyComponent extends React.Component { this.loadPromise.promise.then(this.onScriptLoaded).catch(this.onScriptError); - if (document.body) { - document.body.appendChild(script); - } + document.body.appendChild(script); } componentDidUpdate() { @@ -136,7 +112,7 @@ class CardVerifyComponent extends React.Component { } }; - onScriptError = () => { + onScriptError = (...args) => { throw new Error('Unable to load credit validation script.'); }; @@ -144,23 +120,6 @@ class CardVerifyComponent extends React.Component { this.setState({ open: false }); }; - onClick = () => { - if (scriptDidError) { - throw new Error('Tried to call onClick, but StripeCheckout failed to load'); - } else if (CardVerify.stripeHandler) { - this.showStripeDialog(); - } else { - this.hasPendingClick = true; - } - }; - - loadPromise: { - promise: Promise, - cancel: Function, - }; - - hasPendingClick: boolean; - updateStripeHandler() { if (!CardVerify.stripeHandler) { CardVerify.stripeHandler = StripeCheckout.configure({ @@ -183,6 +142,18 @@ class CardVerifyComponent extends React.Component { }); } + onClick = () => { + if (scriptDidError) { + try { + throw new Error('Tried to call onClick, but StripeCheckout failed to load'); + } catch (x) {} + } else if (CardVerify.stripeHandler) { + this.showStripeDialog(); + } else { + this.hasPendingClick = true; + } + }; + render() { return (