Update
This commit is contained in:
@@ -107,8 +107,8 @@ const useResponsiveDimensions = () => {
|
||||
return dimensions;
|
||||
};
|
||||
|
||||
const Editor = () => {
|
||||
const { init } = useMediaStore();
|
||||
const Editor = ({ setInitialMeme, setInitialBackground, setInitialText }) => {
|
||||
const { init, setInitialMeme: setStoreMeme, setInitialBackground: setStoreBackground, setInitialText: setStoreText, clearInitialState } = useMediaStore();
|
||||
const { getSetting } = useLocalSettingsStore();
|
||||
const { setSelectedTextElement } = useVideoEditorStore();
|
||||
const emitter = useMitt();
|
||||
@@ -121,8 +121,28 @@ const Editor = () => {
|
||||
const isBelowMinWidth = useViewportDetection(320);
|
||||
|
||||
useEffect(() => {
|
||||
// Clear any previous initial state to allow fresh initialization
|
||||
clearInitialState();
|
||||
|
||||
// Set initial values if props are provided
|
||||
if (setInitialMeme) {
|
||||
setInitialMeme(setStoreMeme);
|
||||
}
|
||||
if (setInitialBackground) {
|
||||
setInitialBackground(setStoreBackground);
|
||||
}
|
||||
if (setInitialText) {
|
||||
setInitialText(setStoreText);
|
||||
}
|
||||
|
||||
// Initialize (will skip API call if initial values were set)
|
||||
init();
|
||||
}, []);
|
||||
|
||||
// Cleanup: Clear initial state when component unmounts
|
||||
return () => {
|
||||
clearInitialState();
|
||||
};
|
||||
}, [setInitialMeme, setInitialBackground, setInitialText, setStoreMeme, setStoreBackground, setStoreText, init, clearInitialState]);
|
||||
|
||||
// Listen for text element selection (but don't auto-open sidebar)
|
||||
useEffect(() => {
|
||||
@@ -173,7 +193,7 @@ const Editor = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative mx-auto flex min-h-[93vh] flex-col space-y-2 pt-4" style={{ width: `${responsiveWidth}px` }}>
|
||||
<div className="relative mx-auto flex min-h-[88vh] flex-col space-y-2" style={{ width: `${responsiveWidth}px` }}>
|
||||
<EditSidebar isOpen={isEditSidebarOpen} onClose={handleEditClose} />
|
||||
<EditNavSidebar isOpen={isEditNavSidebarOpen} onClose={handleEditNavClose} />
|
||||
<TextSidebar isOpen={isTextSidebarOpen} onClose={handleTextSidebarClose} />
|
||||
|
||||
Reference in New Issue
Block a user