Skip to content

armgit / ente

Public Imported from GitHub
0

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

refractor(_app):remove-unwanted-function

Aswin Asokf67d50a11415
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index f2f9527d8b..018e98efbb 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -53,87 +53,6 @@ import "photoswipe/dist/photoswipe.css";
import "styles/global.css";
import "styles/photoswipe.css";
-const installPerformanceMeasureGuard = () => {
- if (typeof window === "undefined") return;
- if (process.env.NODE_ENV !== "development") return;
-
- const perf = window.performance;
- if (typeof perf.measure !== "function") return;
- if ((perf as { __enteMeasureGuard?: boolean }).__enteMeasureGuard) return;
-
- const originalMeasure = perf.measure.bind(perf);
- const isDataCloneError = (error: unknown) => {
- if (error instanceof DOMException) {
- return error.name === "DataCloneError";
- }
- return (
- !!error &&
- typeof error === "object" &&
- "name" in error &&
- (error as { name?: string }).name === "DataCloneError"
- );
- };
-
- // Dev-only: avoid crashing when React's user timing clones huge props.
- const createFallbackMeasure = (name: string): PerformanceMeasure =>
- ({
- name,
- entryType: "measure",
- startTime: 0,
- duration: 0,
- toJSON: () => ({
- name,
- entryType: "measure",
- startTime: 0,
- duration: 0,
- }),
- }) as PerformanceMeasure;
-
- const guardedMeasure: Performance["measure"] = (
- name,
- startOrOptions,
- endMark,
- ) => {
- try {
- return originalMeasure(name, startOrOptions, endMark);
- } catch (error) {
- if (!isDataCloneError(error)) throw error;
-
- if (
- startOrOptions &&
- typeof startOrOptions === "object" &&
- !Array.isArray(startOrOptions)
- ) {
- const { start, end, duration } = startOrOptions;
- try {
- return originalMeasure(name, { start, end, duration });
- } catch {
- try {
- return originalMeasure(name);
- } catch {
- return createFallbackMeasure(name);
- }
- }
- }
-
- try {
- return originalMeasure(name);
- } catch {
- return createFallbackMeasure(name);
- }
- }
- };
-
- try {
- perf.measure = guardedMeasure;
- (perf as { __enteMeasureGuard?: boolean }).__enteMeasureGuard = true;
- } catch {
- // Ignore if the environment blocks overrides.
- }
-};
-
-installPerformanceMeasureGuard();
-
const App: React.FC<AppProps> = ({ Component, pageProps }) => {
useSetupLogs();