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", "new_update_available": "Versão {{version}} disponível",
"restart_to_install_update": "Reinicia o Hydra para instalar a nova versão", "restart_to_install_update": "Reinicia o Hydra para instalar a nova versão",
"new_friend_request_title": "Novo pedido de amizade", "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": { "system_tray": {
"open": "Abrir o Hydra", "open": "Abrir o Hydra",

View File

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

View File

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

View File

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

View File

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