-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(libanki): convert Consts to enums #17431
Conversation
5a067d4
to
053f251
Compare
@Arthur-Milchior Unblocked |
053f251
to
84e33c4
Compare
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.
Incomplete review, I'm not going to have time to finish it
@@ -246,12 +246,12 @@ open class AnkiDroidJsAPI(private val activity: AbstractFlashcardViewer) { | |||
"cardMod" -> convertToByteArray(apiContract, currentCard.mod) | |||
"cardId" -> convertToByteArray(apiContract, currentCard.id) | |||
"cardNid" -> convertToByteArray(apiContract, currentCard.nid) | |||
"cardType" -> convertToByteArray(apiContract, currentCard.type) | |||
"cardType" -> convertToByteArray(apiContract, currentCard.type.ordinal) |
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.
! Should be a constant, not dependent on the enum order
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt
Outdated
Show resolved
Hide resolved
84e33c4
to
e551396
Compare
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.
Doesn't compile
Last round of feedback. Let's get this in
fun reviewable() = | ||
when (this) { | ||
MANUALLY_BURIED, SIBLING_BURIED, SUSPENDED -> false | ||
NEW, LRN, REV, DAY_LEARN_RELEARN, PREVIEW -> true |
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.
This doesn't make sense to me as a name. Preview is reviewable?
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.
Would "viewable" be better?
I'd be fine with a NOTREACHED() for the "preview" case because we should never reach it.
194ac14
to
74c7155
Compare
1148af6
to
fdc3513
Compare
e9f22c1
to
5cd6e10
Compare
d0799fc
to
232c806
Compare
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.
Cheers!
232c806
to
4c2933a
Compare
I hope I understood correctly what you asked me to do with the unknown case. |
Needs Would also question why the pre-commit hook isn't firing. This may want to be rebased on |
This improves typing. It's also clearer what will be the behavior of the app if we encounter code with a new kind of card type.
This improve the typing.
Improve typing
4c2933a
to
07d0068
Compare
sealed class CardType( | ||
val code: Int, | ||
) { | ||
object New : CardType(0) |
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.
prefer data object
Merging this now so it doesn't take any more conflicts. |
This PR should be merged after #17430. It contains #17430 and removing #17430 would create a ton of merge conflict.
It transforms IntDef of Consts.kt into enum