mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
patching user displayName and profileImageUrl
This commit is contained in:
parent
af69509c61
commit
59b2096d06
6 changed files with 33 additions and 10 deletions
1
src/renderer/src/declaration.d.ts
vendored
1
src/renderer/src/declaration.d.ts
vendored
|
|
@ -96,6 +96,7 @@ declare global {
|
|||
|
||||
/* Misc */
|
||||
openExternal: (src: string) => Promise<void>;
|
||||
imagePathToBase64: (filePath: string) => Promise<string>;
|
||||
getVersion: () => Promise<string>;
|
||||
ping: () => string;
|
||||
getDefaultDownloadsPath: () => Promise<string>;
|
||||
|
|
|
|||
|
|
@ -18,22 +18,28 @@ export const UserEditProfileModal = ({
|
|||
}: UserEditProfileModalProps) => {
|
||||
const [displayName, setDisplayName] = useState(userProfile.displayName);
|
||||
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
||||
const [newImageBase64, setNewImageBase64] = useState<string | null>(null);
|
||||
|
||||
const handleChangeProfileAvatar = async () => {
|
||||
const { filePaths } = await window.electron.showOpenDialog({
|
||||
properties: ["openFile"],
|
||||
filters: [
|
||||
{
|
||||
name: "Profile avatar",
|
||||
extensions: ["jpg", "png", "gif"],
|
||||
name: "Profile image",
|
||||
extensions: ["jpg", "png", "gif", "webp", "jpeg"],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const path = filePaths[0];
|
||||
console.log(path);
|
||||
if (filePaths && filePaths.length > 0) {
|
||||
const path = filePaths[0];
|
||||
|
||||
setNewImagePath(path);
|
||||
window.electron.imagePathToBase64(path).then((base64) => {
|
||||
setNewImageBase64(base64);
|
||||
});
|
||||
|
||||
setNewImagePath(path);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveProfile = async () => {
|
||||
|
|
@ -67,7 +73,7 @@ export const UserEditProfileModal = ({
|
|||
<img
|
||||
className={styles.profileAvatar}
|
||||
alt={userProfile.displayName}
|
||||
src={newImagePath ?? userProfile.profileImageUrl}
|
||||
src={newImageBase64 ?? userProfile.profileImageUrl}
|
||||
/>
|
||||
) : (
|
||||
<PersonIcon size={72} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue