From ce6b94913cd6dd52aecdaca1bce2769b6b4bb2a8 Mon Sep 17 00:00:00 2001 From: "quan.vo" Date: Mon, 23 Sep 2024 15:25:01 +0700 Subject: [PATCH] Fix issue and increase some dependiences --- components/PopupMenu.tsx | 13 +++++++++++++ components/files/BottomModal.tsx | 13 +++++-------- package-lock.json | 22 +++++++++++++--------- package.json | 4 ++-- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/components/PopupMenu.tsx b/components/PopupMenu.tsx index 0b5cdc8..fdbd54a 100644 --- a/components/PopupMenu.tsx +++ b/components/PopupMenu.tsx @@ -28,6 +28,10 @@ import { faCamera } from "@fortawesome/free-solid-svg-icons/faCamera"; import { faQrcode } from "@fortawesome/free-solid-svg-icons/faQrcode"; import { useError } from "@/hooks/useError"; import * as Linking from "expo-linking"; +import { + hasProblemDetails, + NOT_ACCEPTABLE_STATUS, +} from "@inrupt/solid-client-errors"; import { ThemedText } from "./ThemedText"; const { width } = Dimensions.get("window"); @@ -61,6 +65,15 @@ const PopupMenu: React.FC = ({ mutationFn: postFile, onSuccess: onUploadSuccess, onError: (error) => { + if ( + error && + hasProblemDetails(error) && + error.problemDetails.status === NOT_ACCEPTABLE_STATUS + ) { + // This is the expected behavior of the Solid server. The file has already been uploaded to Solid, even though the server returned a 406 error. + onUploadSuccess(); + return; + } console.debug("A non-HTTP error occurred.", error); showErrorMsg("Unable to save the file into your Wallet."); }, diff --git a/components/files/BottomModal.tsx b/components/files/BottomModal.tsx index 9c6dafe..b602b43 100644 --- a/components/files/BottomModal.tsx +++ b/components/files/BottomModal.tsx @@ -56,7 +56,9 @@ const BottomModal: React.FC = ({ const [isShowQRCode, setShowQRCode] = useState(false); const deleteMutation = useMutation({ mutationFn: deleteFile, - onSuccess: () => queryClient.refetchQueries({ queryKey: ["files"] }), + onSuccess: () => { + onDeleteSuccessfully?.(); + }, mutationKey: ["filesMutation"], }); const queryClient = useQueryClient(); @@ -105,11 +107,6 @@ const BottomModal: React.FC = ({ // eslint-disable-next-line no-console .catch(() => console.error("Error while deleting data")); onCloseModal(); - onDeleteSuccessfully?.(); - queryClient - .refetchQueries({ queryKey: ["files"] }) - // eslint-disable-next-line no-console - .catch(() => console.error("Error while refetching data")); }; const onShareViaQR = () => { @@ -161,7 +158,7 @@ const BottomModal: React.FC = ({ > - Share via QR Code + Show QR Code = ({ > - Download a copy + Share {Boolean(fileDownload) && (