REFACTOR: Break ChatViewModel into smaller specialized files

- Created ChatState.kt for centralized state management
- Created DataManager.kt for persistence operations
- Created MessageManager.kt for message handling and deduplication
- Created ChannelManager.kt for channel operations and encryption
- Created PrivateChatManager.kt for private chat functionality
- Created CommandProcessor.kt for IRC-style command processing

ChatViewModel.kt reduced from 1000+ lines to ~300 lines while maintaining 100% functionality.
All existing functionality preserved, just better organized.
This commit is contained in:
callebtc
2025-07-09 00:42:43 +02:00
parent 6d22aa7315
commit 56824b6594
9 changed files with 1732 additions and 1069 deletions
@@ -112,7 +112,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
// Input area - stays at bottom
ChatInputSection(
messageText = messageText,
onMessageTextChange = { newText ->
onMessageTextChange = { newText: String ->
messageText = newText
viewModel.updateCommandSuggestions(newText)
},
@@ -124,7 +124,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
},
showCommandSuggestions = showCommandSuggestions,
commandSuggestions = commandSuggestions,
onSuggestionClick = { suggestion ->
onSuggestionClick = { suggestion: CommandSuggestion ->
messageText = viewModel.selectCommandSuggestion(suggestion)
},
selectedPrivatePeer = selectedPrivatePeer,
@@ -199,8 +199,8 @@ private fun ChatInputSection(
onMessageTextChange: (String) -> Unit,
onSend: () -> Unit,
showCommandSuggestions: Boolean,
commandSuggestions: List<ChatViewModel.CommandSuggestion>,
onSuggestionClick: (ChatViewModel.CommandSuggestion) -> Unit,
commandSuggestions: List<CommandSuggestion>,
onSuggestionClick: (CommandSuggestion) -> Unit,
selectedPrivatePeer: String?,
currentChannel: String?,
nickname: String,