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:
parent
deb95cd443
commit
9d830615fd
1 changed files with 39 additions and 47 deletions
|
@ -114,6 +114,9 @@ function checkAuthBusy() {
|
||||||
*/
|
*/
|
||||||
export function doCheckUserOdyseeMemberships(user) {
|
export function doCheckUserOdyseeMemberships(user) {
|
||||||
return async (dispatch) => {
|
return async (dispatch) => {
|
||||||
|
let highestMembershipRanking;
|
||||||
|
|
||||||
|
if (user.odysee_member) {
|
||||||
// get memberships for a given user
|
// get memberships for a given user
|
||||||
// TODO: in the future, can we specify this just to @odysee?
|
// TODO: in the future, can we specify this just to @odysee?
|
||||||
|
|
||||||
|
@ -127,7 +130,6 @@ export function doCheckUserOdyseeMemberships(user) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let savedMemberships = [];
|
let savedMemberships = [];
|
||||||
let highestMembershipRanking;
|
|
||||||
|
|
||||||
// TODO: this will work for now, but it should be adjusted
|
// 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
|
// 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';
|
highestMembershipRanking = 'Premium';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.ADD_ODYSEE_MEMBERSHIP_DATA,
|
type: ACTIONS.ADD_ODYSEE_MEMBERSHIP_DATA,
|
||||||
|
@ -182,10 +185,7 @@ export function doAuthenticate(
|
||||||
data: { user, accessToken: token },
|
data: { user, accessToken: token },
|
||||||
});
|
});
|
||||||
|
|
||||||
// if user is an Odysee member, get the membership details
|
|
||||||
if (user.odysee_member) {
|
|
||||||
dispatch(doCheckUserOdyseeMemberships(user));
|
dispatch(doCheckUserOdyseeMemberships(user));
|
||||||
}
|
|
||||||
|
|
||||||
if (shareUsageData) {
|
if (shareUsageData) {
|
||||||
dispatch(doRewardList());
|
dispatch(doRewardList());
|
||||||
|
@ -218,11 +218,7 @@ export function doUserFetch() {
|
||||||
|
|
||||||
Lbryio.getCurrentUser()
|
Lbryio.getCurrentUser()
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
// get user membership status
|
|
||||||
if (user.odysee_member) {
|
|
||||||
dispatch(doCheckUserOdyseeMemberships(user));
|
dispatch(doCheckUserOdyseeMemberships(user));
|
||||||
}
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.USER_FETCH_SUCCESS,
|
type: ACTIONS.USER_FETCH_SUCCESS,
|
||||||
data: { user },
|
data: { user },
|
||||||
|
@ -243,14 +239,10 @@ export function doUserCheckEmailVerified() {
|
||||||
// This will happen in the background so we don't need loading booleans
|
// This will happen in the background so we don't need loading booleans
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
Lbryio.getCurrentUser().then((user) => {
|
Lbryio.getCurrentUser().then((user) => {
|
||||||
if (user.has_verified_email) {
|
|
||||||
// check premium membership
|
|
||||||
if (user.odysee_member) {
|
|
||||||
dispatch(doCheckUserOdyseeMemberships(user));
|
dispatch(doCheckUserOdyseeMemberships(user));
|
||||||
}
|
|
||||||
|
|
||||||
|
if (user.has_verified_email) {
|
||||||
dispatch(doRewardList());
|
dispatch(doRewardList());
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.USER_FETCH_SUCCESS,
|
type: ACTIONS.USER_FETCH_SUCCESS,
|
||||||
data: { user },
|
data: { user },
|
||||||
|
|
Loading…
Reference in a new issue