Skip to content

Commit

Permalink
Add backwards compatibility for px size preferences saved
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhabib committed Sep 11, 2024
1 parent 8e50103 commit b7c41ca
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/StoreContext/StoreContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ export const StoreProvider = ({
Promise.all([
store.getItem<string>('code'),
store.getItem<EditorPosition>('editorPosition'),
store.getItem<number>('editorHeight'), // Deprecated
store.getItem<number>('editorWidth'), // Deprecated
store.getItem<string>('editorHeightPercentage'),
store.getItem<string>('editorWidthPercentage'),
store.getItem<number[]>('visibleWidths'),
Expand All @@ -490,27 +492,37 @@ export const StoreProvider = ({
([
storedCode,
storedPosition,
storedHeight,
storedWidth,
storedHeight, // Deprecated
storedWidth, // Deprecated
storedHeightPercentage,
storedWidthPercentage,
storedVisibleWidths,
storedVisibleThemes,
storedColorScheme,
]) => {
const code = codeFromQuery || storedCode || exampleCode;
const editorPosition = storedPosition;

const editorHeightPercentage =
storedHeight || defaultEditorSizePercentage;
storedHeightPercentage ||
(storedHeight ? `${storedHeight}px` : null) ||
defaultEditorSizePercentage;

const editorWidthPercentage =
storedWidth || defaultEditorSizePercentage;
storedWidthPercentage ||
(storedWidth ? `${storedWidth}px` : null) ||
defaultEditorSizePercentage;
const visibleWidths =
widthsFromQuery ||
storedVisibleWidths ||
playroomConfig?.defaultVisibleWidths;

const visibleThemes =
hasThemesConfigured &&
(themesFromQuery ||
storedVisibleThemes ||
playroomConfig?.defaultVisibleThemes);

const colorScheme = storedColorScheme;

dispatch({
Expand Down

0 comments on commit b7c41ca

Please sign in to comment.