fix(app): gate reworked typing indicators behind an experiment (#2782)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-14 21:54:52 +02:00
1 parent 1861432a53
commit c212d315f4
91 files changed
+6137 -1756

No files matched your search

@@ -60,6 +60,10 @@ import {
type MessageKeyboardFocusConfig,
MessageKeyboardFocusConfigSchema,
} from '@fluxer/schema/src/domains/experiment/MessageKeyboardFocusSchemas';
import {
type TypingIndicatorReworkConfig,
TypingIndicatorReworkConfigSchema,
} from '@fluxer/schema/src/domains/experiment/TypingIndicatorReworkSchemas';
import {
type InstanceAppPublic,
InstanceAppPublicSchema,
@@ -85,6 +89,7 @@ const MESSAGE_KEYBOARD_FOCUS_CONFIG_KEY = 'message_keyboard_focus_config';
const BLOCKED_MESSAGE_GROUPS_CONFIG_KEY = 'blocked_message_groups_config';
const EXPRESSION_INFO_CARD_CONFIG_KEY = 'expression_info_card_config';
const GUILD_HEADER_COLLAPSE_CONFIG_KEY = 'guild_header_collapse_config';
const TYPING_INDICATOR_REWORK_CONFIG_KEY = 'typing_indicator_rework_config';
const REGISTRATION_CONFIG_KEY = 'registration_config';
const REGISTRATION_URLS_KEY = 'registration_urls';
const REGISTRATION_PENDING_APPROVALS_KEY = 'registration_pending_approvals';
@@ -374,6 +379,7 @@ type StoredConfigSection =
| 'blocked message groups'
| 'expression info card'
| 'guild header collapse'
| 'typing indicator rework'
| 'instance policy'
| 'integrations'
| 'media'
@@ -539,6 +545,10 @@ function parseStoredGuildHeaderCollapseConfig(raw: string | null): GuildHeaderCo
return parseStoredConfigOrDefault(GuildHeaderCollapseConfigSchema, raw, 'guild header collapse');
}
function parseStoredTypingIndicatorReworkConfig(raw: string | null): TypingIndicatorReworkConfig {
return parseStoredConfigOrDefault(TypingIndicatorReworkConfigSchema, raw, 'typing indicator rework');
}
function validateStoredCollection<T>(schema: z.ZodType<T>, value: unknown, section: StoredConfigSection): Array<T> {
if (!Array.isArray(value)) {
throw new Error(`Stored ${section} configuration must be an array`);
@@ -1064,6 +1074,7 @@ export class InstanceConfigRepository {
parseStoredBlockedMessageGroupsConfig(snapshot.get(BLOCKED_MESSAGE_GROUPS_CONFIG_KEY) ?? null);
parseStoredExpressionInfoCardConfig(snapshot.get(EXPRESSION_INFO_CARD_CONFIG_KEY) ?? null);
parseStoredGuildHeaderCollapseConfig(snapshot.get(GUILD_HEADER_COLLAPSE_CONFIG_KEY) ?? null);
parseStoredTypingIndicatorReworkConfig(snapshot.get(TYPING_INDICATOR_REWORK_CONFIG_KEY) ?? null);
const policy = parseStoredInstancePolicyConfig(snapshot.get(INSTANCE_POLICY_CONFIG_KEY) ?? null);
checkStoredConfig('registration', () =>
parseStoredRegistrationConfig(snapshot.get(REGISTRATION_CONFIG_KEY) ?? null),
@@ -1213,6 +1224,16 @@ export class InstanceConfigRepository {
await this.setConfig(GUILD_HEADER_COLLAPSE_CONFIG_KEY, JSON.stringify(validated));
}
async getTypingIndicatorReworkConfig(): Promise<TypingIndicatorReworkConfig> {
const raw = await this.getConfig(TYPING_INDICATOR_REWORK_CONFIG_KEY);
return parseStoredTypingIndicatorReworkConfig(raw);
}
async setTypingIndicatorReworkConfig(config: TypingIndicatorReworkConfig): Promise<void> {
const validated = validateStoredConfig(TypingIndicatorReworkConfigSchema, config, 'typing indicator rework');
await this.setConfig(TYPING_INDICATOR_REWORK_CONFIG_KEY, JSON.stringify(validated));
}
async setExperimentDeliveryConfig(config: ExperimentDeliveryConfig): Promise<void> {
const validated = validateStoredConfig(ExperimentDeliveryConfigSchema, config, 'experiment delivery');
await this.setConfig(EXPERIMENT_DELIVERY_CONFIG_KEY, JSON.stringify(validated));