Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-mereuta committed Dec 3, 2024
1 parent a84343c commit 6087161
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/StudioProjectLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
UserInterfaceWithOutputSettings,
} from './types/types';
import { getDownloadLink } from './utils/documentExportHelper';
import { SESSION_USER_INTEFACE_ID_KEY } from './utils/constants';

export class StudioProjectLoader {
private projectDownloadUrl?: string;
Expand Down Expand Up @@ -223,10 +224,11 @@ export class StudioProjectLoader {
});
return mappedOutputSettings;
};

if (userInterfaceId) {
// userInterfaceID from projectConfig or session-stored userInterfaceId
const userInterface = userInterfaceId || sessionStorage.getItem(SESSION_USER_INTEFACE_ID_KEY);
if (userInterface) {
const userInterfaceData: UserInterface = await axios
.get(`${this.graFxStudioEnvironmentApiBaseUrl}/user-interfaces/${userInterfaceId}`, {
.get(`${this.graFxStudioEnvironmentApiBaseUrl}/user-interfaces/${userInterface}`, {
headers: { Authorization: `Bearer ${this.authToken}` },
})
.then((res) => res.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const useUserInterfaceSelector = () => {
const validUserInterfaceForTemplate = userInterfaces.find(
(item) => item.id === sessionStorage.getItem(SESSION_USER_INTEFACE_ID_KEY),
)?.id;

const selectedUserInterface =
validUserInterfaceForTemplate || selectedUserInterfaceId || userInterfaces.find((item) => item.default)?.id;

Expand Down
13 changes: 11 additions & 2 deletions src/components/navbar/studioNavbar/useStudioNavbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useCallback, useMemo } from 'react';
import { useTheme } from '@chili-publish/grafx-shared-components';
import useNavbarDownloadBtn from '../navbarItems/useNavbarDownloadBtn';
import useNavbarUndoRedoItems from '../navbarItems/useNavbarUndoRedo';
Expand All @@ -9,6 +9,7 @@ import useNavbarMenu from '../navbarItems/useNavbarMenu';
import useNavbarModeToggle from '../navbarItems/useNavbarModeToggle';
import useUserInterfaceSelector from '../navbarItems/useUserInterfaceSelector';
import { ProjectConfig } from '../../../types/types';
import { SESSION_USER_INTEFACE_ID_KEY } from '../../../utils/constants';

interface INavbar {
projectName: string | undefined;
Expand All @@ -26,10 +27,18 @@ const useStudioNavbar = ({
onBackClick,
onDownloadPanelOpen,
}: INavbar) => {
const handleOnBack = useCallback(() => {
if (onBackClick) {
sessionStorage.removeItem(SESSION_USER_INTEFACE_ID_KEY);
return onBackClick?.();
}
return undefined;
}, [onBackClick]);
const { menuNavbarItem } = useNavbarMenu({ undoStackState, zoom, onBackClick: handleOnBack });

const { undoRedoNavbarItem } = useNavbarUndoRedoItems(undoStackState);
const { downloadNavbarItem } = useNavbarDownloadBtn(onDownloadPanelOpen);
const { zoomNavbarItem } = useNavbarZoom(zoom);
const { menuNavbarItem } = useNavbarMenu({ undoStackState, zoom, onBackClick });
const { modeToggleNavbarItem } = useNavbarModeToggle(projectConfig);
const { userInterfaceDropdownNavbarItem } = useUserInterfaceSelector();
const { mode } = useTheme();
Expand Down

0 comments on commit 6087161

Please sign in to comment.