builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
259 stars 258 forks source link

Fix enum switch for Kotlin 1.7.10 #457

Closed bounty1342 closed 1 year ago

bounty1342 commented 1 year ago

Describe the bug

Compilation issue with Kotlin 1.7.10.
/builds/projet-root/.pub-cache/hosted/pub.dartlang.org/device_calendar-4.2.0/android/src/main/kotlin/com/builttoroam/devicecalendar/CalendarDelegate.kt: (772, 9): 'when' expression must be exhaustive, add necessary 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY' branches or 'else' branch instead
[282](https://gitlab.socrate.vsct.fr/projet-root/-/jobs/14970613#L282)FAILURE: Build failed with an exception.

Actual code

       when (rfcRecurrenceRule.freq) {             Freq.WEEKLY, Freq.MONTHLY, Freq.YEARLY -> {                 recurrenceRule.daysOfWeek = rfcRecurrenceRule.byDayPart?.mapNotNull {                     DayOfWeek.values().find { dayOfWeek -> dayOfWeek.ordinal == it.weekday.ordinal }                 }?.toMutableList()             }         }

Proposed correction code

       when (rfcRecurrenceRule.freq) {             Freq.WEEKLY, Freq.MONTHLY, Freq.YEARLY -> {                 recurrenceRule.daysOfWeek = rfcRecurrenceRule.byDayPart?.mapNotNull {                     DayOfWeek.values().find { dayOfWeek -> dayOfWeek.ordinal == it.weekday.ordinal }                 }?.toMutableList()             }             else -> null         }

Let me know if you need more information.

Regards

IVLIVS-III commented 1 year ago

The code change itself looks good. Could you please open an identical PR to the develop-branch instead? develop is the main/master branch of this project.

bounty1342 commented 1 year ago

Apparently something you fix in the develop branch already :

    val frequency = when (rfcRecurrenceRule.freq) {
        RruleFreq.YEARLY -> RruleFreq.YEARLY
        RruleFreq.MONTHLY -> RruleFreq.MONTHLY
        RruleFreq.WEEKLY -> RruleFreq.WEEKLY
        RruleFreq.DAILY -> RruleFreq.DAILY
        else -> null
    } ?: return null
    //Avoid handling HOURLY/MINUTELY/SECONDLY frequencies for now

Do you have any ETA for a new release or maybe push the fix on release ? I can also use the fork in the meantime ;)

IVLIVS-III commented 1 year ago

Unfortunately, I cannot give an ETA for the new release. See https://github.com/builttoroam/device_calendar/pull/445 which tracks the progress. Looks like the only thing blocking a new release at the moment is achieving a bit more compatibility with the RecurrenceRule implementation of versions < 5.0.

Personally, I'm most likely not able to put enough work into this project to push the (pre-)release within two / three weeks. Early December I could have more time, no promises tho.

thomassth commented 1 year ago

Closing this since apparently it's fixed

Also this is submitted to the wrong branch. Please submit PR to develop instead