Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WALLET-573 : Fix issues when upload file #69

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ In the output, you'll find options to open the app in a
### On a device with Expo Go

After expo has started, make sure it targets the Expo Go environment (as opposed to "development build").
This will display a QR code which you will need to scan from your device's Expo Go application.
This will display a QR code which you will need to scan with your device.

The Wallet application will then build and install into your device for you to test & debug.

Expand Down
13 changes: 13 additions & 0 deletions components/PopupMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -61,6 +65,15 @@ const PopupMenu: React.FC<PopupMenuProps> = ({
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why this happens - something must be trying to upload the file a second time which seems odd.

onUploadSuccess();
return;
}
console.debug("A non-HTTP error occurred.", error);
showErrorMsg("Unable to save the file into your Wallet.");
},
Expand Down
9 changes: 3 additions & 6 deletions components/files/BottomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const BottomModal: React.FC<BottomModalProps> = ({
const [isShowQRCode, setShowQRCode] = useState(false);
const deleteMutation = useMutation({
mutationFn: deleteFile,
onSuccess: () => queryClient.refetchQueries({ queryKey: ["files"] }),
onSuccess: () => {
onDeleteSuccessfully?.();
},
mutationKey: ["filesMutation"],
});
const queryClient = useQueryClient();
Expand Down Expand Up @@ -105,11 +107,6 @@ const BottomModal: React.FC<BottomModalProps> = ({
// 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 = () => {
Expand Down
138 changes: 121 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@inrupt/solid-client-errors": "^0.0.2",
"@react-native-cookies/cookies": "^6.2.1",
"@react-navigation/native": "^6.1.18",
"@tanstack/react-query": "^5.51.23",
"@tanstack/react-query": "^5.56.2",
"date-fns": "^3.6.0",
"expo": "~51.0.31",
"expo-build-properties": "~0.12.5",
Expand All @@ -51,7 +51,7 @@
"react-native-gesture-handler": "~2.16.1",
"react-native-qrcode-svg": "^6.3.1",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-safe-area-context": "4.11.0",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-svg-transformer": "^1.5.0",
Expand Down