Class ChatMessageManager
Owns chat message storage, formatting, and mutation. Fires MessagesChanged when a channel's message list is modified so the UI layer can refresh.
public sealed class ChatMessageManager
- Inheritance
-
ChatMessageManager
- Inherited Members
Constructors
ChatMessageManager()
public ChatMessageManager()
Fields
ContentIndentCols
Columns before message text starts: "HH:mm " + nick column + " │ ".
public const int ContentIndentCols = 21
Field Value
NickColWidth
Columns reserved for the right-aligned nick column (WeeChat-style).
public const int NickColWidth = 12
Field Value
Properties
CurrentChannel
The currently active channel (used for unread tracking and @mention detection).
public string CurrentChannel { get; set; }
Property Value
CurrentUser
public string CurrentUser { get; }
Property Value
LastReadIds
Last message the user has read per channel — persisted by the orchestrator so unread/mention state can be seeded from history on the next connect.
public IReadOnlyDictionary<string, Guid> LastReadIds { get; }
Property Value
MentionChannels
Channels with an unread @mention of the current user (cleared by ClearUnread(string)).
public IReadOnlySet<string> MentionChannels { get; }
Property Value
- IReadOnlySet<string>
Methods
AddMessage(MessageDto)
Format and store a received message. Increments unread count if not the active channel.
public void AddMessage(MessageDto message)
Parameters
messageMessageDto
AddStatusMessage(string, string, string)
Add a status change message to a channel with colored styling.
public void AddStatusMessage(string channelName, string username, string status)
Parameters
AddSystemMessage(string, string)
Add a system/informational message to a channel with colored styling.
public void AddSystemMessage(string channelName, string text)
Parameters
ClearAll()
Reset all message state (used on disconnect).
public void ClearAll()
ClearChannelMessages(string)
Clear all messages from a specific channel.
public void ClearChannelMessages(string channelName)
Parameters
channelNamestring
ClearUnread(string)
public void ClearUnread(string channelName)
Parameters
channelNamestring
GetMessages(string)
public List<ChatLine>? GetMessages(string channelName)
Parameters
channelNamestring
Returns
- List<ChatLine>
GetUnreadCount(string)
public int GetUnreadCount(string channelName)
Parameters
channelNamestring
Returns
LoadHistory(string, List<MessageDto>, Guid?)
Load historical messages into a channel, replacing any existing messages.
When lastReadId is given (persisted from a previous session),
messages after it seed the unread count, @mention highlight, and the
"new messages" marker — so activity that happened while offline still lights up.
public void LoadHistory(string channelName, List<MessageDto> messages, Guid? lastReadId = null)
Parameters
channelNamestringmessagesList<MessageDto>lastReadIdGuid?
PrependHistory(string, List<MessageDto>)
Prepend older messages at the front of a channel's buffer, skipping any that are already present. Fires HistoryPrepended when new lines are actually inserted.
public void PrependHistory(string channelName, List<MessageDto> olderMessages)
Parameters
channelNamestringolderMessagesList<MessageDto>
RemoveMessage(string, Guid)
Remove all lines associated with a specific message ID.
public void RemoveMessage(string channelName, Guid messageId)
Parameters
SetChatWidth(int)
public void SetChatWidth(int width)
Parameters
widthint
SetCurrentUser(string)
public void SetCurrentUser(string username)
Parameters
usernamestring
Events
HistoryPrepended
Fired after older messages are prepended to a channel's buffer. Parameter is the channel name.
public event Action<string>? HistoryPrepended
Event Type
MessagesChanged
Fired after any mutation to a channel's messages. Parameter is the channel name.
public event Action<string>? MessagesChanged