(fix): ttp_url missing in qrcode
This commit is contained in:
parent
fd18ee6079
commit
167036533c
2 changed files with 17 additions and 8 deletions
|
|
@ -190,11 +190,9 @@ export default function Form() {
|
||||||
[save],
|
[save],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isTauriEnv = isTauri();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex md:flex-row flex-col gap-15">
|
<div className="flex md:flex-row flex-col gap-15">
|
||||||
{isTauriEnv ? (
|
{isTauri() ? (
|
||||||
<>
|
<>
|
||||||
<QrCodeScanner
|
<QrCodeScanner
|
||||||
onData={async (data) => {
|
onData={async (data) => {
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ function QrCodeLogin() {
|
||||||
const [qrCodeBase64, setQrCodeBase64] = useState<string | undefined>(
|
const [qrCodeBase64, setQrCodeBase64] = useState<string | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
const [connectionString, setConnectionString] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
load("private_key").then((value) => {
|
load("private_key").then((value) => {
|
||||||
|
|
@ -58,15 +59,25 @@ function QrCodeLogin() {
|
||||||
setUserId(value);
|
setUserId(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
load("ttp_url")
|
||||||
|
.then((value) => {
|
||||||
|
if (value) {
|
||||||
|
const url = new URL(value);
|
||||||
|
setConnectionString(`@${url.host}`);
|
||||||
|
} else {
|
||||||
|
setConnectionString("");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => setConnectionString(""));
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userId && privateKey) {
|
if (userId && privateKey && connectionString !== null) {
|
||||||
generateQR(`tensamin://tu::${userId}::${privateKey}`).then(
|
generateQR(
|
||||||
setQrCodeBase64,
|
`tensamin://tu::${userId}${connectionString}::${privateKey}`,
|
||||||
);
|
).then(setQrCodeBase64);
|
||||||
}
|
}
|
||||||
}, [userId, privateKey]);
|
}, [userId, privateKey, connectionString]);
|
||||||
|
|
||||||
const [qrCodeVisible, setQrCodeVisible] = useState(false);
|
const [qrCodeVisible, setQrCodeVisible] = useState(false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue