feat: iap (#1996)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { WebApplication } from '@/Application/Application'
|
||||
import { PremiumFeatureModalType } from '@/Components/PremiumFeaturesModal/PremiumFeatureModalType'
|
||||
import { destroyAllObjectProperties } from '@/Utils'
|
||||
import {
|
||||
ApplicationEvent,
|
||||
@@ -16,6 +17,7 @@ export class FeaturesController extends AbstractViewController {
|
||||
hasSmartViews: boolean
|
||||
hasFiles: boolean
|
||||
premiumAlertFeatureName: string | undefined
|
||||
premiumAlertType: PremiumFeatureModalType | undefined = undefined
|
||||
|
||||
override deinit() {
|
||||
super.deinit()
|
||||
@@ -25,6 +27,7 @@ export class FeaturesController extends AbstractViewController {
|
||||
;(this.hasSmartViews as unknown) = undefined
|
||||
;(this.hasFiles as unknown) = undefined
|
||||
;(this.premiumAlertFeatureName as unknown) = undefined
|
||||
;(this.premiumAlertType as unknown) = undefined
|
||||
|
||||
destroyAllObjectProperties(this)
|
||||
}
|
||||
@@ -43,10 +46,11 @@ export class FeaturesController extends AbstractViewController {
|
||||
hasFolders: observable,
|
||||
hasSmartViews: observable,
|
||||
hasFiles: observable,
|
||||
|
||||
premiumAlertType: observable,
|
||||
premiumAlertFeatureName: observable,
|
||||
showPremiumAlert: action,
|
||||
closePremiumAlert: action,
|
||||
showPurchaseSuccessAlert: action,
|
||||
})
|
||||
|
||||
this.showPremiumAlert = this.showPremiumAlert.bind(this)
|
||||
@@ -55,6 +59,9 @@ export class FeaturesController extends AbstractViewController {
|
||||
this.disposers.push(
|
||||
application.addEventObserver(async (event) => {
|
||||
switch (event) {
|
||||
case ApplicationEvent.DidPurchaseSubscription:
|
||||
this.showPurchaseSuccessAlert()
|
||||
break
|
||||
case ApplicationEvent.FeaturesUpdated:
|
||||
case ApplicationEvent.Launched:
|
||||
runInAction(() => {
|
||||
@@ -76,11 +83,17 @@ export class FeaturesController extends AbstractViewController {
|
||||
|
||||
public async showPremiumAlert(featureName: string): Promise<void> {
|
||||
this.premiumAlertFeatureName = featureName
|
||||
return when(() => this.premiumAlertFeatureName === undefined)
|
||||
this.premiumAlertType = PremiumFeatureModalType.UpgradePrompt
|
||||
|
||||
return when(() => this.premiumAlertType === undefined)
|
||||
}
|
||||
|
||||
showPurchaseSuccessAlert = () => {
|
||||
this.premiumAlertType = PremiumFeatureModalType.UpgradeSuccess
|
||||
}
|
||||
|
||||
public closePremiumAlert() {
|
||||
this.premiumAlertFeatureName = undefined
|
||||
this.premiumAlertType = undefined
|
||||
}
|
||||
|
||||
private isEntitledToFiles(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user