Skip to content

Commit

Permalink
disable layout
Browse files Browse the repository at this point in the history
  • Loading branch information
gempir committed Feb 6, 2024
1 parent fd393c3 commit 760f8e3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dayjs.extend(localizedFormat);
export default function App({ Component, pageProps }: { Component: any; pageProps: any }) {
const createStore = useCreateStore(pageProps.store);

const renderFullLayout = Component.name !== "Overlay";
const renderFullLayout = pageProps.renderFullLayout ?? true;

return (
<StoreProvider createStore={createStore}>
Expand Down
5 changes: 2 additions & 3 deletions web/src/pages/overlay/[roomId].tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";
import { initializeStore } from "../../service/initializeStore";
import { IframeOverlayPage } from "../../components/Overlay/IframeOverlayPage";
import { initializeStoreWithProps } from "../../service/initializeStore";

export default function Overlay() {
return <IframeOverlayPage />
}

export const getServerSideProps = initializeStore;
export const getServerSideProps = initializeStoreWithProps({renderFullLayout: false});
30 changes: 30 additions & 0 deletions web/src/service/initializeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,34 @@ export const initializeStore = (ctx: NextPageContext) => {
}
},
};
}

export const initializeStoreWithProps = (props: any) => {
return (ctx: NextPageContext) => {
const cookies = parseCookie(ctx.req?.headers.cookie ?? "");

let scTokenContent = null;
if (cookies.scToken) {
try {
scTokenContent = jwt_decode<ScTokenContent | null>(cookies.scToken ?? "") ?? null;
} catch (e) {
console.error(e);
}
}

return {
props: {
...props,
store: {
scTokenContent: scTokenContent,
scToken: cookies.scToken ? cookies.scToken : null,
managing: cookies.managing ? cookies.managing : null,
twitchClientId: (process.env.NEXT_PUBLIC_TWITCH_CLIENT_ID ?? "").replaceAll('"', ''),
apiBaseUrl: (process.env.NEXT_PUBLIC_API_BASE_URL ?? "").replaceAll('"', ''),
yjsWsUrl: (process.env.NEXT_PUBLIC_YJS_WS_URL ?? "").replaceAll('"', ''),
baseUrl: (process.env.NEXT_PUBLIC_BASE_URL ?? "").replaceAll('"', ''),
}
},
};
}
}

0 comments on commit 760f8e3

Please sign in to comment.