Notification Dialog Does Not Indicate Intended Recipient
Changes: - Updated AdminMenu::handleNotificationEvent, CustomerMenu::handleNotificationEvent, and TechnicianMenu::handleNotificationEvent to retrieve the authenticated user and pass their name to displayNewNotification(). - Modified Menu::handleAccountDisabledEvent to append the authenticated user’s name to the message box title when available. - Refactored displayNewNotification() in MenuHelper.h to accept the authenticated user’s name as an additional parameter. - Enhanced notification display logic to append the user’s name to the notification title when present. - Added null checks to ensure safe handling when no authenticated user exists. FIxes #2080
This commit is contained in:
@@ -163,7 +163,13 @@ Return type: void
|
|||||||
void AdminMenu::handleNotificationEvent()
|
void AdminMenu::handleNotificationEvent()
|
||||||
{
|
{
|
||||||
auto notifications = m_controller.getNotifications();
|
auto notifications = m_controller.getNotifications();
|
||||||
displayNewNotification(notifications);
|
const User* authenticatedUser = m_controller.getAuthenticatedUser();
|
||||||
|
std::string name;
|
||||||
|
if (authenticatedUser)
|
||||||
|
{
|
||||||
|
name = authenticatedUser->getName();
|
||||||
|
}
|
||||||
|
displayNewNotification(notifications, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -134,7 +134,13 @@ Return type: void
|
|||||||
void CustomerMenu::handleNotificationEvent()
|
void CustomerMenu::handleNotificationEvent()
|
||||||
{
|
{
|
||||||
auto notifications = m_controller.getNotifications();
|
auto notifications = m_controller.getNotifications();
|
||||||
displayNewNotification(notifications);
|
const User* authenticatedUser = m_controller.getAuthenticatedUser();
|
||||||
|
std::string name;
|
||||||
|
if (authenticatedUser)
|
||||||
|
{
|
||||||
|
name = authenticatedUser->getName();
|
||||||
|
}
|
||||||
|
displayNewNotification(notifications, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -133,10 +133,16 @@ Return type: void
|
|||||||
void Menu::handleAccountDisabledEvent()
|
void Menu::handleAccountDisabledEvent()
|
||||||
{
|
{
|
||||||
m_isMenuActive.store(false);
|
m_isMenuActive.store(false);
|
||||||
|
const User* authenticatedUser = m_controller.getAuthenticatedUser();
|
||||||
|
std::string messageTitle = "Account Disabled";
|
||||||
|
if (authenticatedUser)
|
||||||
|
{
|
||||||
|
messageTitle += " - " + authenticatedUser->getName();
|
||||||
|
}
|
||||||
MessageBoxA(
|
MessageBoxA(
|
||||||
GetConsoleWindow(),
|
GetConsoleWindow(),
|
||||||
"Your account has been disabled.",
|
"Your account has been disabled.",
|
||||||
"Account Disabled",
|
messageTitle.c_str(),
|
||||||
MB_OK |
|
MB_OK |
|
||||||
MB_ICONWARNING |
|
MB_ICONWARNING |
|
||||||
MB_SETFOREGROUND |
|
MB_SETFOREGROUND |
|
||||||
|
|||||||
@@ -1415,9 +1415,10 @@ Description: Displays the most recent notification from the supplied
|
|||||||
notification collection.
|
notification collection.
|
||||||
Parameter: util::Vector<const Notification*> notifications -
|
Parameter: util::Vector<const Notification*> notifications -
|
||||||
collection of notifications
|
collection of notifications
|
||||||
|
const std::string& - The name of the user currently authenticated with the system
|
||||||
Return type: void
|
Return type: void
|
||||||
*/
|
*/
|
||||||
inline void displayNewNotification(util::Vector<const Notification*> notifications)
|
inline void displayNewNotification(util::Vector<const Notification*> notifications, const std::string& name)
|
||||||
{
|
{
|
||||||
const Notification* notification = nullptr;
|
const Notification* notification = nullptr;
|
||||||
size_t numberOfNotifications = notifications.getSize();
|
size_t numberOfNotifications = notifications.getSize();
|
||||||
@@ -1435,10 +1436,18 @@ inline void displayNewNotification(util::Vector<const Notification*> notificatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageBoxA(
|
if (notification)
|
||||||
GetConsoleWindow(),
|
{
|
||||||
notification->getMessage().c_str(),
|
std::string messageTitle = notification->getTitle();
|
||||||
notification->getTitle().c_str(),
|
if (!name.empty())
|
||||||
MB_OK |
|
{
|
||||||
MB_ICONINFORMATION);
|
messageTitle += " - " + name;
|
||||||
|
}
|
||||||
|
MessageBoxA(
|
||||||
|
GetConsoleWindow(),
|
||||||
|
notification->getMessage().c_str(),
|
||||||
|
messageTitle.c_str(),
|
||||||
|
MB_OK |
|
||||||
|
MB_ICONINFORMATION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,13 @@ Return type: void
|
|||||||
void TechnicianMenu::handleNotificationEvent()
|
void TechnicianMenu::handleNotificationEvent()
|
||||||
{
|
{
|
||||||
auto notifications = m_controller.getNotifications();
|
auto notifications = m_controller.getNotifications();
|
||||||
displayNewNotification(notifications);
|
const User* authenticatedUser = m_controller.getAuthenticatedUser();
|
||||||
|
std::string name;
|
||||||
|
if (authenticatedUser)
|
||||||
|
{
|
||||||
|
name = authenticatedUser->getName();
|
||||||
|
}
|
||||||
|
displayNewNotification(notifications, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user