Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Prune

Manav Rathi28580cf10755
diff --git a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx
index 2683cc3ee0..da72f3b46a 100644
--- a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx
+++ b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx
@@ -14,7 +14,7 @@ import { t } from "i18next";
import { useEffect, useState } from "react";
import { Trans } from "react-i18next";
import { v4 as uuidv4 } from "uuid";
-import { loadSender } from "../../utils/useCastSender";
+import { loadCast } from "../../utils/cast";
interface Props {
show: boolean;
@@ -100,9 +100,7 @@ export default function AlbumCastDialog({
useEffect(() => {
if (view === "auto") {
- loadSender().then(async (sender) => {
- const { cast } = sender;
-
+ loadCast().then(async (cast) => {
const instance = await cast.framework.CastContext.getInstance();
try {
await instance.requestSession();
diff --git a/web/apps/photos/src/utils/useCastSender.tsx b/web/apps/photos/src/utils/cast.ts
similarity index 75%
rename from web/apps/photos/src/utils/useCastSender.tsx
rename to web/apps/photos/src/utils/cast.ts
index 51615748a0..cd3cdabd05 100644
--- a/web/apps/photos/src/utils/useCastSender.tsx
+++ b/web/apps/photos/src/utils/cast.ts
@@ -7,16 +7,14 @@ declare global {
}
}
-type Sender = {
- chrome: typeof chrome;
- cast: typeof cast;
-};
-
-export const loadSender = (() => {
- let promise: Promise<Sender> | null = null;
+/**
+ * Load the Chromecast script, resolving with the global `cast` object.
+ */
+export const loadCast = (() => {
+ let promise: Promise<any> | undefined;
return () => {
- if (promise === null) {
+ if (promise === undefined) {
promise = new Promise((resolve) => {
const script = document.createElement("script");
script.src =
@@ -29,10 +27,7 @@ export const loadSender = (() => {
chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
});
- resolve({
- chrome,
- cast,
- });
+ resolve(cast);
}
};
document.body.appendChild(script);