patching user displayName and profileImageUrl

This commit is contained in:
Zamitto
2024-06-18 12:02:16 -03:00
parent af69509c61
commit 59b2096d06
6 changed files with 33 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ import "./library/remove-game";
import "./library/remove-game-from-library";
import "./misc/open-external";
import "./misc/show-open-dialog";
import "./misc/image-path-to-base-64";
import "./torrenting/cancel-game-download";
import "./torrenting/pause-game-download";
import "./torrenting/resume-game-download";

View File

@@ -0,0 +1,14 @@
import mime from "mime";
import { registerEvent } from "../register-event";
import fs from "node:fs";
const imagePathToBase64 = async (
_event: Electron.IpcMainInvokeEvent,
filePath: string
) => {
const buffer = fs.readFileSync(filePath);
const mimeType = mime.getType(filePath);
return `data:${mimeType};base64,${buffer.toString("base64")}`;
};
registerEvent("imagePathToBase64", imagePathToBase64);

View File

@@ -4,12 +4,11 @@ import axios from "axios";
import fs from "node:fs";
import mime from "mime";
const patchUserProfile = (displayName: string, imageUrl?: string) => {
return;
if (imageUrl) {
const patchUserProfile = (displayName: string, profileImageUrl?: string) => {
if (profileImageUrl) {
return HydraApi.patch("/profile", {
displayName,
imageUrl,
profileImageUrl,
});
} else {
return HydraApi.patch("/profile", {