Skip to content

Commit

Permalink
rename store var
Browse files Browse the repository at this point in the history
  • Loading branch information
alextaing committed Oct 24, 2023
1 parent 907d059 commit ee8a85f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/studio-ui/src/hooks/useInjectUserStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { StudioStore } from "../store/models/StudioStore";
export default function useInjectUserStyles(
iframeDocument: Document | undefined
) {
const [userStyleImports, loadedStyles] = useStudioStore(
(store) => [getUserStyleImports(store), store.loadedStyles.loadedStyles],
const [userStyleImports, loadedStyleFilepaths] = useStudioStore(
(store) => [getUserStyleImports(store), store.loadedStyles.loadedStyleFilepaths],
isEqual
);

Expand All @@ -31,12 +31,12 @@ export default function useInjectUserStyles(
};

/**
* loadedStyles is watched by this useEffect hook to
* account for the race condition where this hook is
* loadedStyleFilepaths is watched by this useEffect hook to
* account for the race condition where this hook is
* called before all user styles are added to Studio's
* document head.
*/
}, [iframeDocument, userStyleImports, loadedStyles]);
}, [iframeDocument, userStyleImports, loadedStyleFilepaths]);
}

function getUserStyleImports(store: StudioStore): string[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default interface LoadedStylesSlice {
loadedStyles: Set<string>;
addLoadedStyle: (style: string) => void;
loadedStyleFilepaths: Set<string>;
addLoadedStyleFilepath: (style: string) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import LoadedStylesSlice from "../models/slices/LoadedStylesSlice";
import { SliceCreator } from "../models/utils";

const createLoadedStylesSlice: SliceCreator<LoadedStylesSlice> = (set) => ({
loadedStyles: new Set<string>(),
addLoadedStyle: (style: string) => {
loadedStyleFilepaths: new Set<string>(),
addLoadedStyleFilepath: (styleFilepath: string) => {
set((store) => {
store.loadedStyles.add(style);
store.loadedStyleFilepaths.add(styleFilepath);
});
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/studio-ui/src/utils/loadUserAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function loadComponents(): Promise<void>[] {
*/
export function loadStyling(): Promise<void>[] {
const studioStore = useStudioStore.getState();
const addLoadedStyle = studioStore.loadedStyles.addLoadedStyle;
const addLoadedStyle = studioStore.loadedStyles.addLoadedStyleFilepath;
const pages = Object.values(studioStore.pages.pages);
const layouts = Object.values(studioStore.layouts.layoutNameToLayoutState);
const fileMetadatas = Object.values(
Expand Down

0 comments on commit ee8a85f

Please sign in to comment.