-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal subscriptions #1424
Internal subscriptions #1424
Conversation
b8f568e
to
0331298
Compare
0331298
to
019d6e2
Compare
8611169
to
a22813b
Compare
}; | ||
|
||
class Page extends React.PureComponent<Props, State> { | ||
static getDerivedStateFromProps(nextProps: Props, prevState: State) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React recommends getDerivedStateFromProps
moving forward instead of componentWillReceiveProps
@@ -34,6 +34,7 @@ | |||
"singleQuote": true | |||
}], | |||
"func-names": ["warn", "as-needed"], | |||
"jsx-a11y/label-has-for": 0 | |||
"jsx-a11y/label-has-for": 0, | |||
"import/prefer-default-export": 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this isn't needed. Mostly for util files, I don't want to add the first one as a default export if I think there may be more functions added later.
}; | ||
|
||
export const doChannelUnsubscribe = (subscription: Subscription) => (dispatch: Dispatch) => { | ||
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't touch this, lint was telling me to move it
@@ -114,40 +228,80 @@ export const doCheckSubscription = (subscription: Subscription, notify?: boolean | |||
}); | |||
}; | |||
|
|||
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => ( | |||
export const setSubscriptionNotifications = (notifications: SubscriptionNotifications) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, just re-ordering
} | ||
}; | ||
|
||
export const doCheckSubscriptions = () => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this, just moved it
a22813b
to
1fe95ce
Compare
f7737a6
to
e301f64
Compare
4bdd51f
to
2a3003d
Compare
22c8a8f
to
87026c8
Compare
@kauffj ready for more feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very close.
@@ -166,6 +166,9 @@ export const SET_SUBSCRIPTION_NOTIFICATIONS = 'SET_SUBSCRIPTION_NOTIFICATIONS'; | |||
export const CHECK_SUBSCRIPTION_STARTED = 'CHECK_SUBSCRIPTION_STARTED'; | |||
export const CHECK_SUBSCRIPTION_COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED'; | |||
export const CHECK_SUBSCRIPTIONS_SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE'; | |||
export const FETCH_MY_SUBSCRIPTIONS_START = 'FETCH_MY_SUBSCRIPTIONS_START'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanyesmunt this is fine for now. My suggestion for that case would be to de-couple noticing new subscriptions from downloading or to add an auto-download setting that can default to a different value for desktop vs. mobile.
(@akinwale )
src/renderer/constants/settings.js
Outdated
@@ -11,4 +11,6 @@ export const INSTANT_PURCHASE_ENABLED = 'instantPurchaseEnabled'; | |||
export const INSTANT_PURCHASE_MAX = 'instantPurchaseMax'; | |||
export const THEME = 'theme'; | |||
export const THEMES = 'themes'; | |||
export const DARK_THEME = 'dark'; | |||
export const LIGHT_THEME = 'light'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently these values are setting keys not setting values. It's a good idea to const these theme values, but we ought to do this in a way that retains that distinction.
type: ACTIONS.CHANNEL_SUBSCRIBE, | ||
data: subscription, | ||
}); | ||
const getClaimId = uri => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use parseURI
?
|
||
// Actual claim type has more values than this | ||
// Add them as they are used | ||
export type Claim = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Subscription
also be a standalone type file like Claim
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
storedSubscriptions.forEach(sub => { | ||
if (!reduxSubMap[sub.claim_id]) { | ||
const uri = `lbry://${sub.channel_name}#${sub.claim_id}`; | ||
subscriptionsToReturn.push({ uri, channelName: sub.channel_name }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mildly surprised this works. If subscriptionsToReturn
is an array of Subscription
, doesn't this need to include the latest
property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest
isn't required. It will populate it in doCheckSubscriptions
. We are just adding them to redux, which is where it looks when it's checking for the latest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly sure this is my misunderstanding, but I still don't understand why Flow type checking wouldn't be forcing storedSubscriptions
to be Array<Subscription>
and thus require the latest
property.
(Going to merge anyway, but if you know the answer would appreciate the education :) )
@@ -166,6 +176,9 @@ export const SET_SUBSCRIPTION_NOTIFICATIONS = 'SET_SUBSCRIPTION_NOTIFICATIONS'; | |||
export const CHECK_SUBSCRIPTION_STARTED = 'CHECK_SUBSCRIPTION_STARTED'; | |||
export const CHECK_SUBSCRIPTION_COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED'; | |||
export const CHECK_SUBSCRIPTIONS_SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE'; | |||
export const FETCH_MY_SUBSCRIPTIONS_START = 'FETCH_MY_SUBSCRIPTIONS_START'; | |||
export const FETCH_MY_SUBSCRIPTIONS_FAIL = 'FETCH_MY_SUBSCRIPTIONS_FAIL'; | |||
export const FETCH_MY_SUBSCRIPTIONS_SUCCESS = 'FETCH_MY_SUBSCRIPTIONS_SUCCESS'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we drop MY
from these? Or let me know what additional clarity it is providing if you think it should remain.
|
||
// There is some mismatch between redux state and db state | ||
// If something is in the db, but not in redux, add it to redux | ||
// If something is in redux, but not in the db, add it to the db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the most reasonable choice and that we can't (or shouldn't) do anything differently immediately, but I also think it's guaranteed that this will cause a bug or confusion in the future.
update subscription types update changelog Simplify subscriptions sync logic add claim type use let over const change spinner color based on theme clean up subscriptions
101f135
to
492b160
Compare
Adds subscriptions to our internal-api database
Notes
Ideally this should live in
lbry-redux
. It seems like there is still some work movinglbry.call
over, mostly with auth stuff. And we need to figure out how we want to interact between app code and lbry-redux code. Currently the the subscriptions actions we are usingdoPurchaseUri
which doesn't exist inlbry-redux
. It shouldn't be too difficult to move over, but will just take some planning. I thought it was out of the scope for this PR.Implementation
There are 3 main scenarios that cause some extra logic re: respecting users privacy. If a user decides not to share app usage, we will not make any calls to the db. If they are sharing data with us, this is what happens: