Skip to content

Chat View Model#72

Merged
5eli merged 11 commits into
developmentfrom
chat_view_model
Jun 11, 2026
Merged

Chat View Model#72
5eli merged 11 commits into
developmentfrom
chat_view_model

Conversation

@5eli

@5eli 5eli commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Context
refactored Chat logic into ChatViewModel

Description
Moved chat functions from GameViewModel into ChatViewModel and updated tests
Changes in the codebase:

Files changed:
GameViewModel.kt, ChatViewModel.kt. GameViewModelTest.kt, ChatViewModelTest,kt, LobbyScreen.kt, NavGraph.kt, GameScreenWrapper.kt

@the-only-queen-anna the-only-queen-anna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grundsätzlich bin ich einverstanden, allerdings würde ich mir noch folgende Änderungen bzw. Erweiterungen wünschen:

  • Auslagern der "destinations" in das Repository oder den Controller dazu
  • Einführen eines ChatWebSocketController (oder so), damit der Chat und das Game entkoppelt werden (einfach die Methoden aus dem Game Controller rauskopieren in einen neuen Controller und den verwenden)
  • Das Repository richtig nutzen, und zwar soll das ViewModel nur die Nachricht weiterleiten, das Repository mappt dann auf das dto und leitet sie an den korrekten Pfad weiter, das ViewModel sollte nichts von der WebSocket Logik wissen.

Das mit dem Repository würde ich noch in dieser PR ändern, der Controller kann sonst eine eigene werden auch.

Siehe Kommentare im Code :)

),
)
val uiState: StateFlow<ChatUiState> = _uiState.asStateFlow()
@HiltViewModel

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supi, hilt macht das viel angenehmer

content: String,
) {
viewModelScope.launch {
chatRepository.sendMessage("/app/chat/$lobbyCode/$team", username, content)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das ViewModel sollte nichts von den Destinations wissen, das ist schon Socket-Logik

@5eli

5eli commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator Author

die changes sollten jetzt (hoffentlich) richtig sein

@sonarqubecloud

Copy link
Copy Markdown

@the-only-queen-anna the-only-queen-anna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, danke für die Änderungen :)

@5eli 5eli merged commit 8e31b23 into development Jun 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants