Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix qr bug, ignore webpack plugins

Steven Tey0c6cafc28209
diff --git a/app/ui/modals/link-qr-modal.tsx b/app/ui/modals/link-qr-modal.tsx
index ca0317842a..8f99d109a0 100644
--- a/app/ui/modals/link-qr-modal.tsx
+++ b/app/ui/modals/link-qr-modal.tsx
@@ -24,6 +24,7 @@ import IconMenu from "@/components/shared/icon-menu";
import Popover from "#/ui/popover";
import { toast } from "sonner";
import { GOOGLE_FAVICON_URL } from "#/lib/constants";
+import { useDebouncedCallback } from "use-debounce";
function LinkQRModalHelper({
showLinkQRModal,
@@ -55,7 +56,7 @@ function LinkQRModalHelper({
if (logo) return logo;
return typeof window !== "undefined" && window.location.origin
? new URL("/_static/logo.svg", window.location.origin).href
- : "";
+ : "https://dub.sh/_static/logo.svg";
}, [logo]);
function download(url: string, extension: string) {
@@ -187,10 +188,9 @@ function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {
const { plan } = useProject();
const [expanded, setExpanded] = useState(false);
- const isApp = useMemo(() => {
- if (typeof window === "undefined") return false;
- return window.location.host.startsWith("app.");
- }, []);
+ const debouncedSetFgColor = useDebouncedCallback((color) => {
+ setFgColor(color);
+ }, 100);
return (
<div>
@@ -265,7 +265,7 @@ function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {
<div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">
<HexColorPicker
color={qrData.fgColor}
- onChange={(color) => setFgColor(color)}
+ onChange={debouncedSetFgColor}
/>
</div>
}
diff --git a/components/app/modals/link-qr-modal.tsx b/components/app/modals/link-qr-modal.tsx
index 7dd522a429..72d077a087 100644
--- a/components/app/modals/link-qr-modal.tsx
+++ b/components/app/modals/link-qr-modal.tsx
@@ -35,6 +35,7 @@ import {
import { useRouter } from "next/router";
import { ModalContext } from "#/ui/modal-provider";
import { motion } from "framer-motion";
+import { useDebouncedCallback } from "use-debounce";
function LinkQRModalHelper({
showLinkQRModal,
@@ -66,7 +67,7 @@ function LinkQRModalHelper({
if (logo && plan !== "free") return logo;
return typeof window !== "undefined" && window.location.origin
? new URL("/_static/logo.svg", window.location.origin).href
- : "";
+ : "https://dub.sh/_static/logo.svg";
}, [logo, plan]);
function download(url: string, extension: string) {
@@ -207,6 +208,10 @@ function AdvancedSettings({
const { plan, logo } = useProject();
const [expanded, setExpanded] = useState(false);
+ const debouncedSetFgColor = useDebouncedCallback((color) => {
+ setFgColor(color);
+ }, 100);
+
const { setShowAddProjectModal, setShowUpgradePlanModal } =
useContext(ModalContext);
@@ -311,7 +316,7 @@ function AdvancedSettings({
<div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">
<HexColorPicker
color={qrData.fgColor}
- onChange={(color) => setFgColor(color)}
+ onChange={debouncedSetFgColor}
/>
</div>
}
diff --git a/next.config.js b/next.config.js
index 7eb79f65a4..c1b99e9c7a 100644
--- a/next.config.js
+++ b/next.config.js
@@ -18,6 +18,24 @@ const nextConfig = {
serverActions: true,
useDeploymentIdServerActions: true,
},
+ webpack: (config, { webpack, isServer }) => {
+ if (isServer) {
+ // Module not found
+ config.plugins.push(
+ new webpack.IgnorePlugin({
+ resourceRegExp:
+ /(^@google-cloud\/spanner|^@mongodb-js\/zstd|^aws-crt|^aws4$|^pg-native$|^mongodb-client-encryption$|^@sap\/hana-client$|^snappy$|^react-native-sqlite-storage$|^bson-ext$|^cardinal$|^kerberos$|^hdb-pool$|^sql.js$|^sqlite3$|^better-sqlite3$|^ioredis$|^typeorm-aurora-data-api-driver$|^pg-query-stream$|^oracledb$|^mysql$|^snappy\/package\.json$|^cloudflare:sockets$)/,
+ }),
+ );
+ }
+
+ config.module = {
+ ...config.module,
+ exprContextCritical: false,
+ };
+
+ return config;
+ },
images: {
domains: [
"www.google.com",