feat: auto install default false on linux and friend request notification

This commit is contained in:
Zamitto
2025-03-10 18:57:13 -03:00
parent 497f5e7742
commit b344a1850a
6 changed files with 92 additions and 15 deletions

View File

@@ -4,11 +4,17 @@ import updater from "electron-updater";
const { autoUpdater } = updater;
const restartAndInstallUpdate = async (_event: Electron.IpcMainInvokeEvent) => {
export const restartAndInstallUpdate = async () => {
autoUpdater.removeAllListeners();
if (app.isPackaged) {
autoUpdater.quitAndInstall(false);
}
};
registerEvent("restartAndInstallUpdate", restartAndInstallUpdate);
const restartAndInstallUpdateEvent = async (
_event: Electron.IpcMainInvokeEvent
) => {
restartAndInstallUpdate();
};
registerEvent("restartAndInstallUpdate", restartAndInstallUpdateEvent);

View File

@@ -1,17 +1,35 @@
import { registerEvent } from "../register-event";
import { HydraApi } from "@main/services";
import { publishNewFriendRequestNotification } from "@main/services/notifications";
import { UserNotLoggedInError } from "@shared";
import type { FriendRequestSync } from "@types";
interface SyncState {
friendsRequest: number | null;
}
const syncState: SyncState = {
friendsRequest: null,
};
const syncFriendRequests = async (_event: Electron.IpcMainInvokeEvent) => {
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`).catch(
(err) => {
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`)
.then((res) => {
if (
syncState.friendsRequest &&
syncState.friendsRequest < res.friendRequestCount
) {
publishNewFriendRequestNotification();
}
syncState.friendsRequest = res.friendRequestCount;
})
.catch((err) => {
if (err instanceof UserNotLoggedInError) {
return { friendRequests: [] };
return { friendRequestCount: 0 } as FriendRequestSync;
}
throw err;
}
);
});
};
registerEvent("syncFriendRequests", syncFriendRequests);