-
Notifications
You must be signed in to change notification settings - Fork 0
more-card-options #81
Conversation
Reviewer's GuideThis pull request implements card list duplicate, copy, and move workflows end-to-end, refactors repeated logic into a shared helper and expression bodies, centralizes keyboard state in a new repository, enhances UI theming and toast messaging, and cleans up DAO and repository interfaces for streamlined operations. Class diagram for new and updated card list operationsclassDiagram
class NavViewModel {
+suspend copyCardList(deckId: Int): Pair<Boolean, String>
+suspend moveCardList(deckId: Int): Pair<Boolean, String>
+suspend getAllDecks(): List<Deck>
+deselectAll()
+selectAll()
}
class CardTypeRepository {
<<interface>>
+suspend copyCardList(deck: Deck)
+suspend moveCardList(deck: Deck)
+deselectAll()
}
class OfflineCardTypeRepository {
+suspend copyCardList(deck: Deck)
+suspend moveCardList(deck: Deck)
+deselectAll()
}
class CardTypesDao {
+suspend copyCardList(cts: List<CT>, deck: Deck)
+suspend moveCardList(cts: List<CT>, deck: Deck)
+fun getMaxDCNumber(deckId: Int): Int?
}
class Deck
class CT
NavViewModel --> CardTypeRepository
OfflineCardTypeRepository ..|> CardTypeRepository
OfflineCardTypeRepository --> CardTypesDao
CardTypesDao --> Deck
CardTypesDao --> CT
NavViewModel --> Deck
Class diagram for KeyboardSelectionRepository and related stateclassDiagram
class KeyboardSelectionRepository {
<<interface>>
+showKatexKeyboard: StateFlow<Boolean>
+selectedKB: StateFlow<SelectedKeyboard?>
+resetOffset: StateFlow<Boolean>
+updateSelectedKB(selectedKeyboard: SelectedKeyboard)
+resetSelectedKB()
+retrieveKB(retrievedKB: SelectedKeyboard?)
+toggleKeyboard()
+resetOffset()
+resetDone()
+resetKeyboardStuff()
+retrieveShowKB(show: Boolean)
}
class KeyboardSelectionRepoImpl {
+showKatexKeyboard
+selectedKB
+resetOffset
+updateSelectedKB(selectedKeyboard: SelectedKeyboard)
+resetSelectedKB()
+retrieveKB(retrievedKB: SelectedKeyboard?)
+toggleKeyboard()
+resetOffset()
+resetDone()
+resetKeyboardStuff()
+retrieveShowKB(show: Boolean)
}
class SelectedKeyboard
KeyboardSelectionRepoImpl ..|> KeyboardSelectionRepository
KeyboardSelectionRepository --> SelectedKeyboard
Class diagram for new UI state and dialog modelsclassDiagram
class Decision {
<<sealed class>>
Move
Copy
Idle
}
class Dialogs {
+showDelete: Boolean
+showMoveCopy: Boolean
+showDuplicate: Boolean
}
Decision <|-- Move
Decision <|-- Copy
Decision <|-- Idle
Dialogs --> Decision
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @xanderlmk - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Infinite recursion in semiTransButtonColor default case (link)
- Infinite recursion in choiceColor default branch (link)
General comments:
- There’s a lot of duplicated code between your
copyCardListandmoveCardListmethods in both the ViewModel and DAO—consider extracting the shared logic into a helper or service to reduce repetition. - The DAO now contains complex business logic (building new card entities, deck‐number calculations, etc.); it’d be better to push that heavy lifting into the repository layer so the DAO stays focused on straightforward database operations.
- The
showToastMessagehack of embedding and parsing"$$**"in strings is fragile—use Android’s string placeholders (e.g.%1$s) in your resources and letgetString(R.string.some_format, param)handle formatting instead of manual substring logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a lot of duplicated code between your `copyCardList` and `moveCardList` methods in both the ViewModel and DAO—consider extracting the shared logic into a helper or service to reduce repetition.
- The DAO now contains complex business logic (building new card entities, deck‐number calculations, etc.); it’d be better to push that heavy lifting into the repository layer so the DAO stays focused on straightforward database operations.
- The `showToastMessage` hack of embedding and parsing `"$$**"` in strings is fragile—use Android’s string placeholders (e.g. `%1$s`) in your resources and let `getString(R.string.some_format, param)` handle formatting instead of manual substring logic.
## Individual Comments
### Comment 1
<location> `app/src/main/java/com/belmontCrest/cardCrafter/ui/theme/GetUIStyle.kt:51` </location>
<code_context>
- ifDarkAndCute() -> semiTransDarkCuteButton
- ifDarkAndNotCute() -> semiTransDarkButton
- ifNotDarkAndCute() -> semiTransCuteButton
- else -> semiTransButtonColor
- }
+ fun semiTransButtonColor(): Color = when {
</code_context>
<issue_to_address>
Infinite recursion in semiTransButtonColor default case
The else branch should return the default color property, not call semiTransButtonColor() recursively.
</issue_to_address>
### Comment 2
<location> `app/src/main/java/com/belmontCrest/cardCrafter/ui/theme/GetUIStyle.kt:100` </location>
<code_context>
- if (isCuteTheme) {
- cuteChoiceColor
- } else {
- choiceColor
- }
+ choiceColor
</code_context>
<issue_to_address>
Infinite recursion in choiceColor default branch
The else branch should return a default color constant, not call choiceColor() recursively.
</issue_to_address>
### Comment 3
<location> `app/src/main/java/com/belmontCrest/cardCrafter/localDatabase/dbInterface/daoInterfaces/deckAndCardDao/CardTypesDao.kt:208` </location>
<code_context>
+ /** Copy the selected cards into a new deck */
+ @Transaction
+ suspend fun copyCardList(cts: List<CT>, deck: Deck) {
+ cts.map { ct ->
+ val newDeckCardNumber = returnCardDeckNum(deck.id)
+ when (ct) {
</code_context>
<issue_to_address>
Use forEach instead of map for side-effect operations
map creates a list that's not used; forEach better indicates intent for side effects.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
cts.map { ct ->
val newDeckCardNumber = returnCardDeckNum(deck.id)
when (ct) {
=======
cts.forEach { ct ->
val newDeckCardNumber = returnCardDeckNum(deck.id)
when (ct) {
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| cts.map { ct -> | ||
| val newDeckCardNumber = returnCardDeckNum(deck.id) | ||
| when (ct) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Use forEach instead of map for side-effect operations
map creates a list that's not used; forEach better indicates intent for side effects.
| cts.map { ct -> | |
| val newDeckCardNumber = returnCardDeckNum(deck.id) | |
| when (ct) { | |
| cts.forEach { ct -> | |
| val newDeckCardNumber = returnCardDeckNum(deck.id) | |
| when (ct) { |
Summary by Sourcery
Add card-list management options (copy, move, duplicate, delete), extract keyboard selection into its own repository, refactor DAOs and repositories for bulk operations, centralize review count updates in a reusable class, and streamline UI styling and platform utilities
New Features:
Enhancements: