patchthecode/JTAppleCalendar

Selecting a large date range all at once shows a delay before loading app [Expected]. Suggestions wanted on how to improve this code.

Offen

#1.201 geöffnet am 27.12.2019

 (12 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Swift (819 Forks)batch import
help wanted

Repository-Metriken

Stars
 (7.660 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Version Number: 8.0.2

Description

Function "selectDates(from startDate: Date, to endDate: Date, triggerSelectionDelegate: Bool = true, keepSelectionIfMultiSelectionAllowed: Bool = false)" freeze main thread in my app when I pass too long period between startDate and endDate (about six and more months).

Steps To Reproduce

func calendar(_ calendar: JTACMonthView, didSelectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath) {
               var selectedDates = calendar.selectedDates
               if let start = selectedDates.min(), let end = selectedDates.max() {
                              calendar.selectDates(from: start, to: end, triggerSelectionDelegate: false, keepSelectionIfMultiSelectionAllowed: true)
               }
}

Expected Behavior

Not freeze main thread in app for a few seconds

Contributor Guide