mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-09 16:24:25 +01:00
catch paste errors
This commit is contained in:
committed by
Tony Giorgio
parent
97d9d9969e
commit
81d45874fd
@@ -74,10 +74,13 @@ export default function Scanner() {
|
||||
history.back();
|
||||
}
|
||||
|
||||
function handlePaste() {
|
||||
navigator.clipboard.readText().then((text) => {
|
||||
async function handlePaste() {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
setScanResult(text);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
|
||||
@@ -358,19 +358,17 @@ export default function Send() {
|
||||
parsePaste(text);
|
||||
}
|
||||
|
||||
function handlePaste() {
|
||||
async function handlePaste() {
|
||||
if (!navigator.clipboard.readText)
|
||||
return showToast(new Error("Clipboard not supported"));
|
||||
|
||||
navigator.clipboard
|
||||
.readText()
|
||||
.then((text) => {
|
||||
setFieldDestination(text);
|
||||
parsePaste(text);
|
||||
})
|
||||
.catch((e) => {
|
||||
showToast(new Error("Failed to read clipboard: " + e.message));
|
||||
});
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
setFieldDestination(text);
|
||||
parsePaste(text);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function processContacts(
|
||||
|
||||
@@ -10,7 +10,7 @@ export const useCopy = ({ copiedTimeout = 2000 }: UseCopyProps = {}): [
|
||||
copied: Accessor<boolean>
|
||||
] => {
|
||||
const [copied, setCopied] = createSignal(false);
|
||||
let timeout: NodeJS.Timeout;
|
||||
let timeout: number;
|
||||
const copy: CopyFn = async (text) => {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
|
||||
Reference in New Issue
Block a user