Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

add requestIdleCallback polyfill to fix Safari crash (#5689)

rahulramesha117afdb67fa3
diff --git a/web/app/provider.tsx b/web/app/provider.tsx
index 12b6a09f8a..dba975a637 100644
--- a/web/app/provider.tsx
+++ b/web/app/provider.tsx
@@ -12,6 +12,8 @@ import { SWR_CONFIG } from "@/constants/swr-config";
import { resolveGeneralTheme } from "@/helpers/theme.helper";
// nprogress
import { AppProgressBar } from "@/lib/n-progress";
+// polyfills
+import "@/lib/polyfills";
// mobx store provider
import { StoreProvider } from "@/lib/store-context";
// wrappers
diff --git a/web/core/lib/polyfills/index.ts b/web/core/lib/polyfills/index.ts
new file mode 100644
index 0000000000..20b3b476c0
--- /dev/null
+++ b/web/core/lib/polyfills/index.ts
@@ -0,0 +1 @@
+export * from "./requestIdleCallback";
diff --git a/web/core/lib/polyfills/requestIdleCallback.ts b/web/core/lib/polyfills/requestIdleCallback.ts
new file mode 100644
index 0000000000..76dd4c29e0
--- /dev/null
+++ b/web/core/lib/polyfills/requestIdleCallback.ts
@@ -0,0 +1,24 @@
+if (typeof window !== "undefined" && window) {
+ // Add request callback polyfill to browser incase it does not exist
+ window.requestIdleCallback =
+ window.requestIdleCallback ??
+ function (cb) {
+ var start = Date.now();
+ return setTimeout(function () {
+ cb({
+ didTimeout: false,
+ timeRemaining: function () {
+ return Math.max(0, 50 - (Date.now() - start));
+ },
+ });
+ }, 1);
+ };
+
+ window.cancelIdleCallback =
+ window.cancelIdleCallback ??
+ function (id) {
+ clearTimeout(id);
+ };
+}
+
+export {};