fix: correctly refresh cta banner

This commit is contained in:
Mo
2022-11-03 06:35:06 -05:00
parent dc4530b2f3
commit 305ffdf984
4 changed files with 24 additions and 5 deletions

View File

@@ -386,6 +386,7 @@ class Footer extends AbstractComponent<Props, State> {
<UpgradeNow
application={this.application}
featuresController={this.viewControllerManager.featuresController}
subscriptionContoller={this.viewControllerManager.subscriptionController}
/>
{this.state.showBetaWarning && (
<Fragment>

View File

@@ -1,18 +1,20 @@
import { WebApplication } from '@/Application/Application'
import { FeaturesController } from '@/Controllers/FeaturesController'
import { SubscriptionController } from '@/Controllers/Subscription/SubscriptionController'
import { observer } from 'mobx-react-lite'
import { loadPurchaseFlowUrl } from '../PurchaseFlow/PurchaseFlowFunctions'
type Props = {
application: WebApplication
featuresController: FeaturesController
subscriptionContoller: SubscriptionController
}
const UpgradeNow = ({ application, featuresController }: Props) => {
const UpgradeNow = ({ application, featuresController, subscriptionContoller }: Props) => {
const shouldShowCTA = !featuresController.hasFolders
const hasAccount = application.hasAccount()
const hasAccount = subscriptionContoller.hasAccount
if (hasAccount && application.hideSubscriptionMarketing) {
if (hasAccount && subscriptionContoller.hideSubscriptionMarketing) {
return null
}

View File

@@ -69,7 +69,11 @@ const Navigation: FunctionComponent<Props> = ({ application }) => {
label="Go to items list"
icon="chevron-left"
/>
<UpgradeNow application={application} featuresController={viewControllerManager.featuresController} />
<UpgradeNow
application={application}
subscriptionContoller={viewControllerManager.subscriptionController}
featuresController={viewControllerManager.featuresController}
/>
<RoundIconButton
className="ml-2.5 bg-default"
onClick={() => {

View File

@@ -9,7 +9,7 @@ import {
SubscriptionClientInterface,
Uuid,
} from '@standardnotes/snjs'
import { action, computed, makeObservable, observable } from 'mobx'
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
import { WebApplication } from '../../Application/Application'
import { AbstractViewController } from '../Abstract/AbstractViewController'
import { AvailableSubscriptions } from './AvailableSubscriptionsType'
@@ -21,6 +21,8 @@ export class SubscriptionController extends AbstractViewController {
userSubscription: Subscription | undefined = undefined
availableSubscriptions: AvailableSubscriptions | undefined = undefined
subscriptionInvitations: Invitation[] | undefined = undefined
hideSubscriptionMarketing: boolean
hasAccount: boolean
override deinit() {
super.deinit()
@@ -37,11 +39,15 @@ export class SubscriptionController extends AbstractViewController {
private subscriptionManager: SubscriptionClientInterface,
) {
super(application, eventBus)
this.hideSubscriptionMarketing = application.hideSubscriptionMarketing
this.hasAccount = application.hasAccount()
makeObservable(this, {
userSubscription: observable,
availableSubscriptions: observable,
subscriptionInvitations: observable,
hideSubscriptionMarketing: observable,
hasAccount: observable,
userSubscriptionName: computed,
userSubscriptionExpirationDate: computed,
@@ -61,6 +67,9 @@ export class SubscriptionController extends AbstractViewController {
this.getSubscriptionInfo().catch(console.error)
this.reloadSubscriptionInvitations().catch(console.error)
}
runInAction(() => {
this.hasAccount = application.hasAccount()
})
}, ApplicationEvent.Launched),
)
@@ -68,6 +77,9 @@ export class SubscriptionController extends AbstractViewController {
application.addEventObserver(async () => {
this.getSubscriptionInfo().catch(console.error)
this.reloadSubscriptionInvitations().catch(console.error)
runInAction(() => {
this.hasAccount = application.hasAccount()
})
}, ApplicationEvent.SignedIn),
)