- updated notifications functionality;

This commit is contained in:
Vitalii Kiiko
2025-01-03 08:50:23 +01:00
parent b9a60ecc27
commit 63b71ce20e
5 changed files with 11 additions and 11 deletions

View File

@@ -70,12 +70,12 @@ const NotificationsSidebar = () => {
const role = pathOr('', ['role', 'roleType'], userData);
if (currentSubscription) {
console.log('UNsubscribed')
//console.log('UNsubscribed')
currentSubscription.unsubscribe();
setCurrentSubscription(null);
}
if (isConnected && userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
setLoading(true);
NotificationService.getNotifications(
userData.id,
@@ -86,10 +86,10 @@ const NotificationsSidebar = () => {
['companyId', chosenCompanyId]
]
);
if (socket.current) {
if (isConnected && socket.current) {
subscribeTo(`/topic/notifications_user_${userData.id}_company_${chosenCompanyId}`)
}
} else if (isConnected && userData.id && role !== 'ROLE_BENEFICIARY') {
} else if (userData.id && role !== 'ROLE_BENEFICIARY') {
setLoading(true);
NotificationService.getNotifications(
userData.id,
@@ -99,7 +99,7 @@ const NotificationsSidebar = () => {
['status', status]
]
);
if (socket.current) {
if (isConnected && socket.current) {
subscribeTo(`/topic/notifications_user_${userData.id}`)
}
}