fix import stuff

multistore
Razmig Sarkissian 1 year ago
parent b82566e69a
commit 9dee830887
  1. 20
      PadelClub/Utils/SourceFileManager.swift
  2. 5
      PadelClub/Views/Navigation/MainView.swift

@ -45,11 +45,11 @@ class SourceFileManager {
} }
func fetchData() async { func fetchData() async {
if let mostRecent = mostRecentDateAvailable, let current = Calendar.current.date(byAdding: .month, value: 1, to: mostRecent), current > mostRecent { await fetchData(fromDate: Date())
await fetchData(fromDate: current) // if let mostRecent = mostRecentDateAvailable, let current = Calendar.current.date(byAdding: .month, value: 1, to: mostRecent), current > mostRecent {
} else { // await fetchData(fromDate: current)
await fetchData(fromDate: Date()) // } else {
} // }
} }
func _removeAllData(fromDate current: Date) { func _removeAllData(fromDate current: Date) {
@ -96,11 +96,11 @@ class SourceFileManager {
try await group.waitForAll() try await group.waitForAll()
} }
if current < Date() { // if current < Date() {
if let nextCurrent = Calendar.current.date(byAdding: .month, value: 1, to: current) { // if let nextCurrent = Calendar.current.date(byAdding: .month, value: 1, to: current) {
await fetchData(fromDate: nextCurrent) // await fetchData(fromDate: nextCurrent)
} // }
} // }
} catch { } catch {
print("downloadRankingData", error) print("downloadRankingData", error)

@ -66,7 +66,6 @@ struct MainView: View {
.environmentObject(dataStore) .environmentObject(dataStore)
.task { .task {
await self._checkSourceFileAvailability() await self._checkSourceFileAvailability()
await self._downloadPreviousDate()
} }
// .refreshable { // .refreshable {
// Task { // Task {
@ -99,8 +98,8 @@ struct MainView: View {
} }
} }
} }
} else if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable { } else if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable, let lastDataSourceDate = SourceFileManager.shared.lastDataSourceDate() {
if mostRecentDateAvailable > SourceFileManager.shared.lastDataSourceDate() ?? .distantPast { if mostRecentDateAvailable > lastDataSourceDate {
Label(mostRecentDateAvailable.monthYearFormatted + " disponible", systemImage: "exclamationmark.triangle") Label(mostRecentDateAvailable.monthYearFormatted + " disponible", systemImage: "exclamationmark.triangle")
.labelStyle(.titleAndIcon) .labelStyle(.titleAndIcon)
} else { } else {

Loading…
Cancel
Save