fix: correctly refresh cta banner
This commit is contained in:
@@ -386,6 +386,7 @@ class Footer extends AbstractComponent<Props, State> {
|
|||||||
<UpgradeNow
|
<UpgradeNow
|
||||||
application={this.application}
|
application={this.application}
|
||||||
featuresController={this.viewControllerManager.featuresController}
|
featuresController={this.viewControllerManager.featuresController}
|
||||||
|
subscriptionContoller={this.viewControllerManager.subscriptionController}
|
||||||
/>
|
/>
|
||||||
{this.state.showBetaWarning && (
|
{this.state.showBetaWarning && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
import { WebApplication } from '@/Application/Application'
|
import { WebApplication } from '@/Application/Application'
|
||||||
import { FeaturesController } from '@/Controllers/FeaturesController'
|
import { FeaturesController } from '@/Controllers/FeaturesController'
|
||||||
|
import { SubscriptionController } from '@/Controllers/Subscription/SubscriptionController'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { loadPurchaseFlowUrl } from '../PurchaseFlow/PurchaseFlowFunctions'
|
import { loadPurchaseFlowUrl } from '../PurchaseFlow/PurchaseFlowFunctions'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
featuresController: FeaturesController
|
featuresController: FeaturesController
|
||||||
|
subscriptionContoller: SubscriptionController
|
||||||
}
|
}
|
||||||
|
|
||||||
const UpgradeNow = ({ application, featuresController }: Props) => {
|
const UpgradeNow = ({ application, featuresController, subscriptionContoller }: Props) => {
|
||||||
const shouldShowCTA = !featuresController.hasFolders
|
const shouldShowCTA = !featuresController.hasFolders
|
||||||
const hasAccount = application.hasAccount()
|
const hasAccount = subscriptionContoller.hasAccount
|
||||||
|
|
||||||
if (hasAccount && application.hideSubscriptionMarketing) {
|
if (hasAccount && subscriptionContoller.hideSubscriptionMarketing) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,11 @@ const Navigation: FunctionComponent<Props> = ({ application }) => {
|
|||||||
label="Go to items list"
|
label="Go to items list"
|
||||||
icon="chevron-left"
|
icon="chevron-left"
|
||||||
/>
|
/>
|
||||||
<UpgradeNow application={application} featuresController={viewControllerManager.featuresController} />
|
<UpgradeNow
|
||||||
|
application={application}
|
||||||
|
subscriptionContoller={viewControllerManager.subscriptionController}
|
||||||
|
featuresController={viewControllerManager.featuresController}
|
||||||
|
/>
|
||||||
<RoundIconButton
|
<RoundIconButton
|
||||||
className="ml-2.5 bg-default"
|
className="ml-2.5 bg-default"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
SubscriptionClientInterface,
|
SubscriptionClientInterface,
|
||||||
Uuid,
|
Uuid,
|
||||||
} from '@standardnotes/snjs'
|
} from '@standardnotes/snjs'
|
||||||
import { action, computed, makeObservable, observable } from 'mobx'
|
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
|
||||||
import { WebApplication } from '../../Application/Application'
|
import { WebApplication } from '../../Application/Application'
|
||||||
import { AbstractViewController } from '../Abstract/AbstractViewController'
|
import { AbstractViewController } from '../Abstract/AbstractViewController'
|
||||||
import { AvailableSubscriptions } from './AvailableSubscriptionsType'
|
import { AvailableSubscriptions } from './AvailableSubscriptionsType'
|
||||||
@@ -21,6 +21,8 @@ export class SubscriptionController extends AbstractViewController {
|
|||||||
userSubscription: Subscription | undefined = undefined
|
userSubscription: Subscription | undefined = undefined
|
||||||
availableSubscriptions: AvailableSubscriptions | undefined = undefined
|
availableSubscriptions: AvailableSubscriptions | undefined = undefined
|
||||||
subscriptionInvitations: Invitation[] | undefined = undefined
|
subscriptionInvitations: Invitation[] | undefined = undefined
|
||||||
|
hideSubscriptionMarketing: boolean
|
||||||
|
hasAccount: boolean
|
||||||
|
|
||||||
override deinit() {
|
override deinit() {
|
||||||
super.deinit()
|
super.deinit()
|
||||||
@@ -37,11 +39,15 @@ export class SubscriptionController extends AbstractViewController {
|
|||||||
private subscriptionManager: SubscriptionClientInterface,
|
private subscriptionManager: SubscriptionClientInterface,
|
||||||
) {
|
) {
|
||||||
super(application, eventBus)
|
super(application, eventBus)
|
||||||
|
this.hideSubscriptionMarketing = application.hideSubscriptionMarketing
|
||||||
|
this.hasAccount = application.hasAccount()
|
||||||
|
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
userSubscription: observable,
|
userSubscription: observable,
|
||||||
availableSubscriptions: observable,
|
availableSubscriptions: observable,
|
||||||
subscriptionInvitations: observable,
|
subscriptionInvitations: observable,
|
||||||
|
hideSubscriptionMarketing: observable,
|
||||||
|
hasAccount: observable,
|
||||||
|
|
||||||
userSubscriptionName: computed,
|
userSubscriptionName: computed,
|
||||||
userSubscriptionExpirationDate: computed,
|
userSubscriptionExpirationDate: computed,
|
||||||
@@ -61,6 +67,9 @@ export class SubscriptionController extends AbstractViewController {
|
|||||||
this.getSubscriptionInfo().catch(console.error)
|
this.getSubscriptionInfo().catch(console.error)
|
||||||
this.reloadSubscriptionInvitations().catch(console.error)
|
this.reloadSubscriptionInvitations().catch(console.error)
|
||||||
}
|
}
|
||||||
|
runInAction(() => {
|
||||||
|
this.hasAccount = application.hasAccount()
|
||||||
|
})
|
||||||
}, ApplicationEvent.Launched),
|
}, ApplicationEvent.Launched),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -68,6 +77,9 @@ export class SubscriptionController extends AbstractViewController {
|
|||||||
application.addEventObserver(async () => {
|
application.addEventObserver(async () => {
|
||||||
this.getSubscriptionInfo().catch(console.error)
|
this.getSubscriptionInfo().catch(console.error)
|
||||||
this.reloadSubscriptionInvitations().catch(console.error)
|
this.reloadSubscriptionInvitations().catch(console.error)
|
||||||
|
runInAction(() => {
|
||||||
|
this.hasAccount = application.hasAccount()
|
||||||
|
})
|
||||||
}, ApplicationEvent.SignedIn),
|
}, ApplicationEvent.SignedIn),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user