mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: get user static image on notifications
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import { PythonRPC } from "@main/services/python-rpc";
|
import { PythonRPC } from "@main/services/python-rpc";
|
||||||
|
|
||||||
const processProfileImage = async (
|
const processProfileImageEvent = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
path: string
|
path: string
|
||||||
) => {
|
) => {
|
||||||
|
return processProfileImage(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const processProfileImage = async (path: string) => {
|
||||||
return PythonRPC.rpc
|
return PythonRPC.rpc
|
||||||
.post<{
|
.post<{
|
||||||
imagePath: string;
|
imagePath: string;
|
||||||
@@ -13,4 +17,4 @@ const processProfileImage = async (
|
|||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("processProfileImage", processProfileImage);
|
registerEvent("processProfileImage", processProfileImageEvent);
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ import { db, levelKeys, themesSublevel } from "@main/level";
|
|||||||
import { restartAndInstallUpdate } from "@main/events/autoupdater/restart-and-install-update";
|
import { restartAndInstallUpdate } from "@main/events/autoupdater/restart-and-install-update";
|
||||||
import { SystemPath } from "../system-path";
|
import { SystemPath } from "../system-path";
|
||||||
import { getThemeSoundPath } from "@main/helpers";
|
import { getThemeSoundPath } from "@main/helpers";
|
||||||
|
import { processProfileImage } from "@main/events/profile/process-profile-image";
|
||||||
|
|
||||||
|
const getStaticImage = async (path: string) => {
|
||||||
|
return processProfileImage(path)
|
||||||
|
.then((response) => response.imagePath)
|
||||||
|
.catch(() => path);
|
||||||
|
};
|
||||||
|
|
||||||
async function downloadImage(url: string | null) {
|
async function downloadImage(url: string | null) {
|
||||||
if (!url) return undefined;
|
if (!url) return undefined;
|
||||||
@@ -31,8 +38,9 @@ async function downloadImage(url: string | null) {
|
|||||||
response.data.pipe(writer);
|
response.data.pipe(writer);
|
||||||
|
|
||||||
return new Promise<string | undefined>((resolve) => {
|
return new Promise<string | undefined>((resolve) => {
|
||||||
writer.on("finish", () => {
|
writer.on("finish", async () => {
|
||||||
resolve(outputPath);
|
const staticImagePath = await getStaticImage(outputPath);
|
||||||
|
resolve(staticImagePath);
|
||||||
});
|
});
|
||||||
writer.on("error", () => {
|
writer.on("error", () => {
|
||||||
logger.error("Failed to download image", { url });
|
logger.error("Failed to download image", { url });
|
||||||
|
|||||||
Reference in New Issue
Block a user