fetch featured channels #1064
Closed
daovist wants to merge 22 commits from
featured-channels
into master
pull from: featured-channels
merge into: LBRYCommunity:master
LBRYCommunity:master
LBRYCommunity:dependabot/npm_and_yarn/electron-22.3.21
LBRYCommunity:dependabot/npm_and_yarn/semver-5.7.2
LBRYCommunity:7681-remove-block-list-apis
LBRYCommunity:new-sync-demo-no-user
LBRYCommunity:commentserver-swap-test-2
LBRYCommunity:Comment-server-swap
LBRYCommunity:7683-upgrade-to-electron-20
LBRYCommunity:7668-improve-startup-performance-while-fetching-comment-moderation-info
LBRYCommunity:feat-exportWalletSync
LBRYCommunity:feat-walletExport
LBRYCommunity:new-sync-demo
LBRYCommunity:test-updates4b
LBRYCommunity:test-updates-4a
LBRYCommunity:update-test-3c
LBRYCommunity:update-test-3b
LBRYCommunity:update-test-3
LBRYCommunity:test7495b2
LBRYCommunity:test7495a2
LBRYCommunity:test7495b
LBRYCommunity:test7495
LBRYCommunity:test109
LBRYCommunity:test-sdk-109
LBRYCommunity:feat-restoreLocalNotifications
LBRYCommunity:test-gatekeeper
LBRYCommunity:test-107
LBRYCommunity:test-mac-notarize
LBRYCommunity:update-postcss-quagmire
LBRYCommunity:testpush
LBRYCommunity:commentApiDefault
LBRYCommunity:inspect-upgrades
LBRYCommunity:fix-unblockIsChannelClaim
LBRYCommunity:ody255
LBRYCommunity:robd-mac-2
LBRYCommunity:sso-demo
LBRYCommunity:robd-universal
LBRYCommunity:remove-swap
LBRYCommunity:cleaning.dec.21
LBRYCommunity:update-trending-param
LBRYCommunity:collection-ordering
LBRYCommunity:download-progress
LBRYCommunity:anton
LBRYCommunity:anthony-fix-video-ios
LBRYCommunity:saltdev
LBRYCommunity:bump-electron-to-11
LBRYCommunity:fix-noBlockSubmitOnImgError
LBRYCommunity:x.lint.extras
LBRYCommunity:x.final
LBRYCommunity:somehow-working
LBRYCommunity:reenable-ads
LBRYCommunity:issue/7152
LBRYCommunity:chat-markdown
LBRYCommunity:ip/muted.uris
LBRYCommunity:odysee-split
LBRYCommunity:feat-desktopRelated
LBRYCommunity:ip/memo
LBRYCommunity:bs
LBRYCommunity:ip/memoization
LBRYCommunity:bump-flow-version
LBRYCommunity:ip/shared.block.list
LBRYCommunity:keycloak-sso
LBRYCommunity:a-r-w-k-2
LBRYCommunity:auth-refactor-w-keycloak
LBRYCommunity:auth-refactor
LBRYCommunity:rb-ip/embed-replay
LBRYCommunity:issue/2120
LBRYCommunity:oidc
LBRYCommunity:fix-videojs-ios
LBRYCommunity:fiat-tip-improvements
LBRYCommunity:test-tom-1
LBRYCommunity:fix-videojs-issues
LBRYCommunity:fix-persistSupportOption
LBRYCommunity:ctrl-txt
LBRYCommunity:add-play-button-on-pause-ios
LBRYCommunity:mobile-ui-bugfix-for-preview-images
LBRYCommunity:fix-livestream-claim-type
LBRYCommunity:playback-controls-2
LBRYCommunity:copy-list
LBRYCommunity:feat-collection-background-publishing
LBRYCommunity:ip/repost.in.homepage
LBRYCommunity:wallet-iteration-2
LBRYCommunity:broken-ads-branch
LBRYCommunity:move-stripe-transactions-to-wallet-fix
LBRYCommunity:lint.autoformat
LBRYCommunity:jessop-stripe
LBRYCommunity:move-transactions
LBRYCommunity:stripe-move-transactions-to-wallet
LBRYCommunity:mater
LBRYCommunity:more-stripe-integration
LBRYCommunity:more-stripe-integration1
LBRYCommunity:desktop-redirect
LBRYCommunity:rss-test
LBRYCommunity:fixed-collectionEdit
LBRYCommunity:watchman-plugin-odysee-anthony
LBRYCommunity:grin
LBRYCommunity:watchman-plugin-odysee
LBRYCommunity:protocol
LBRYCommunity:salt_saved_list
LBRYCommunity:salt-saved_list
LBRYCommunity:watchman-plugin
LBRYCommunity:more-stripe-integration2
LBRYCommunity:salt-savedList
LBRYCommunity:salt/mobile-comments
LBRYCommunity:chromecast-test2
LBRYCommunity:odysee
LBRYCommunity:wpe-on-ody
LBRYCommunity:bring-back-subtitles-button
LBRYCommunity:merge-to-odysee
LBRYCommunity:bugfix-tip-error
LBRYCommunity:popup-fix
LBRYCommunity:favi-cherry
LBRYCommunity:searchDefaults
LBRYCommunity:pin-from-homepages-master
LBRYCommunity:ody-7-22-c
LBRYCommunity:ody-7-22-b
LBRYCommunity:ody-7-22
LBRYCommunity:ody-7-21
LBRYCommunity:cherry.pick.thumbs.fix
LBRYCommunity:ody-rb-7-20c
LBRYCommunity:test-chromecast
LBRYCommunity:ody-7-20-rb
LBRYCommunity:odysee-cnsearch
LBRYCommunity:ody-7-19-b
LBRYCommunity:anthony-odysee
LBRYCommunity:drewhancock-patch-2
LBRYCommunity:horizon-server
LBRYCommunity:feat-nicer-outages
LBRYCommunity:tech-debt/selectors-search
LBRYCommunity:fix-lbry-tv-thumbnails
LBRYCommunity:drewhancock-patch-1
LBRYCommunity:jbnrecsys
LBRYCommunity:feat/disableListEditPending
LBRYCommunity:testapi
LBRYCommunity:bump-lightouse-throttle
LBRYCommunity:popup
LBRYCommunity:replays-rebased-tom
LBRYCommunity:pre-reoll-ads-rebase
LBRYCommunity:julianchandra-patch-1
LBRYCommunity:feat/better-chat
LBRYCommunity:revert-livestream
LBRYCommunity:feat/code-splitting
LBRYCommunity:feat/go-live-forms
LBRYCommunity:UI/drop-down-menu-animation
LBRYCommunity:faster-builds
No reviewers
Labels
Clear labels
Work is part of a proposal
Beamer is waiting on you!
Discuss this issue at the next planning meeting, then remove this label
Welcome to Hacktoberfest
Long-term storage
No knowledge of the existing code required
Some knowledge of the existing code is recommended
Significant knowledge of the existing code is recommended
Intimate knowledge of the existing code is recommended
Solution unclear, needs research
Issue needs to be groomed before work can start
Priority level needs to be defined
Issue needs step-by-step instructions on how to reproduce in latest code
Needs technical design signoff before implementation can begin
Temporarily paused
Issue is blocking release, do ASAP
Work needs to be moved into sprint ASAP
Work should be done but can stay in the backlog for now
Work needs to be done within 2-3 sprints
general redesign not prioritize for anyone release
Requires work on lbry-sdk repo
Existing functionality is wrong or broken
A conversation. No specific changes requested
Existing (or partially existing) functionality needs to be changed
New functionality that does not exist yet
Minimal user-visible changes, but significant internal work
Either work that's not related to the code, or a small chore that does not fit into other categories
Solution needs additional user testing
Work that was not planned into the spirnt, took priority over planned work
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
Work is part of a proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
Beamer is waiting on you!
channel
comments
community PR
consider soon
Discuss this issue at the next planning meeting, then remove this label
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
Welcome to Hacktoberfest
help wanted
hub-dependent
icebox
Long-term storage
Invalid
level: 0
level: 1
No knowledge of the existing code required
level: 2
Some knowledge of the existing code is recommended
level: 3
Significant knowledge of the existing code is recommended
level: 4
Intimate knowledge of the existing code is recommended
merge when green
needs: exploration
Solution unclear, needs research
needs: grooming
Issue needs to be groomed before work can start
needs: priority
Priority level needs to be defined
needs: repro
Issue needs step-by-step instructions on how to reproduce in latest code
needs: tech design
Needs technical design signoff before implementation can begin
notifications
odysee
on hold
Temporarily paused
playlists
priority: blocker
Issue is blocking release, do ASAP
priority: high
Work needs to be moved into sprint ASAP
priority: low
Work should be done but can stay in the backlog for now
priority: medium
Work needs to be done within 2-3 sprints
protocol dependent
recsys
redesign
general redesign not prioritize for anyone release
regression
resilience
sdk dependent
Requires work on lbry-sdk repo
Tom's Wishlist
trending
type: bug
Existing functionality is wrong or broken
type: discussion
A conversation. No specific changes requested
type: improvement
Existing (or partially existing) functionality needs to be changed
type: new feature
New functionality that does not exist yet
type: refactor
Minimal user-visible changes, but significant internal work
type: task
Either work that's not related to the code, or a small chore that does not fit into other categories
type: testing
Solution needs additional user testing
unplanned
Work that was not planned into the spirnt, took priority over planned work
windows
No labels
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
channel
comments
community PR
consider soon
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
help wanted
hub-dependent
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
merge when green
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
notifications
odysee
on hold
playlists
priority: blocker
priority: high
priority: low
priority: medium
protocol dependent
recsys
redesign
regression
resilience
sdk dependent
Tom's Wishlist
trending
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
windows
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-desktop#1064
Reference in a new issue
No description provided.
Delete branch "featured-channels"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fetches data for featured channels and puts it into store.content.featuredUris
work in progress, channels are not displaying yet...
This is ready for a real review - @liamcardenas @seanyesmunt
I ended up separating channel data from the existing discover data entirely. The channels are below the normal discover data and they come in several seconds later so I added a second waiting message:
{hasContent && !hasChannels && <BusyMessage message={__('Fetching featured channels')} />}
Issue #1049 says "If the object key begins with an @ (indicating a channel) and the listed content array is empty" so I have an empty channel and a channel with one uri hard coded in the action to demonstrate an empty channel and one with addresses, which I will remove as this issue reaches completion.
Because I am splitting the list from the API into "content" and "channels", a channel with a non empty array is treated like content so it doesn't get the categoryLink like in the issue description -- I am turning the given channel key into
${channel}#${certificateId}
when the channel data comes in.I think if you use
doFetchClaimsByChannel
you can eliminate most or all of this code.This looks like a new copy of claims-in-channel data, which would be a DRY break. Use the same place that other channel claim data is stored. Please look at
ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED
.That's what I was going for all week but couldn't get all the parts together. I could never get the component to re-render when the channels came in, or couldn't load from channels correctly while not interfering with the subscriptions page or having to reset before viewing either page to not mix featured and subscribed channels.
I pushed this because it worked. I will try more of that tomorrow and push.
@kauffj a more thorough explanation:
ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED
stores claim data instate.claims.claimsByChannel
rewriting the reducer to store the data in
state.content.featuredUris
when requested by the Discover page rather than the Subscriptions page seems like it will add as much code and complexity as my approach of adding 3state.content
properties, 1 action, and 2 reducersif the Discover page is putting featured channels in
state.claims.claimsByChannel
then both featured and subscribed channels will be displayed on the Subscriptions pageand on the Discover page if/when the users goes back
each page could filter out the other's claim data in the view but that seems hackish
not to mention this would also require adding all the subscription fetching code to the discover component, which is a huge mess with the following comment:
// setHasFetchedSubscriptions is a terrible hack // it allows the subscriptions to load correctly when refresing on the subscriptions page // currently the page is rendered before the state is rehyrdated // that causes this component to be rendered with zero savedSubscriptions // we need to wait until persist/REHYDRATE has fired before rendering the page
https://github.com/lbryio/lbry-app/blob/master/src/renderer/page/subscriptions/view.jsx
this is the road I went down--and ran into rendering issues I still haven't figured out--before becoming convinced that treating Featured Channels as its own feature worthy of its own place in the data model was simpler than trying to implement it using functions built for Featured Uris and Subscriptions
I may not need
fetchingFeaturedChannels
and am not yet usingfetchingFeaturedChannelsFailed
so this doesn't need to be a full copy offeaturedUris
's data structure, I was just trying to get something that made sense on here for y'all to look atI am happy to refactor the Subscriptions page but that seems like a bigger issue than Featured Channels
or I could still be missing a simple solution, this part of the app is still new to me
@daovist
Not storing the same data in two different places or two different ways is about as fundamental as it gets when it comes to DRY. It is exceedingly unlikely we'll accept a solution that involves storing the same data in two places or in two different ways (caching for performance reasons is the only exception I can think of).
If a simpler data model comes at the cost of more code that is entirely acceptable.
I suspect there is a misunderstanding (or someone else is doing something very wrong), if data additions to
claimsByChannel
are affecting subscriptions.claimsByChannel
is where all data is stored related to claims in a channel. Accessing any channel page stores data there.I'm not following a lot of your comments. I don't understand how this is related to subscriptions at all. I don't understand what you mean with your comments related to filtering. I strongly suspect this functionality should be doable with 0 additional actions and 0 additional Redux state values.
@kauffj here is a new version based on what you said. It only alters the one action
doFetchFeaturedUris
to calldoFetchClaimsByChannel
and uses existing selectors. All of the new logic is in therender
function ofDiscoverPage
.There are two hardcoded channels added to
Uris
indoFetchFeaturedUris
to demonstrate channels with empty and non-empty arrays, which I will remove if this code is acceptable.Edit: actually, a bunch of the useless code is still in there, but not being used, which I'm removing now...
@daovist great refactor! One more potential improvement.
@ -223,2 +223,4 @@
class DiscoverPage extends React.PureComponent {
constructor(props) {
Can this logic be either moved into
<FeaturedCategory>
and/or moved into a selector that is called by<FeaturedCategory>
?@ -223,2 +223,4 @@
class DiscoverPage extends React.PureComponent {
constructor(props) {
I moved all this logic into
selectDiscover
and am calling it from theDiscover
page and it's working correctly. Calling it from<FeaturedCategory>
doesn't make sense to me because the selector returns an object which is mapped to many<FeaturedCategory>
s in the view.I can kind of see doing to logic for each category separately but I would need to think about it and it doesn't seem like it will be nearly as clean as this.
@liamcardenas / @daovist what's the status on this PR?
@tzarebczan I think it's good to go given that @kauffj is cool with
<DiscoverPage>
the selector rather than the<FeaturedCategory>
and nobody else has any objections
one nuance of this code is it assumes it's getting just the
@channel
and not@channel#claim_id
-- if someone put@channel#claim_id
in the original json it would mess things up, but I could fix this easy enoughI still have two channels hardcoded into the action so others can see the functionality of this branch in dev before we start including channels in the lbry.io API -- happy to take them out when this is merge-ready
@daovist I think an approach where
<FeaturedCategory>
initiates the channel fetches is mildly better, but I won't block over this. (It's better because basically deferring execution until you're in the lowest-level component that needs it results in tighter and more logical coupling. It's also the "React way".)I'm not sure sure why a new selector is necessary either. If a new one is necessary, then presumably
selectFeaturedUris
can be dropped?selectDiscover
usesselectFeaturedUris
I understand what you @kauffj are/were saying much better now and agree. It means leaving the Discover page mostly as it was and grabbing channel data in another selector that uses similar logic to what I've got here
my concern is that changing
<FeaturedCategory>
for channels would affect<SubscriptionsPage>
(also I realize I need to refactor FC into its own top level component either way)
a small thing is the lbry.io API would need the full
@channel#claim_id
which shouldn't be much of an issue since people can copypastaHow are we going to ensure that we don't break the homepage for old versions of the app by returning channel names via the api?
@liamcardenas breaking old app versions is acceptable - upgrading is basically mandatory during the beta.
Can you please:
(1) merge the latest version of master into your branch
(2) do the command
yarn run format
so that the code is properly formattedThanks!
@ -2,11 +2,18 @@ import React from 'react';
import { connect } from 'react-redux';
import { doFetchFeaturedUris } from 'redux/actions/content';
import { selectFeaturedUris, selectFetchingFeaturedUris } from 'redux/selectors/content';
you don't use this
I got rid of the imports and select properties from
/page/discover/index.js
as @liamcardenas requested and that broke the whole thing. I tried putting it back the way it was before I moved the logic in the view render function to its own selector and it worked again. So I worked piece by piece back to how it was when it was working and found that including extra selectors in the index file's select function is the difference between featured channels showing up when they arrive and them not showing (until you click subscriptions and back to discover; if the channel data is already in the state, it's fine, the problem is not triggering cWRP or render whenselectDiscover
updates)working:
fetchingFeaturedUris: selectFetchingFeaturedUris(state), categories: selectDiscover(state), featuredUris: selectFeaturedUris(state), claimsById: selectClaimsById(state), claimsByChannel: selectAllClaimsByChannel(state),
not working:
fetchingFeaturedUris: selectFetchingFeaturedUris(state), categories: selectDiscover(state), // featuredUris: selectFeaturedUris(state), // claimsById: selectClaimsById(state), // claimsByChannel: selectAllClaimsByChannel(state),
the extra selectors aren't even declared in the view's render function:
const { fetchingFeaturedUris, categories } = this.props;
Every time I think I understand React, I find something new and confusing. I'm gonna read react-indepth this evening/tonight and see if this doesn't make more sense tomorrow
I'm also gonna retry the @kauffj approach of calling
doFetchClaimsByChannel
from<FeaturedChannel>
and dealing with an emptynames
propI tested this and it works beautifully! We can consider re-architecting this to request the change in the component, but I think that is a marginal improvement at best.
I made some code suggestions that should keep you busy for a while. Once we get all of those resolved, I will be happy to merge this.
(also please resolve merge conflicts)
Thanks!
@ -10,0 +11,4 @@
categories: selectDiscover(state),
// we shouldn't need these
featuredUris: selectFeaturedUris(state),
if we don't need them, can you take them out?
do you need to split it because you are extracting the channel name from a uri? look into using
parseURI
@ -78,21 +78,25 @@ export function doFetchFeaturedUris() {
});
const success = ({ Uris }) => {
Uris['@LupoTV'] = [];
I appreciate you leaving this in for testing purposes, obviously remove this when it is ready to merge
@ -80,2 +80,4 @@
const success = ({ Uris }) => {
Uris['@LupoTV'] = [];
let urisToResolve = [];
let actions = [];
use const, when possible
@ -0,0 +6,4 @@
[selectFeaturedUris, selectClaimsById, selectAllClaimsByChannel],
(featuredUris, claimsById, claimsByChannel) => {
let categories = featuredUris;
if (!!categories && !!claimsByChannel) {
unnecessary to do
!!
@ -0,0 +14,4 @@
}
});
Object.keys(claimsByChannel).forEach(key => {
if (channels.includes(key)) {
you could take out the other forEach loop if you change this line to
if(categories[key].indexOf('@') === 0)
@ -0,0 +18,4 @@
delete categories[key];
const ids = claimsByChannel[key][1];
let uris = [];
const newKey = `${key}#${claimsById[ids[0]].value.publisherSignature.certificateId}`;
instead of using string interpolation, the proper way to do with is with the
buildURI
function(I know I told you this method was fine earlier, sorry about that)
@ -0,0 +19,4 @@
const ids = claimsByChannel[key][1];
let uris = [];
const newKey = `${key}#${claimsById[ids[0]].value.publisherSignature.certificateId}`;
ids.forEach(id => {
instead of all of these loops, you should learn how to use
map
,reduce
,filter
, etc.i dont think this would block merging, however, here is a rough sketch of how i would do this
and in fact you could even set
this could cut out a lot of this code and make it shorter. It's something you should play around with.
@ -0,0 +22,4 @@
ids.forEach(id => {
const claim = claimsById[id] ? claimsById[id] : null;
if (claim) {
uris.push(`${claim.name}#${claim.claim_id}`);
same here, use buildURI
@ -0,0 +29,4 @@
}
});
}
console.log("select:", categories);
obviously remove when ready to merge :)
dang, i accidentally was looking at this one instead of the other one. In the future, it would be best to close PRs that are no longer relevant. I will close this if I feel the other one is better.
yep, the other one was better.
Pull request closed