Fix user membership state for incognito.

Run the membership reducer even for incognito.

The GUI needs to differentiate between 'unfetched' (`undefined`) and 'no membership' (`''`), so we must call the action/reducer for the incognito case as well.
This commit is contained in:
infinite-persistence 2022-05-30 18:53:42 +08:00
parent deb95cd443
commit 9d830615fd
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -114,6 +114,9 @@ function checkAuthBusy() {
*/
export function doCheckUserOdyseeMemberships(user) {
return async (dispatch) => {
let highestMembershipRanking;
if (user.odysee_member) {
// get memberships for a given user
// TODO: in the future, can we specify this just to @odysee?
@ -127,7 +130,6 @@ export function doCheckUserOdyseeMemberships(user) {
);
let savedMemberships = [];
let highestMembershipRanking;
// TODO: this will work for now, but it should be adjusted
// TODO: to check if it's active, or if it's cancelled if it's still valid past current date
@ -151,6 +153,7 @@ export function doCheckUserOdyseeMemberships(user) {
highestMembershipRanking = 'Premium';
}
}
}
dispatch({
type: ACTIONS.ADD_ODYSEE_MEMBERSHIP_DATA,
@ -182,10 +185,7 @@ export function doAuthenticate(
data: { user, accessToken: token },
});
// if user is an Odysee member, get the membership details
if (user.odysee_member) {
dispatch(doCheckUserOdyseeMemberships(user));
}
if (shareUsageData) {
dispatch(doRewardList());
@ -218,11 +218,7 @@ export function doUserFetch() {
Lbryio.getCurrentUser()
.then((user) => {
// get user membership status
if (user.odysee_member) {
dispatch(doCheckUserOdyseeMemberships(user));
}
dispatch({
type: ACTIONS.USER_FETCH_SUCCESS,
data: { user },
@ -243,14 +239,10 @@ export function doUserCheckEmailVerified() {
// This will happen in the background so we don't need loading booleans
return (dispatch) => {
Lbryio.getCurrentUser().then((user) => {
if (user.has_verified_email) {
// check premium membership
if (user.odysee_member) {
dispatch(doCheckUserOdyseeMemberships(user));
}
if (user.has_verified_email) {
dispatch(doRewardList());
dispatch({
type: ACTIONS.USER_FETCH_SUCCESS,
data: { user },