fix qr code web

This commit is contained in:
2025-10-24 14:48:30 +02:00
parent 8356b04eb2
commit 0b37c7bc07
4 changed files with 62 additions and 10 deletions
+5 -1
View File
@@ -13,7 +13,12 @@ const QrCode = ({
errorCorrectionLevel = "M", errorCorrectionLevel = "M",
}) => { }) => {
const { matrix } = useMemo(() => { const { matrix } = useMemo(() => {
try {
return generateQrMatrix({ value, errorCorrectionLevel }); return generateQrMatrix({ value, errorCorrectionLevel });
} catch (error) {
console.error("qr.code.generate.error", error);
return { matrix: [] };
}
}, [value, errorCorrectionLevel]); }, [value, errorCorrectionLevel]);
const cellSize = useMemo(() => { const cellSize = useMemo(() => {
@@ -58,4 +63,3 @@ const QrCode = ({
}; };
export default QrCode; export default QrCode;
+34 -1
View File
@@ -46,6 +46,7 @@ const ShareModal = ({ payload }) => {
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const copyTimeout = useRef(null); const copyTimeout = useRef(null);
const shareQrTimeoutRef = useRef(null);
const modalRef = useRef(null); const modalRef = useRef(null);
const [webVisible, setWebVisible] = useState(true); const [webVisible, setWebVisible] = useState(true);
const blurProps = const blurProps =
@@ -88,6 +89,7 @@ const ShareModal = ({ payload }) => {
if (copyTimeout.current) { if (copyTimeout.current) {
clearTimeout(copyTimeout.current); clearTimeout(copyTimeout.current);
} }
}; };
}, []); }, []);
@@ -191,7 +193,22 @@ const ShareModal = ({ payload }) => {
const handleShareOption = useCallback( const handleShareOption = useCallback(
async (option) => { async (option) => {
if (option?.type === "qr") { if (option?.type === "qr") {
await closeSheet(); console.log("share.modal.handleShareOption", {
key: option?.key,
platform: Platform.OS,
});
if (shareQrTimeoutRef.current) {
clearTimeout(shareQrTimeoutRef.current);
}
const openQrModal = () => {
console.log("share.modal.openQrModal", {
platform: Platform.OS,
url: qrUrl,
title: qrTitle,
});
shareQrTimeoutRef.current = null;
setGlobal({ setGlobal({
shareQrModal: { shareQrModal: {
visible: true, visible: true,
@@ -199,6 +216,22 @@ const ShareModal = ({ payload }) => {
title: qrTitle, title: qrTitle,
}, },
}); });
};
if (Platform.OS === "web") {
console.log("share.modal.scheduleQr", { platform: Platform.OS });
const maybePromise = closeSheet();
shareQrTimeoutRef.current = setTimeout(openQrModal, 80);
if (maybePromise && typeof maybePromise.catch === "function") {
maybePromise.catch((error) => {
console.error("share.modal.closeSheet.error", error);
});
}
} else {
await closeSheet();
openQrModal();
}
return; return;
} }
+8 -1
View File
@@ -1,6 +1,6 @@
import { Portal } from "@gorhom/portal"; import { Portal } from "@gorhom/portal";
import { BlurView } from "expo-blur"; import { BlurView } from "expo-blur";
import React, { useMemo } from "react"; import React, { useEffect, useMemo } from "react";
import { Platform, Pressable, StyleSheet, Text, View } from "react-native"; import { Platform, Pressable, StyleSheet, Text, View } from "react-native";
import { Palette } from "../../styles"; import { Palette } from "../../styles";
@@ -15,6 +15,13 @@ const ShareQrModal = ({
}) => { }) => {
const shareUrl = useMemo(() => url, [url]); const shareUrl = useMemo(() => url, [url]);
useEffect(() => {
console.log("share.qr.modal.state", {
visible,
url: shareUrl,
});
}, [shareUrl, visible]);
if (!visible) { if (!visible) {
return null; return null;
} }
@@ -1,4 +1,4 @@
import React from "react"; import React, { useEffect } from "react";
import { useGlobal } from "reactn"; import { useGlobal } from "reactn";
import { musiclandShareUrl } from "../../data"; import { musiclandShareUrl } from "../../data";
@@ -9,6 +9,14 @@ const ShareQrModalContainer = () => {
const { visible, url, title } = shareQrModal || {}; const { visible, url, title } = shareQrModal || {};
useEffect(() => {
console.log("share.qr.container.state", {
visible: !!visible,
url,
title,
});
}, [visible, url, title]);
const handleClose = () => { const handleClose = () => {
setShareQrModal({ setShareQrModal({
visible: false, visible: false,