mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: adding csp update
This commit is contained in:
parent
5bc424796a
commit
7f600a0cbf
10 changed files with 37 additions and 53 deletions
|
@ -6,8 +6,12 @@
|
|||
<title>Hydra</title>
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self'; script-src *; style-src 'self' 'unsafe-inline'; img-src 'self' data: local: *; media-src 'self' local: data: *; connect-src *; font-src *;"
|
||||
content="default-src 'self' 'unsafe-inline' *;"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="%RENDERER_VITE_EXTERNAL_RESOURCES_URL%"
|
||||
></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
|
|
@ -2,8 +2,6 @@ import { useCallback, useContext, useEffect, useRef } from "react";
|
|||
|
||||
import { Sidebar, BottomPanel, Header, Toast } from "@renderer/components";
|
||||
|
||||
import Intercom from "@intercom/messenger-js-sdk";
|
||||
|
||||
import {
|
||||
useAppDispatch,
|
||||
useAppSelector,
|
||||
|
@ -36,10 +34,6 @@ export interface AppProps {
|
|||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
Intercom({
|
||||
app_id: import.meta.env.RENDERER_VITE_INTERCOM_APP_ID,
|
||||
});
|
||||
|
||||
export function App() {
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
const { updateLibrary, library } = useLibrary();
|
||||
|
@ -68,6 +62,25 @@ export function App() {
|
|||
clearUserDetails,
|
||||
} = useUserDetails();
|
||||
|
||||
useEffect(() => {
|
||||
if (userDetails) {
|
||||
const $existingScript = document.getElementById("user-details");
|
||||
|
||||
const content = `window.userDetails = ${JSON.stringify(userDetails)};`;
|
||||
|
||||
if ($existingScript) {
|
||||
$existingScript.textContent = content;
|
||||
} else {
|
||||
const $script = document.createElement("script");
|
||||
$script.id = "user-details";
|
||||
$script.type = "text/javascript";
|
||||
$script.textContent = content;
|
||||
|
||||
document.head.appendChild($script);
|
||||
}
|
||||
}
|
||||
}, [userDetails]);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
@ -215,9 +228,7 @@ export function App() {
|
|||
|
||||
useEffect(() => {
|
||||
new MutationObserver(() => {
|
||||
const modal = document.body.querySelector(
|
||||
"[role=dialog]:not([data-intercom-frame='true'])"
|
||||
);
|
||||
const modal = document.body.querySelector("[data-hydra-dialog]");
|
||||
|
||||
dispatch(toggleDraggingDisabled(Boolean(modal)));
|
||||
}).observe(document.body, {
|
||||
|
|
|
@ -107,6 +107,7 @@ export function Modal({
|
|||
aria-labelledby={title}
|
||||
aria-describedby={description}
|
||||
ref={modalContentRef}
|
||||
data-hydra-dialog
|
||||
>
|
||||
<div className={styles.modalHeader}>
|
||||
<div style={{ display: "flex", gap: 4, flexDirection: "column" }}>
|
||||
|
|
|
@ -22,8 +22,6 @@ import { SidebarProfile } from "./sidebar-profile";
|
|||
import { sortBy } from "lodash-es";
|
||||
import { CommentDiscussionIcon } from "@primer/octicons-react";
|
||||
|
||||
import { show, update } from "@intercom/messenger-js-sdk";
|
||||
|
||||
const SIDEBAR_MIN_WIDTH = 200;
|
||||
const SIDEBAR_INITIAL_WIDTH = 250;
|
||||
const SIDEBAR_MAX_WIDTH = 450;
|
||||
|
@ -50,23 +48,7 @@ export function Sidebar() {
|
|||
return sortBy(library, (game) => game.title);
|
||||
}, [library]);
|
||||
|
||||
const { userDetails, hasActiveSubscription } = useUserDetails();
|
||||
|
||||
useEffect(() => {
|
||||
if (userDetails) {
|
||||
window.electron.isStaging().then((isStaging) => {
|
||||
update({
|
||||
user_id: userDetails.id + (isStaging ? "-staging" : ""),
|
||||
name: userDetails.displayName,
|
||||
Username: userDetails.username,
|
||||
email: userDetails.email ?? undefined,
|
||||
Email: userDetails.email,
|
||||
"Subscription expiration date": userDetails?.subscription?.expiresAt,
|
||||
"Payment status": userDetails?.subscription?.status,
|
||||
});
|
||||
});
|
||||
}
|
||||
}, [userDetails, hasActiveSubscription]);
|
||||
const { hasActiveSubscription } = useUserDetails();
|
||||
|
||||
const { lastPacket, progress } = useDownload();
|
||||
|
||||
|
@ -269,7 +251,11 @@ export function Sidebar() {
|
|||
</div>
|
||||
|
||||
{hasActiveSubscription && (
|
||||
<button type="button" className={styles.helpButton} onClick={show}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.helpButton}
|
||||
data-open-support-chat
|
||||
>
|
||||
<div className={styles.helpButtonIcon}>
|
||||
<CommentDiscussionIcon size={14} />
|
||||
</div>
|
||||
|
|
3
src/renderer/src/declaration.d.ts
vendored
3
src/renderer/src/declaration.d.ts
vendored
|
@ -162,7 +162,6 @@ declare global {
|
|||
openExternal: (src: string) => Promise<void>;
|
||||
openCheckout: () => Promise<void>;
|
||||
getVersion: () => Promise<string>;
|
||||
isStaging: () => Promise<boolean>;
|
||||
ping: () => string;
|
||||
getDefaultDownloadsPath: () => Promise<string>;
|
||||
isPortableVersion: () => Promise<boolean>;
|
||||
|
@ -232,6 +231,8 @@ declare global {
|
|||
|
||||
/* Notifications */
|
||||
publishNewRepacksNotification: (newRepacksCount: number) => Promise<void>;
|
||||
|
||||
isStaging: boolean;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
|
|
8
src/renderer/src/vite-env.d.ts
vendored
8
src/renderer/src/vite-env.d.ts
vendored
|
@ -1,10 +1,2 @@
|
|||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-plugin-svgr/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly RENDERER_VITE_INTERCOM_APP_ID: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue