mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-22 18:33:56 +00:00
feat: friend request notification adjustments
This commit is contained in:
@@ -16,13 +16,15 @@ const syncFriendRequests = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`)
|
||||
.then((res) => {
|
||||
if (
|
||||
syncState.friendsRequest &&
|
||||
syncState.friendsRequest != null &&
|
||||
syncState.friendsRequest < res.friendRequestCount
|
||||
) {
|
||||
publishNewFriendRequestNotification();
|
||||
}
|
||||
|
||||
syncState.friendsRequest = res.friendRequestCount;
|
||||
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err instanceof UserNotLoggedInError) {
|
||||
|
||||
@@ -81,15 +81,24 @@ export const publishNotificationUpdateReadyToInstall = async (
|
||||
};
|
||||
|
||||
export const publishNewFriendRequestNotification = async () => {
|
||||
const userPreferences = await db.get<string, UserPreferences>(
|
||||
levelKeys.userPreferences,
|
||||
{
|
||||
valueEncoding: "json",
|
||||
}
|
||||
);
|
||||
|
||||
if (!userPreferences.friendRequestNotificationsEnabled) return;
|
||||
|
||||
new Notification({
|
||||
title: t("new_friend_request", {
|
||||
title: t("new_friend_request_title", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
body: t("You have received a new friend request", {
|
||||
body: t("new_friend_request_description", {
|
||||
ns: "notifications",
|
||||
}),
|
||||
icon: trayIcon,
|
||||
});
|
||||
}).show();
|
||||
};
|
||||
|
||||
export const publishCombinedNewAchievementNotification = async (
|
||||
|
||||
Reference in New Issue
Block a user