Skip to content

Commit

Permalink
[ios] Prevent family option from being shown under features
Browse files Browse the repository at this point in the history
We cannot offer this as a feature to iOS users due to limitations with
iOS subscriptions.

Closes #7195
  • Loading branch information
paw-hub authored and charlag committed Sep 2, 2024
1 parent 47f031a commit 1ee3a26
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/common/subscription/FeatureListProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import Stream from "mithril/stream"
import { PlanPrices } from "../api/entities/sys/TypeRefs"
import { TranslationKey } from "../misc/LanguageViewModel"
import { PaymentInterval } from "./PriceUtils.js"
import { PlanName, PlanType, PlanTypeToName } from "../api/common/TutanotaConstants.js"
import { AvailablePlans, PlanName, PlanType, PlanTypeToName } from "../api/common/TutanotaConstants.js"
import { downcast, getFromMap } from "@tutao/tutanota-utils"
import { isIOSApp } from "../api/common/Env.js"

let dataProvider: FeatureListProvider | null = null

const IOS_EXCLUDED_FEATURES: TranslationKey[] = ["pricing.family_label"]

export class FeatureListProvider {
private featureList: FeatureLists | null = null

Expand All @@ -17,6 +20,9 @@ export class FeatureListProvider {
const listResourceUrl = `${this.domainConfig.websiteBaseUrl}/resources/data/features.json`
try {
const featureList = await fetch(listResourceUrl).then((r) => r.json())
if (isIOSApp()) {
this.stripUnsupportedIosFeatures(featureList)
}
this.countFeatures([...featureList.Free.categories, ...featureList.Revolutionary.categories, ...featureList.Legend.categories])
this.countFeatures([...featureList.Essential.categories, ...featureList.Advanced.categories, ...featureList.Unlimited.categories])
this.featureList = featureList
Expand Down Expand Up @@ -60,6 +66,22 @@ export class FeatureListProvider {
featureLoadingDone(): boolean {
return this.featureList != null
}

/**
* Remove features from the feature list that are unsupported for iOS and shouldn't be displayed to iOS users.
* @param featureList feature list obtained from the server
* @private
*/
private stripUnsupportedIosFeatures(featureList: any) {
for (const plan of AvailablePlans) {
const features: { categories: FeatureCategory[] } = featureList[PlanTypeToName[plan]]
for (const category of features.categories) {
category.features = category.features.filter(({ text }) => {
return !IOS_EXCLUDED_FEATURES.includes(text)
})
}
}
}
}

/**
Expand Down

0 comments on commit 1ee3a26

Please sign in to comment.