-
Notifications
You must be signed in to change notification settings - Fork 7
ENG-2173 Enable props-based settings by default #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import { | |
| migrateGraphLevel, | ||
| migratePersonalSettings, | ||
| } from "./migrateLegacyToBlockProps"; | ||
| import { migratePropsStoreDefault } from "./migratePropsStoreDefault"; | ||
| import { getTopLevelBlockPropsConfig } from "~/components/settings/utils/zodSchema"; | ||
| import { DG_BLOCK_PROP_SETTINGS_PAGE_TITLE } from "./zodSchema"; | ||
| import toFlexRegex from "roamjs-components/util/toFlexRegex"; | ||
|
|
@@ -376,8 +377,11 @@ export const initSchema = async (): Promise<InitSchemaResult> => { | |
| refreshConfigTree(); | ||
| } | ||
|
|
||
| await migrateGraphLevel(blockUids); | ||
| await migratePersonalSettings(blockUids); | ||
| const graphSettingsMigrated = await migrateGraphLevel(blockUids); | ||
| const personalSettingsMigrated = await migratePersonalSettings(blockUids); | ||
| if (graphSettingsMigrated && personalSettingsMigrated) { | ||
| await migratePropsStoreDefault(blockUids); | ||
|
mdroidian marked this conversation as resolved.
Comment on lines
+382
to
+383
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In a shared graph, once the first user reaches this call, Useful? React with 👍 / 👎. |
||
| } | ||
| (window as unknown as Record<string, unknown>).dgDualReadLog = | ||
| logDualReadComparison; | ||
| return { blockUids, nodePageUids: {} }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import getBlockProps from "~/utils/getBlockProps"; | ||
| import { setBlockPropsAsync } from "~/utils/setBlockProps"; | ||
| import internalError from "~/utils/internalError"; | ||
| import { invalidateDiscourseNodeTypeCaches } from "~/utils/discourseNodeTypeCache"; | ||
| import { FEATURE_FLAG_KEYS } from "./settingKeys"; | ||
| import { STATIC_TOP_LEVEL_ENTRIES } from "./zodSchema"; | ||
|
|
||
| const LOG_PREFIX = "[DG Props Default Migration]"; | ||
| export const PROPS_STORE_DEFAULT_MIGRATION_KEY = | ||
| "Props settings default migrated"; | ||
|
|
||
| export const migratePropsStoreDefault = async ( | ||
| blockUids: Record<string, string>, | ||
| ): Promise<void> => { | ||
| const featureFlagsUid = blockUids[STATIC_TOP_LEVEL_ENTRIES.featureFlags.key]; | ||
|
|
||
| if (!featureFlagsUid) { | ||
| internalError({ | ||
| error: "Cannot enable props-based settings by default", | ||
| type: "DG Props Default Migration", | ||
| context: { featureFlagsUid }, | ||
| sendEmail: false, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const featureFlags = getBlockProps(featureFlagsUid); | ||
| if (featureFlags[PROPS_STORE_DEFAULT_MIGRATION_KEY] === true) { | ||
| console.log(`${LOG_PREFIX} skipped (already migrated)`); | ||
| return; | ||
| } | ||
|
|
||
| const propsStoreAlreadyEnabled = | ||
| featureFlags[FEATURE_FLAG_KEYS.useNewSettingsStore] === true; | ||
| await setBlockPropsAsync( | ||
| featureFlagsUid, | ||
| { | ||
| [PROPS_STORE_DEFAULT_MIGRATION_KEY]: true, | ||
| ...(propsStoreAlreadyEnabled | ||
| ? {} | ||
| : { [FEATURE_FLAG_KEYS.useNewSettingsStore]: true }), | ||
| }, | ||
| false, | ||
| ); | ||
|
|
||
| if (!propsStoreAlreadyEnabled) { | ||
| invalidateDiscourseNodeTypeCaches(); | ||
| } | ||
| console.log(`${LOG_PREFIX} completed`); | ||
| } catch (error) { | ||
| internalError({ | ||
| error, | ||
| type: "DG Props Default Migration", | ||
| context: { featureFlagsUid }, | ||
| sendEmail: false, | ||
| }); | ||
| } | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.