From 43900dd72fb8f002b06401ec184c4dbcbaa70510 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 15 Oct 2019 11:47:43 -0400 Subject: [PATCH] call sync after channel create --- package.json | 2 +- src/ui/component/app/index.js | 4 +- src/ui/page/settings/view.jsx | 4 +- src/ui/redux/actions/subscriptions.js | 127 -------------------------- src/ui/store.js | 5 +- yarn.lock | 4 +- 6 files changed, 11 insertions(+), 135 deletions(-) diff --git a/package.json b/package.json index 4656bfd72..c23cd8032 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "husky": "^0.14.3", "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#cd69946d4ca016c896639aa401d8f6b87d3e410e", + "lbry-redux": "lbryio/lbry-redux#6edcf747e10919605b05b905214fe1d3286898e3", "lbryinc": "lbryio/lbryinc#b8e1708ee4491db342c81576265e1b58f542bedb", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/src/ui/component/app/index.js b/src/ui/component/app/index.js index fd1e312fa..8788fb428 100644 --- a/src/ui/component/app/index.js +++ b/src/ui/component/app/index.js @@ -1,7 +1,7 @@ import * as SETTINGS from 'constants/settings'; import { hot } from 'react-hot-loader/root'; import { connect } from 'react-redux'; -import { selectUser, doRewardList, doFetchRewardedContent, doAuthenticate } from 'lbryinc'; +import { selectUser, doRewardList, doFetchRewardedContent, doFetchAccessToken } from 'lbryinc'; import { doFetchTransactions, doFetchChannelListMine, selectBalance } from 'lbry-redux'; import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings'; import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app'; @@ -21,7 +21,7 @@ const perform = dispatch => ({ fetchRewards: () => dispatch(doRewardList()), fetchRewardedContent: () => dispatch(doFetchRewardedContent()), fetchTransactions: () => dispatch(doFetchTransactions()), - fetchAccessToken: () => dispatch(doAuthenticate()), + fetchAccessToken: () => dispatch(doFetchAccessToken()), fetchChannelListMine: () => dispatch(doFetchChannelListMine()), signIn: () => dispatch(doSignIn()), requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()), diff --git a/src/ui/page/settings/view.jsx b/src/ui/page/settings/view.jsx index 00a23561e..d744158f8 100644 --- a/src/ui/page/settings/view.jsx +++ b/src/ui/page/settings/view.jsx @@ -588,7 +588,9 @@ class SettingsPage extends React.PureComponent { /> {/* @if TARGET='app' */} - {/* setClientSetting(SETTINGS.AUTO_DOWNLOAD, !autoDownload)} diff --git a/src/ui/redux/actions/subscriptions.js b/src/ui/redux/actions/subscriptions.js index 79bfcaca8..71e0e9885 100644 --- a/src/ui/redux/actions/subscriptions.js +++ b/src/ui/redux/actions/subscriptions.js @@ -181,109 +181,6 @@ export const doRemoveUnreadSubscription = (channelUri: string, readUri: string) dispatch(doRemoveUnreadSubscriptions(channelUri, [readUri])); }; -<<<<<<< HEAD -export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: boolean) => ( - dispatch: Dispatch, - getState: GetState -) => { - // no dispatching FETCH_CHANNEL_CLAIMS_STARTED; causes loading issues on - - const state = getState(); - const shouldAutoDownload = makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state); - const savedSubscription = state.subscriptions.subscriptions.find(sub => sub.uri === subscriptionUri); - - if (!savedSubscription) { - throw Error(`Trying to find new content for ${subscriptionUri} but it doesn't exist in your subscriptions`); - } - dispatch({ - type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED, - data: { - uri: subscriptionUri, - page: 1, - }, - }); - // We may be duplicating calls here. Can this logic be baked into doFetchClaimsByChannel? - Lbry.claim_search({ - channel: subscriptionUri, - valid_channel_signature: true, - order_by: ['release_time'], - page: 1, - page_size: PAGE_SIZE, - }).then(claimListByChannel => { - const { items: claimsInChannel } = claimListByChannel; - - // may happen if subscribed to an abandoned channel or an empty channel - if (!claimsInChannel || !claimsInChannel.length) { - return; - } - - dispatch({ - type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED, - data: { - uri: subscriptionUri, - claims: claimsInChannel || [], - page: 1, - }, - }); - - // Determine if the latest subscription currently saved is actually the latest subscription - const latestIndex = claimsInChannel.findIndex(claim => claim.permanent_url === 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 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 = claim.canonical_url; - const shouldDownload = - shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee); - - // Add the new content to the list of "un-read" subscriptions - if (shouldNotify) { - newUnread.push(uri); - } - - if (shouldDownload) { - downloadCount += 1; - // this fails since something is not resolved/saved somewhere... - dispatch(doPlayUri(uri, true, 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 - const latest = claimsInChannel[0]; - dispatch( - setSubscriptionLatest( - { - channelName: latest.signing_channel.name, - uri: latest.signing_channel.permanent_url, - }, - latest.permanent_url - ) - ); - - // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED - // means it will delete a non-existent fetchingChannelClaims[uri] - }); -}; - -======= ->>>>>>> use sdk preference endpoints export const doChannelSubscribe = (subscription: Subscription) => (dispatch: Dispatch, getState: GetState) => { const { settings: { daemonSettings }, @@ -334,30 +231,6 @@ export const doChannelUnsubscribe = (subscription: Subscription) => (dispatch: D } }; -<<<<<<< HEAD -export const doCheckSubscriptions = () => (dispatch: Dispatch, getState: GetState) => { - const state = getState(); - const subscriptions = selectSubscriptions(state); - - subscriptions.forEach((sub: Subscription) => { - dispatch(doCheckSubscription(sub.uri, true)); - }); -}; - -export const doCheckSubscriptionsInit = () => (dispatch: Dispatch) => { - // doCheckSubscriptionsInit is called by doDaemonReady - // setTimeout below is a hack to ensure redux is hydrated when subscriptions are checked - // this will be replaced with which requires a package upgrade - setTimeout(() => dispatch(doFetchMySubscriptions()), 5000); - const checkSubscriptionsTimer = setInterval(() => dispatch(doCheckSubscriptions()), CHECK_SUBSCRIPTIONS_INTERVAL); - dispatch({ - type: ACTIONS.CHECK_SUBSCRIPTIONS_SUBSCRIBE, - data: { checkSubscriptionsTimer }, - }); -}; - -======= ->>>>>>> use sdk preference endpoints export const doFetchRecommendedSubscriptions = () => (dispatch: Dispatch) => { dispatch({ type: ACTIONS.GET_SUGGESTED_SUBSCRIPTIONS_START, diff --git a/src/ui/store.js b/src/ui/store.js index 9d7e7fbdc..5218ee74c 100644 --- a/src/ui/store.js +++ b/src/ui/store.js @@ -105,11 +105,12 @@ history = createHashHistory(); history = createBrowserHistory(); // @endif -const sharedStateActions = [ +const triggerSharedStateActions = [ ACTIONS.CHANNEL_SUBSCRIBE, ACTIONS.CHANNEL_UNSUBSCRIBE, LBRY_REDUX_ACTIONS.TOGGLE_TAG_FOLLOW, LBRY_REDUX_ACTIONS.TOGGLE_BLOCK_CHANNEL, + LBRY_REDUX_ACTIONS.CREATE_CHANNEL_COMPLETED, ]; /** @@ -140,7 +141,7 @@ const sharedStateCb = ({ dispatch, getState }) => { } }; -const sharedStateMiddleware = buildSharedStateMiddleware(sharedStateActions, sharedStateFilters, sharedStateCb); +const sharedStateMiddleware = buildSharedStateMiddleware(triggerSharedStateActions, sharedStateFilters, sharedStateCb); const rootReducer = createRootReducer(history); const persistedReducer = persistReducer(persistOptions, rootReducer); const bulkThunk = createBulkThunkMiddleware(); diff --git a/yarn.lock b/yarn.lock index b37032108..2ac04f67e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6862,9 +6862,9 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#cd69946d4ca016c896639aa401d8f6b87d3e410e: +lbry-redux@lbryio/lbry-redux#6edcf747e10919605b05b905214fe1d3286898e3: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/cd69946d4ca016c896639aa401d8f6b87d3e410e" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/6edcf747e10919605b05b905214fe1d3286898e3" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0"