mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 17:55:11 +00:00
Formatted code with prettier
This commit is contained in:
parent
2c6f2d52bf
commit
98c9dfb68e
10 changed files with 101 additions and 51 deletions
|
@ -64,8 +64,8 @@ app.on('ready', async () => {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
'Daemon has Exited',
|
'Daemon has Exited',
|
||||||
'The daemon may have encountered an unexpected error, or another daemon instance is already running. \n\n' +
|
'The daemon may have encountered an unexpected error, or another daemon instance is already running. \n\n' +
|
||||||
'For more information please visit: \n' +
|
'For more information please visit: \n' +
|
||||||
'https://lbry.io/faq/startup-troubleshooting'
|
'https://lbry.io/faq/startup-troubleshooting'
|
||||||
);
|
);
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,27 +15,27 @@ class FileList extends React.PureComponent {
|
||||||
this._sortFunctions = {
|
this._sortFunctions = {
|
||||||
dateNew(fileInfos) {
|
dateNew(fileInfos) {
|
||||||
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||||
const height1 = fileInfo1.height
|
const height1 = fileInfo1.height;
|
||||||
const height2 = fileInfo2.height
|
const height2 = fileInfo2.height;
|
||||||
if (height1 > height2) {
|
if (height1 > height2) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (height1 < height2) {
|
} else if (height1 < height2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dateOld(fileInfos) {
|
dateOld(fileInfos) {
|
||||||
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||||
const height1 = fileInfo1.height
|
const height1 = fileInfo1.height;
|
||||||
const height2 = fileInfo2.height
|
const height2 = fileInfo2.height;
|
||||||
if (height1 < height2) {
|
if (height1 < height2) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (height1 > height2) {
|
} else if (height1 > height2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title(fileInfos) {
|
title(fileInfos) {
|
||||||
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||||
|
|
|
@ -15,9 +15,9 @@ const RewardSummary = (props: Props) => {
|
||||||
<div className="card__title-primary">
|
<div className="card__title-primary">
|
||||||
<h3>{__('Rewards')}</h3>
|
<h3>{__('Rewards')}</h3>
|
||||||
<p className="help">
|
<p className="help">
|
||||||
{__('Read our')}{' '}
|
{__('Read our')} <Link href="https://lbry.io/faq/rewards">{__('FAQ')}</Link>{' '}
|
||||||
<Link href="https://lbry.io/faq/rewards">{__('FAQ')}</Link>{' '}{__('to learn more about LBRY Rewards')}.
|
{__('to learn more about LBRY Rewards')}.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
{unclaimedRewardAmount > 0 ? (
|
{unclaimedRewardAmount > 0 ? (
|
||||||
|
|
|
@ -69,7 +69,7 @@ ipcRenderer.on('window-is-focused', () => {
|
||||||
|
|
||||||
document.addEventListener('dragover', event => {
|
document.addEventListener('dragover', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
})
|
});
|
||||||
document.addEventListener('drop', event => {
|
document.addEventListener('drop', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,7 +30,8 @@ const perform = dispatch => ({
|
||||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||||
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
||||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(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);
|
export default connect(select, perform)(FilePage);
|
||||||
|
|
|
@ -37,10 +37,13 @@ class FilePage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSubscriptionLatest(props) {
|
checkSubscriptionLatest(props) {
|
||||||
props.checkSubscriptionLatest({
|
props.checkSubscriptionLatest(
|
||||||
channelName: props.claim.channel_name,
|
{
|
||||||
uri: `${props.claim.channel_name}#${props.claim.value.publisherSignature.certificateId}`,
|
channelName: props.claim.channel_name,
|
||||||
}, `${props.claim.name}#${props.claim.claim_id}`);
|
uri: `${props.claim.channel_name}#${props.claim.value.publisherSignature.certificateId}`,
|
||||||
|
},
|
||||||
|
`${props.claim.name}#${props.claim.claim_id}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -359,12 +359,17 @@ export function doFetchClaimsByChannel(uri, page) {
|
||||||
const claimResult = result[uri] || {};
|
const claimResult = result[uri] || {};
|
||||||
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
||||||
|
|
||||||
if(claimsInChannel && claimsInChannel.length) {
|
if (claimsInChannel && claimsInChannel.length) {
|
||||||
let latest = claimsInChannel[0];
|
let latest = claimsInChannel[0];
|
||||||
dispatch(setSubscriptionLatest({
|
dispatch(
|
||||||
channelName: latest.channel_name,
|
setSubscriptionLatest(
|
||||||
uri: `${latest.channel_name}#${latest.value.publisherSignature.certificateId}`
|
{
|
||||||
}, `${latest.name}#${latest.claim_id}`));
|
channelName: latest.channel_name,
|
||||||
|
uri: `${latest.channel_name}#${latest.value.publisherSignature.certificateId}`,
|
||||||
|
},
|
||||||
|
`${latest.name}#${latest.claim_id}`
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -70,7 +70,8 @@ export function doUpdateIsNight() {
|
||||||
const momentNow = moment();
|
const momentNow = moment();
|
||||||
return {
|
return {
|
||||||
type: ACTIONS.UPDATE_IS_NIGHT,
|
type: ACTIONS.UPDATE_IS_NIGHT,
|
||||||
data: { isNight: (() => {
|
data: {
|
||||||
|
isNight: (() => {
|
||||||
const startNightMoment = moment('21:00', 'HH:mm');
|
const startNightMoment = moment('21:00', 'HH:mm');
|
||||||
const endNightMoment = moment('8:00', 'HH:mm');
|
const endNightMoment = moment('8:00', 'HH:mm');
|
||||||
return !(momentNow.isAfter(endNightMoment) && momentNow.isBefore(startNightMoment));
|
return !(momentNow.isAfter(endNightMoment) && momentNow.isBefore(startNightMoment));
|
||||||
|
|
|
@ -20,9 +20,15 @@ export const doChannelUnsubscribe = (subscription: Subscription) => (dispatch: D
|
||||||
data: subscription,
|
data: subscription,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const doCheckSubscriptions = () => (dispatch: Dispatch, getState: () => SubscriptionState) => {
|
export const doCheckSubscriptions = () => (
|
||||||
|
dispatch: Dispatch,
|
||||||
|
getState: () => SubscriptionState
|
||||||
|
) => {
|
||||||
const checkSubscriptionsTimer = setInterval(
|
const checkSubscriptionsTimer = setInterval(
|
||||||
() => selectSubscriptions(getState()).map((subscription: Subscription) => dispatch(doCheckSubscription(subscription))),
|
() =>
|
||||||
|
selectSubscriptions(getState()).map((subscription: Subscription) =>
|
||||||
|
dispatch(doCheckSubscription(subscription))
|
||||||
|
),
|
||||||
CHECK_SUBSCRIPTIONS_INTERVAL
|
CHECK_SUBSCRIPTIONS_INTERVAL
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -41,47 +47,69 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
||||||
const claimResult = result[subscription.uri] || {};
|
const claimResult = result[subscription.uri] || {};
|
||||||
const { claims_in_channel: claimsInChannel } = claimResult;
|
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 (count !== 0) {
|
||||||
if(!claimsInChannel[0].value.stream.metadata.fee) {
|
if (!claimsInChannel[0].value.stream.metadata.fee) {
|
||||||
dispatch(doPurchaseUri(`${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}`, {cost: 0}));
|
dispatch(
|
||||||
|
doPurchaseUri(`${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}`, { cost: 0 })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const notif = new window.Notification(subscription.channelName, {
|
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,
|
silent: false,
|
||||||
});
|
});
|
||||||
notif.onclick = () => {
|
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({
|
dispatch({
|
||||||
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
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 => {
|
Lbry.claim_list_by_channel({ uri: channel.uri, page: 1 }).then(result => {
|
||||||
const claimResult = result[channel.uri] || {};
|
const claimResult = result[channel.uri] || {};
|
||||||
const { claims_in_channel: claimsInChannel } = claimResult;
|
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));
|
dispatch(setSubscriptionLatest(channel, uri));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) =>
|
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (
|
||||||
dispatch({
|
dispatch: Dispatch
|
||||||
|
) =>
|
||||||
|
dispatch({
|
||||||
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
||||||
data: {
|
data: {
|
||||||
subscription,
|
subscription,
|
||||||
uri
|
uri,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setHasFetchedSubscriptions = () => (dispatch: Dispatch) =>
|
export const setHasFetchedSubscriptions = () => (dispatch: Dispatch) =>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { handleActions } from 'util/redux-utils';
|
||||||
export type Subscription = {
|
export type Subscription = {
|
||||||
channelName: string,
|
channelName: string,
|
||||||
uri: string,
|
uri: string,
|
||||||
latest: ?string
|
latest: ?string,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Subscription redux types
|
// Subscription redux types
|
||||||
|
@ -33,19 +33,26 @@ type setSubscriptionLatest = {
|
||||||
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
||||||
data: {
|
data: {
|
||||||
subscription: Subscription,
|
subscription: Subscription,
|
||||||
uri: string
|
uri: string,
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
type CheckSubscriptionStarted = {
|
type CheckSubscriptionStarted = {
|
||||||
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED
|
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
||||||
}
|
};
|
||||||
|
|
||||||
type CheckSubscriptionCompleted = {
|
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;
|
export type Dispatch = (action: Action) => any;
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
|
@ -92,8 +99,13 @@ export default handleActions(
|
||||||
action: setSubscriptionLatest
|
action: setSubscriptionLatest
|
||||||
): SubscriptionState => ({
|
): SubscriptionState => ({
|
||||||
...state,
|
...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
|
defaultState
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue