mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
reloading user profile on update
This commit is contained in:
parent
9c37711bbf
commit
eea19d43c2
6 changed files with 78 additions and 21 deletions
|
|
@ -3,8 +3,12 @@ import { HydraApi } from "@main/services/hydra-api";
|
|||
import axios from "axios";
|
||||
import fs from "node:fs";
|
||||
import mime from "mime";
|
||||
import { UserProfile } from "@types";
|
||||
|
||||
const patchUserProfile = (displayName: string, profileImageUrl?: string) => {
|
||||
const patchUserProfile = async (
|
||||
displayName: string,
|
||||
profileImageUrl?: string
|
||||
) => {
|
||||
if (profileImageUrl) {
|
||||
return HydraApi.patch("/profile", {
|
||||
displayName,
|
||||
|
|
@ -21,10 +25,9 @@ const updateProfile = async (
|
|||
_event: Electron.IpcMainInvokeEvent,
|
||||
displayName: string,
|
||||
newProfileImagePath: string | null
|
||||
): Promise<any> => {
|
||||
): Promise<UserProfile | null> => {
|
||||
if (!newProfileImagePath) {
|
||||
patchUserProfile(displayName);
|
||||
return;
|
||||
return (await patchUserProfile(displayName)).data;
|
||||
}
|
||||
|
||||
const stats = fs.statSync(newProfileImagePath);
|
||||
|
|
@ -51,8 +54,7 @@ const updateProfile = async (
|
|||
return undefined;
|
||||
});
|
||||
|
||||
console.log(profileImageUrl);
|
||||
patchUserProfile(displayName, profileImageUrl);
|
||||
return (await patchUserProfile(displayName, profileImageUrl)).data;
|
||||
};
|
||||
|
||||
registerEvent("updateProfile", updateProfile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue