Chat toolbar: redraw the unread badge for every message, and keep the count out of the toast #23231
BackVolobox task: VolosoftWorkspace#1929
Problem
Two users with the Chat Messaging permission are signed in. One is on a page other than Chat, and the other sends a message. The receiver gets the toast, but:
- The unread badge on the toolbar's chat icon never appears (MudBlazor). The ABP 11.0.0-rc.2 template smoke test (CHAT-02) failed this way on three of the four MudBlazor combinations:
nolayers-webapp-mssql,nolayers-wasm-pgandms-server-sqlite. It failed again onnolayers-wasm-pgin a second run.app-server-pgpassed, which fits a race. - The toast text ends with the unread count: "Smoke Feature: hello m-mwf5vyypdcq1" (Blazorise and MudBlazor).
In MessagesToolbarItem's ReceiveMessage handler:
TotalUnreadMessageCount++;
if (!IsChatPageOpened())
{
…
if (ChatHubConnectionService.LastNotificationMessageId == message.Id)
{
return; // leaves before StateHasChanged
}
ChatHubConnectionService.LastNotificationMessageId = message.Id;
await Notify.Info(title: L["NewChatMessage"], message: senderTitle + ": " + shortMessage + TotalUnreadMessageCount);
}
await InvokeAsync(StateHasChanged);
Every toolbar item on the page gets the message: each page load opens two chat hub connections. The item that loses the LastNotificationMessageId check returns before StateHasChanged, so its count goes up but its badge is never redrawn. When that item is the one in the visible toolbar, no badge appears.
Change
In both Volo.Chat.Blazor and Volo.Chat.Blazor.MudBlazor:
- Only the toast is skipped for a message that has already been notified.
StateHasChangedalways runs, so every toolbar item redraws its badge. - The toast text is
"{sender}: {message}", without the unread count.
How it was checked
Volo.Chat.BlazorandVolo.Chat.Blazor.MudBlazorbuild (0 errors).- Not run in a solution yet.
To try it: in a MudBlazor solution with --chat, keep the receiver on another page and send a message. The badge shows 1 at once, and the toast shows the message as typed.
The toast's raw <strong>…</strong><br/> in MudBlazor comes from Volo.Abp.MudBlazorUI and is fixed in abpframework/abp#26499 (task 1930).
🤖 Generated with Claude Code