2022-11-28 22:57:27 +00:00
|
|
|
import { STORAGE_KEY_FEATURE_FLAGS } from '~/constants'
|
|
|
|
|
|
|
|
export interface FeatureFlags {
|
|
|
|
experimentalVirtualScroll: boolean
|
2022-12-06 11:07:17 +00:00
|
|
|
experimentalAvatarOnAvatar: boolean
|
2022-11-28 22:57:27 +00:00
|
|
|
}
|
|
|
|
export type FeatureFlagsMap = Record<string, FeatureFlags>
|
|
|
|
|
|
|
|
export function getDefaultFeatureFlags(): FeatureFlags {
|
|
|
|
return {
|
|
|
|
experimentalVirtualScroll: false,
|
2022-12-06 11:07:17 +00:00
|
|
|
experimentalAvatarOnAvatar: true,
|
2022-11-28 22:57:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-13 13:22:27 +00:00
|
|
|
export const currentUserFeatureFlags = useUserLocalStorage(STORAGE_KEY_FEATURE_FLAGS, getDefaultFeatureFlags)
|
2022-11-28 22:57:27 +00:00
|
|
|
|
|
|
|
export function useFeatureFlags() {
|
|
|
|
const featureFlags = currentUserFeatureFlags.value
|
|
|
|
|
|
|
|
return featureFlags
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleFeatureFlag(key: keyof FeatureFlags) {
|
|
|
|
const featureFlags = currentUserFeatureFlags.value
|
|
|
|
|
|
|
|
if (featureFlags[key])
|
|
|
|
featureFlags[key] = !featureFlags[key]
|
|
|
|
else
|
|
|
|
featureFlags[key] = true
|
|
|
|
}
|