Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { getFeatureFlag, setFeatureFlag } from "~/utils/manageFeatureFlag";
import { type FeatureFlags } from "~/utils/zodSchemaForSettings";
import {
getFeatureFlag,
setFeatureFlag,
} from "~/utils/Settings/accessors";
import { type FeatureFlags } from "~/utils/Settings/zodSchema";
import { Checkbox } from "@blueprintjs/core";
import Description from "roamjs-components/components/Description";
import idToTitle from "roamjs-components/util/idToTitle";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import getBlockProps, { type json } from "./getBlockProps";
import getBlockProps, { type json } from "../getBlockProps";
import getBlockUidByTextOnPage from "roamjs-components/queries/getBlockUidByTextOnPage";
import setBlockProps from "./setBlockProps";
import { DG_BLOCK_PROP_SETTINGS_PAGE_TITLE } from "~/data/blockPropsSettingsConfig";
import setBlockProps from "../setBlockProps";
import { DG_BLOCK_PROP_SETTINGS_PAGE_TITLE, TOP_LEVEL_BLOCK_PROP_KEYS } from "~/data/blockPropsSettingsConfig";
import z from "zod";
import { FeatureFlags, FeatureFlagsSchema } from "./zodSchema";

export const getBlockPropBasedSettings = ({
keys,
Expand Down Expand Up @@ -100,3 +102,30 @@ export const setBlockPropBasedSettings = ({

setBlockProps(blockUid, updatedProps, true);
};


export const getFeatureFlag = (key: keyof FeatureFlags): boolean => {
const featureFlagKey = TOP_LEVEL_BLOCK_PROP_KEYS.featureFlags;

const { blockProps } = getBlockPropBasedSettings({
keys: [featureFlagKey],
});

const flags = FeatureFlagsSchema.parse(blockProps || {});

return flags[key];
};

export const setFeatureFlag = (
key: keyof FeatureFlags,
value: boolean,
): void => {
const featureFlagKey = TOP_LEVEL_BLOCK_PROP_KEYS.featureFlags;

const validatedValue = z.boolean().parse(value);

void setBlockPropBasedSettings({
keys: [featureFlagKey, key],
value: validatedValue,
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TOP_LEVEL_BLOCK_PROP_KEYS } from "~/data/blockPropsSettingsConfig";
import { json, normalizeProps } from "./getBlockProps";
import { json, normalizeProps } from "~/utils/getBlockProps";

export const setupPullWatchBlockPropsBasedSettings = (
blockUids: Record<string, string>,
Expand Down
6 changes: 3 additions & 3 deletions apps/roam/src/utils/initializeObserversAndListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ import {
import { getCleanTagText } from "~/components/settings/NodeConfig";
import getPleasingColors from "@repo/utils/getPleasingColors";
import { colord } from "colord";
import { getFeatureFlag } from "./manageFeatureFlag";
import { setupPullWatchBlockPropsBasedSettings } from "./pullWatchBlockPropsBasedSettings";
import { initSchema } from "./initBlockPropSettings";
import { getFeatureFlag } from "./Settings/accessors";
import { setupPullWatchBlockPropsBasedSettings } from "~/utils/Settings/pullWatch";
import { initSchema } from "./Settings/init";

const debounce = (fn: () => void, delay = 250) => {
let timeout: number;
Expand Down
33 changes: 0 additions & 33 deletions apps/roam/src/utils/manageFeatureFlag.ts

This file was deleted.