mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-25 20:01:03 +00:00
feat: code adjustments
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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", {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user