Skip to content

Commit

Permalink
Merge pull request #286 from ConductionNL/feature/WOO-116/attachments
Browse files Browse the repository at this point in the history
feature/WOO-116/attachments
  • Loading branch information
remko48 authored Mar 22, 2024
2 parents 54e30b5 + 133cdbd commit 22f7ddf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
16 changes: 1 addition & 15 deletions pwa/gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,7 @@ export const wrapRootElement = ({ element }) => {
);
};

export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
const isBrowser = () => typeof window !== "undefined";
export const onRenderBody = ({ setHeadComponents }) => {
const HeadComponents = [<title key={0}>Woo Website</title>];
const BodyComponents = [
isBrowser() && window.sessionStorage.getItem("ANALYTICS_URL") ? (
<script
key={0}
id="analytics"
async
src={window.sessionStorage.getItem("ANALYTICS_URL")}
/>
) : (
<script key={0} id="analytics" />
),
];
setHeadComponents(HeadComponents);
setPostBodyComponents(BodyComponents);
};
3 changes: 0 additions & 3 deletions pwa/src/hooks/useEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const useEnvironment = () => {

const updateSessionStorage = () => {
window.dispatchEvent(new Event("sessionStorageChange"));
const analyticsElement = document.getElementById("analytics");
window.sessionStorage.getItem("ANALYTICS_URL") &&
analyticsElement?.setAttribute("src", window.sessionStorage.getItem("ANALYTICS_URL") ?? "");
};

React.useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions pwa/src/layout/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export const Head: React.FC = () => {
getPageTitle(translatedCrumbs, gatsbyContext.location) ?? "Error"
}`}</title>
<link rel="icon" type="svg" href={window.sessionStorage.getItem("FAVICON_URL") ?? ""} />
{window.sessionStorage.getItem("ANALYTICS_URL") || (
<script async src={window.sessionStorage.getItem("ANALYTICS_URL") ?? ""} />
)}
</Helmet>
);
};

0 comments on commit 22f7ddf

Please sign in to comment.