feat: code adjustments

This commit is contained in:
Zamitto
2025-03-10 20:21:17 -03:00
parent 85efc23c25
commit d8a4eaaa66
5 changed files with 11 additions and 11 deletions

View File

@@ -261,7 +261,7 @@
"new_update_available": "Versão {{version}} disponível",
"restart_to_install_update": "Reinicia o Hydra para instalar a nova versão",
"new_friend_request_title": "Novo pedido de amizade",
"new_friend_request_description": "Você recebeu um novo pedido de amizade"
"new_friend_request_description": "Recebeste um novo pedido de amizade"
},
"system_tray": {
"open": "Abrir o Hydra",

View File

@@ -4,7 +4,7 @@ import updater from "electron-updater";
const { autoUpdater } = updater;
export const restartAndInstallUpdate = async () => {
export const restartAndInstallUpdate = () => {
autoUpdater.removeAllListeners();
if (app.isPackaged) {
autoUpdater.quitAndInstall(false);

View File

@@ -5,24 +5,24 @@ import { UserNotLoggedInError } from "@shared";
import type { FriendRequestSync } from "@types";
interface SyncState {
friendsRequest: number | null;
friendRequestCount: number | null;
}
const syncState: SyncState = {
friendsRequest: null,
friendRequestCount: null,
};
const syncFriendRequests = async (_event: Electron.IpcMainInvokeEvent) => {
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`)
.then((res) => {
if (
syncState.friendsRequest != null &&
syncState.friendsRequest < res.friendRequestCount
syncState.friendRequestCount != null &&
syncState.friendRequestCount < res.friendRequestCount
) {
publishNewFriendRequestNotification();
}
syncState.friendsRequest = res.friendRequestCount;
syncState.friendRequestCount = res.friendRequestCount;
return res;
})

View File

@@ -81,14 +81,14 @@ export const publishNotificationUpdateReadyToInstall = async (
};
export const publishNewFriendRequestNotification = async () => {
const userPreferences = await db.get<string, UserPreferences>(
const userPreferences = await db.get<string, UserPreferences | null>(
levelKeys.userPreferences,
{
valueEncoding: "json",
}
);
if (!userPreferences.friendRequestNotificationsEnabled) return;
if (!userPreferences?.friendRequestNotificationsEnabled) return;
new Notification({
title: t("new_friend_request_title", {

View File

@@ -29,14 +29,14 @@ export class UpdateManager {
}
if (process.platform === "linux") {
const userPreferences = await db.get<string, UserPreferences>(
const userPreferences = await db.get<string, UserPreferences | null>(
levelKeys.userPreferences,
{
valueEncoding: "json",
}
);
return userPreferences.enableAutoInstall === true;
return userPreferences?.enableAutoInstall === true;
}
return false;