mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(premium): reflect limit config flags in plan comparisons (#3319)
This commit is contained in:
1 parent
acc1392a53
commit
94f1239050
4 files changed
+49
-8
No files matched your search
+8
-4
@@ -139,8 +139,10 @@ export const FeatureComparisonTable = observer(() => {
|
|||||||
<ComparisonCheckRow
|
<ComparisonCheckRow
|
||||||
key={perk.id}
|
key={perk.id}
|
||||||
feature={label}
|
feature={label}
|
||||||
restrictedHas={perk.restrictedValue}
|
restrictedHas={
|
||||||
stockHas={perk.stockValue}
|
perk.limitKey ? Limits.hasRestrictedFeature(perk.limitKey, perk.restrictedValue) : perk.restrictedValue
|
||||||
|
}
|
||||||
|
stockHas={perk.limitKey ? Limits.hasStockFeature(perk.limitKey, perk.stockValue) : perk.stockValue}
|
||||||
data-flx="app.feature-comparison-table.render-perk-row.comparison-check-row"
|
data-flx="app.feature-comparison-table.render-perk-row.comparison-check-row"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -157,9 +159,11 @@ export const FeatureComparisonTable = observer(() => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (isTextTierPerk(perk)) {
|
if (isTextTierPerk(perk)) {
|
||||||
const restrictedLabel =
|
const lowLabel =
|
||||||
perkLabels[perk.restrictedValueI18nKey as keyof typeof perkLabels] || perk.restrictedValueI18nKey;
|
perkLabels[perk.restrictedValueI18nKey as keyof typeof perkLabels] || perk.restrictedValueI18nKey;
|
||||||
const stockLabel = perkLabels[perk.stockValueI18nKey as keyof typeof perkLabels] || perk.stockValueI18nKey;
|
const highLabel = perkLabels[perk.stockValueI18nKey as keyof typeof perkLabels] || perk.stockValueI18nKey;
|
||||||
|
const restrictedLabel = perk.limitKey && Limits.hasRestrictedFeature(perk.limitKey, false) ? highLabel : lowLabel;
|
||||||
|
const stockLabel = !perk.limitKey || Limits.hasStockFeature(perk.limitKey, true) ? highLabel : lowLabel;
|
||||||
return (
|
return (
|
||||||
<ComparisonRow
|
<ComparisonRow
|
||||||
key={perk.id}
|
key={perk.id}
|
||||||
|
|||||||
@@ -102,6 +102,14 @@ class LimitsClass {
|
|||||||
return LimitResolver.resolveFree(key, fallback);
|
return LimitResolver.resolveFree(key, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasStockFeature(key: LimitKey, fallback: boolean): boolean {
|
||||||
|
return this.getStockValue(key, fallback ? 1 : 0) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasRestrictedFeature(key: LimitKey, fallback: boolean): boolean {
|
||||||
|
return this.getRestrictedValue(key, fallback ? 1 : 0) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
getPremiumValue(key: LimitKey, fallback: number): number {
|
getPremiumValue(key: LimitKey, fallback: number): number {
|
||||||
return this.getStockValue(key, fallback);
|
return this.getStockValue(key, fallback);
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-4
@@ -127,8 +127,16 @@ function buildRows(locale: string, translate: (descriptor: MessageDescriptor) =>
|
|||||||
id: perk.id,
|
id: perk.id,
|
||||||
icon: definition.icon,
|
icon: definition.icon,
|
||||||
label: definition.label,
|
label: definition.label,
|
||||||
free: {kind: 'boolean', value: perk.restrictedValue},
|
free: {
|
||||||
premium: {kind: 'boolean', value: perk.stockValue},
|
kind: 'boolean',
|
||||||
|
value: perk.limitKey
|
||||||
|
? Limits.hasRestrictedFeature(perk.limitKey, perk.restrictedValue)
|
||||||
|
: perk.restrictedValue,
|
||||||
|
},
|
||||||
|
premium: {
|
||||||
|
kind: 'boolean',
|
||||||
|
value: perk.limitKey ? Limits.hasStockFeature(perk.limitKey, perk.stockValue) : perk.stockValue,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -142,12 +150,24 @@ function buildRows(locale: string, translate: (descriptor: MessageDescriptor) =>
|
|||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const freeHasHighQuality = perk.limitKey ? Limits.hasRestrictedFeature(perk.limitKey, false) : false;
|
||||||
|
const premiumHasHighQuality = perk.limitKey ? Limits.hasStockFeature(perk.limitKey, true) : true;
|
||||||
rows.push({
|
rows.push({
|
||||||
id: perk.id,
|
id: perk.id,
|
||||||
icon: definition.icon,
|
icon: definition.icon,
|
||||||
label: definition.label,
|
label: definition.label,
|
||||||
free: {kind: 'text', value: translate(PERK_VIDEO_QUALITY_FREE_DESCRIPTOR)},
|
free: {
|
||||||
premium: {kind: 'text', value: translate(PERK_VIDEO_QUALITY_PREMIUM_DESCRIPTOR)},
|
kind: 'text',
|
||||||
|
value: translate(
|
||||||
|
freeHasHighQuality ? PERK_VIDEO_QUALITY_PREMIUM_DESCRIPTOR : PERK_VIDEO_QUALITY_FREE_DESCRIPTOR,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
premium: {
|
||||||
|
kind: 'text',
|
||||||
|
value: translate(
|
||||||
|
premiumHasHighQuality ? PERK_VIDEO_QUALITY_PREMIUM_DESCRIPTOR : PERK_VIDEO_QUALITY_FREE_DESCRIPTOR,
|
||||||
|
),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export interface BooleanTierPerk extends BasePerk {
|
|||||||
type: 'boolean';
|
type: 'boolean';
|
||||||
restrictedValue: boolean;
|
restrictedValue: boolean;
|
||||||
stockValue: boolean;
|
stockValue: boolean;
|
||||||
|
limitKey?: LimitKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NumericTierPerk extends BasePerk {
|
export interface NumericTierPerk extends BasePerk {
|
||||||
@@ -30,6 +31,7 @@ export interface TextTierPerk extends BasePerk {
|
|||||||
type: 'text';
|
type: 'text';
|
||||||
restrictedValueI18nKey: string;
|
restrictedValueI18nKey: string;
|
||||||
stockValueI18nKey: string;
|
stockValueI18nKey: string;
|
||||||
|
limitKey?: LimitKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LimitTierPerk = BooleanTierPerk | NumericTierPerk | TextTierPerk;
|
export type LimitTierPerk = BooleanTierPerk | NumericTierPerk | TextTierPerk;
|
||||||
@@ -54,6 +56,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'custom_4_digit_username_tag',
|
i18nKey: 'custom_4_digit_username_tag',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_custom_discriminator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'per_guild_profiles',
|
id: 'per_guild_profiles',
|
||||||
@@ -62,6 +65,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'per_community_profiles',
|
i18nKey: 'per_community_profiles',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_per_guild_profiles',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'profile_badge',
|
id: 'profile_badge',
|
||||||
@@ -88,6 +92,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'entrance_sounds',
|
i18nKey: 'entrance_sounds',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_voice_entrance_sounds',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'max_guilds',
|
id: 'max_guilds',
|
||||||
@@ -154,6 +159,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'global_emoji_sticker_access',
|
i18nKey: 'global_emoji_sticker_access',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_global_expressions',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'video_quality',
|
id: 'video_quality',
|
||||||
@@ -162,6 +168,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'video_quality',
|
i18nKey: 'video_quality',
|
||||||
restrictedValueI18nKey: 'video_quality_restricted',
|
restrictedValueI18nKey: 'video_quality_restricted',
|
||||||
stockValueI18nKey: 'video_quality_stock',
|
stockValueI18nKey: 'video_quality_stock',
|
||||||
|
limitKey: 'feature_higher_video_quality',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'animated_profile',
|
id: 'animated_profile',
|
||||||
@@ -170,6 +177,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'animated_avatars_and_banners',
|
i18nKey: 'animated_avatars_and_banners',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_animated_avatar',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'early_access',
|
id: 'early_access',
|
||||||
@@ -178,6 +186,7 @@ export const LIMIT_TIER_PERKS: ReadonlyArray<LimitTierPerk> = [
|
|||||||
i18nKey: 'early_access',
|
i18nKey: 'early_access',
|
||||||
restrictedValue: false,
|
restrictedValue: false,
|
||||||
stockValue: true,
|
stockValue: true,
|
||||||
|
limitKey: 'feature_early_access',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'custom_themes',
|
id: 'custom_themes',
|
||||||
|
|||||||
Reference in new issue
Block a user