From 98c9dfb68e444e62d02b306ed832970abb4557fc Mon Sep 17 00:00:00 2001 From: liamcardenas Date: Tue, 6 Mar 2018 00:36:04 -0800 Subject: [PATCH] Formatted code with prettier --- src/main/index.js | 4 +- src/renderer/component/fileList/view.jsx | 12 ++-- src/renderer/component/rewardSummary/view.jsx | 6 +- src/renderer/index.js | 2 +- src/renderer/page/file/index.js | 3 +- src/renderer/page/file/view.jsx | 11 ++-- src/renderer/redux/actions/content.js | 15 +++-- src/renderer/redux/actions/settings.js | 3 +- src/renderer/redux/actions/subscriptions.js | 62 ++++++++++++++----- src/renderer/redux/reducers/subscriptions.js | 34 ++++++---- 10 files changed, 101 insertions(+), 51 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index d068e87e0..ec468ae70 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -64,8 +64,8 @@ app.on('ready', async () => { dialog.showErrorBox( 'Daemon has Exited', 'The daemon may have encountered an unexpected error, or another daemon instance is already running. \n\n' + - 'For more information please visit: \n' + - 'https://lbry.io/faq/startup-troubleshooting' + 'For more information please visit: \n' + + 'https://lbry.io/faq/startup-troubleshooting' ); app.quit(); } diff --git a/src/renderer/component/fileList/view.jsx b/src/renderer/component/fileList/view.jsx index afb446323..eef0993c6 100644 --- a/src/renderer/component/fileList/view.jsx +++ b/src/renderer/component/fileList/view.jsx @@ -15,27 +15,27 @@ class FileList extends React.PureComponent { this._sortFunctions = { dateNew(fileInfos) { return fileInfos.slice().sort((fileInfo1, fileInfo2) => { - const height1 = fileInfo1.height - const height2 = fileInfo2.height + const height1 = fileInfo1.height; + const height2 = fileInfo2.height; if (height1 > height2) { return -1; } else if (height1 < height2) { return 1; } return 0; - }); + }); }, dateOld(fileInfos) { return fileInfos.slice().sort((fileInfo1, fileInfo2) => { - const height1 = fileInfo1.height - const height2 = fileInfo2.height + const height1 = fileInfo1.height; + const height2 = fileInfo2.height; if (height1 < height2) { return -1; } else if (height1 > height2) { return 1; } return 0; - }); + }); }, title(fileInfos) { return fileInfos.slice().sort((fileInfo1, fileInfo2) => { diff --git a/src/renderer/component/rewardSummary/view.jsx b/src/renderer/component/rewardSummary/view.jsx index 36507d535..9fa611902 100644 --- a/src/renderer/component/rewardSummary/view.jsx +++ b/src/renderer/component/rewardSummary/view.jsx @@ -15,9 +15,9 @@ const RewardSummary = (props: Props) => {

{__('Rewards')}

- {__('Read our')}{' '} - {__('FAQ')}{' '}{__('to learn more about LBRY Rewards')}. -

+ {__('Read our')} {__('FAQ')}{' '} + {__('to learn more about LBRY Rewards')}. +

{unclaimedRewardAmount > 0 ? ( diff --git a/src/renderer/index.js b/src/renderer/index.js index 822f0b153..c1edc1271 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -69,7 +69,7 @@ ipcRenderer.on('window-is-focused', () => { document.addEventListener('dragover', event => { event.preventDefault(); -}) +}); document.addEventListener('drop', event => { event.preventDefault(); }); diff --git a/src/renderer/page/file/index.js b/src/renderer/page/file/index.js index a4a86f131..eb5dd0fd4 100644 --- a/src/renderer/page/file/index.js +++ b/src/renderer/page/file/index.js @@ -30,7 +30,8 @@ const perform = dispatch => ({ navigate: (path, params) => dispatch(doNavigate(path, params)), fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), - checkSubscriptionLatest: (subscription, uri) => dispatch(checkSubscriptionLatest(subscription, uri)), + checkSubscriptionLatest: (subscription, uri) => + dispatch(checkSubscriptionLatest(subscription, uri)), }); export default connect(select, perform)(FilePage); diff --git a/src/renderer/page/file/view.jsx b/src/renderer/page/file/view.jsx index 77d422d1c..1de94e32a 100644 --- a/src/renderer/page/file/view.jsx +++ b/src/renderer/page/file/view.jsx @@ -37,10 +37,13 @@ class FilePage extends React.PureComponent { } checkSubscriptionLatest(props) { - props.checkSubscriptionLatest({ - channelName: props.claim.channel_name, - uri: `${props.claim.channel_name}#${props.claim.value.publisherSignature.certificateId}`, - }, `${props.claim.name}#${props.claim.claim_id}`); + props.checkSubscriptionLatest( + { + channelName: props.claim.channel_name, + uri: `${props.claim.channel_name}#${props.claim.value.publisherSignature.certificateId}`, + }, + `${props.claim.name}#${props.claim.claim_id}` + ); } render() { diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index d665828d6..c369ceb1a 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -359,12 +359,17 @@ export function doFetchClaimsByChannel(uri, page) { const claimResult = result[uri] || {}; const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult; - if(claimsInChannel && claimsInChannel.length) { + if (claimsInChannel && claimsInChannel.length) { let latest = claimsInChannel[0]; - dispatch(setSubscriptionLatest({ - channelName: latest.channel_name, - uri: `${latest.channel_name}#${latest.value.publisherSignature.certificateId}` - }, `${latest.name}#${latest.claim_id}`)); + dispatch( + setSubscriptionLatest( + { + channelName: latest.channel_name, + uri: `${latest.channel_name}#${latest.value.publisherSignature.certificateId}`, + }, + `${latest.name}#${latest.claim_id}` + ) + ); } dispatch({ diff --git a/src/renderer/redux/actions/settings.js b/src/renderer/redux/actions/settings.js index da4ed52a0..db3fa5020 100644 --- a/src/renderer/redux/actions/settings.js +++ b/src/renderer/redux/actions/settings.js @@ -70,7 +70,8 @@ export function doUpdateIsNight() { const momentNow = moment(); return { type: ACTIONS.UPDATE_IS_NIGHT, - data: { isNight: (() => { + data: { + isNight: (() => { const startNightMoment = moment('21:00', 'HH:mm'); const endNightMoment = moment('8:00', 'HH:mm'); return !(momentNow.isAfter(endNightMoment) && momentNow.isBefore(startNightMoment)); diff --git a/src/renderer/redux/actions/subscriptions.js b/src/renderer/redux/actions/subscriptions.js index 5ae3885ea..5e8fddb8c 100644 --- a/src/renderer/redux/actions/subscriptions.js +++ b/src/renderer/redux/actions/subscriptions.js @@ -20,9 +20,15 @@ export const doChannelUnsubscribe = (subscription: Subscription) => (dispatch: D data: subscription, }); -export const doCheckSubscriptions = () => (dispatch: Dispatch, getState: () => SubscriptionState) => { +export const doCheckSubscriptions = () => ( + dispatch: Dispatch, + getState: () => SubscriptionState +) => { const checkSubscriptionsTimer = setInterval( - () => selectSubscriptions(getState()).map((subscription: Subscription) => dispatch(doCheckSubscription(subscription))), + () => + selectSubscriptions(getState()).map((subscription: Subscription) => + dispatch(doCheckSubscription(subscription)) + ), CHECK_SUBSCRIPTIONS_INTERVAL ); dispatch({ @@ -41,47 +47,69 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di const claimResult = result[subscription.uri] || {}; const { claims_in_channel: claimsInChannel } = claimResult; - let count = subscription.latest ? claimsInChannel.reduce((prev, cur, index) => `${cur.name}#${cur.claim_id}` === subscription.latest ? index : prev, -1) : 1; + let count = subscription.latest + ? claimsInChannel.reduce( + (prev, cur, index) => + `${cur.name}#${cur.claim_id}` === subscription.latest ? index : prev, + -1 + ) + : 1; - if(count !== 0) { - if(!claimsInChannel[0].value.stream.metadata.fee) { - dispatch(doPurchaseUri(`${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}`, {cost: 0})); + if (count !== 0) { + if (!claimsInChannel[0].value.stream.metadata.fee) { + dispatch( + doPurchaseUri(`${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}`, { cost: 0 }) + ); } const notif = new window.Notification(subscription.channelName, { - body: `Posted ${claimsInChannel[0].value.stream.metadata.title}${count > 1 ? ` and ${count-1} other new items` : '' }${count < 0 ? ' and 9+ other new items' : ''}`, + body: `Posted ${claimsInChannel[0].value.stream.metadata.title}${ + count > 1 ? ` and ${count - 1} other new items` : '' + }${count < 0 ? ' and 9+ other new items' : ''}`, silent: false, }); notif.onclick = () => { - dispatch(doNavigate('/show', { uri: `lbry://${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}` })) + dispatch( + doNavigate('/show', { + uri: `lbry://${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}`, + }) + ); }; } dispatch({ type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED, - data: subscription + data: subscription, }); }); -} +}; -export const checkSubscriptionLatest = (channel: Subscription, uri: string) => (dispatch: Dispatch) => { +export const checkSubscriptionLatest = (channel: Subscription, uri: string) => ( + dispatch: Dispatch +) => { Lbry.claim_list_by_channel({ uri: channel.uri, page: 1 }).then(result => { const claimResult = result[channel.uri] || {}; const { claims_in_channel: claimsInChannel } = claimResult; - if(claimsInChannel && claimsInChannel.length && `${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}` === uri) { + if ( + claimsInChannel && + claimsInChannel.length && + `${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}` === uri + ) { dispatch(setSubscriptionLatest(channel, uri)); } }); -} +}; -export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) => - dispatch({ +export const setSubscriptionLatest = (subscription: Subscription, uri: string) => ( + dispatch: Dispatch +) => + dispatch({ type: ACTIONS.SET_SUBSCRIPTION_LATEST, data: { subscription, - uri - } + uri, + }, }); export const setHasFetchedSubscriptions = () => (dispatch: Dispatch) => diff --git a/src/renderer/redux/reducers/subscriptions.js b/src/renderer/redux/reducers/subscriptions.js index 2ef3b17cc..a8f40746f 100644 --- a/src/renderer/redux/reducers/subscriptions.js +++ b/src/renderer/redux/reducers/subscriptions.js @@ -5,7 +5,7 @@ import { handleActions } from 'util/redux-utils'; export type Subscription = { channelName: string, uri: string, - latest: ?string + latest: ?string, }; // Subscription redux types @@ -33,19 +33,26 @@ type setSubscriptionLatest = { type: ACTIONS.SET_SUBSCRIPTION_LATEST, data: { subscription: Subscription, - uri: string - } -} + uri: string, + }, +}; type CheckSubscriptionStarted = { - type: ACTIONS.CHECK_SUBSCRIPTION_STARTED -} + type: ACTIONS.CHECK_SUBSCRIPTION_STARTED, +}; type CheckSubscriptionCompleted = { - type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED -} + type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED, +}; -export type Action = doChannelSubscribe | doChannelUnsubscribe | HasFetchedSubscriptions | setSubscriptionLatest | CheckSubscriptionStarted | CheckSubscriptionCompleted | Function; +export type Action = + | doChannelSubscribe + | doChannelUnsubscribe + | HasFetchedSubscriptions + | setSubscriptionLatest + | CheckSubscriptionStarted + | CheckSubscriptionCompleted + | Function; export type Dispatch = (action: Action) => any; const defaultState = { @@ -92,8 +99,13 @@ export default handleActions( action: setSubscriptionLatest ): SubscriptionState => ({ ...state, - subscriptions: state.subscriptions.map(subscription => subscription.channelName === action.data.subscription.channelName ? {...subscription, latest: action.data.uri} : subscription) - }) + subscriptions: state.subscriptions.map( + subscription => + subscription.channelName === action.data.subscription.channelName + ? { ...subscription, latest: action.data.uri } + : subscription + ), + }), }, defaultState );