feat: adding image processing

This commit is contained in:
Chubby Granny Chaser 2024-09-14 00:09:34 +01:00
commit 6e543fecb4
No known key found for this signature in database
18 changed files with 165 additions and 77 deletions

View file

@ -150,6 +150,10 @@ declare global {
updateProfile: (
updateProfile: UpdateProfileRequest
) => Promise<UserProfile>;
updateProfile: (updateProfile: UpdateProfileProps) => Promise<UserProfile>;
processProfileImage: (
path: string
) => Promise<{ imagePath: string; mimeType: string }>;
getFriendRequests: () => Promise<FriendRequest[]>;
updateFriendRequest: (
userId: string,

View file

@ -102,7 +102,7 @@ export function EditProfileModal(
filters: [
{
name: "Image",
extensions: ["jpg", "jpeg", "png"],
extensions: ["jpg", "jpeg", "png", "gif", "webp"],
},
],
});
@ -110,7 +110,14 @@ export function EditProfileModal(
if (filePaths && filePaths.length > 0) {
const path = filePaths[0];
onChange(path);
const { imagePath } = await window.electron
.processProfileImage(path)
.catch(() => {
showErrorToast(t("image_process_failure"));
return { imagePath: null };
});
onChange(imagePath);
}
};