From 9dee830887c4abcba5a036df814718c8831f2ddf Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Mon, 20 May 2024 11:35:37 +0200 Subject: [PATCH] fix import stuff --- PadelClub/Utils/SourceFileManager.swift | 20 ++++++++++---------- PadelClub/Views/Navigation/MainView.swift | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/PadelClub/Utils/SourceFileManager.swift b/PadelClub/Utils/SourceFileManager.swift index 570fbf8..9e0c266 100644 --- a/PadelClub/Utils/SourceFileManager.swift +++ b/PadelClub/Utils/SourceFileManager.swift @@ -45,11 +45,11 @@ class SourceFileManager { } func fetchData() async { - if let mostRecent = mostRecentDateAvailable, let current = Calendar.current.date(byAdding: .month, value: 1, to: mostRecent), current > mostRecent { - await fetchData(fromDate: current) - } else { - await fetchData(fromDate: Date()) - } + await fetchData(fromDate: Date()) +// if let mostRecent = mostRecentDateAvailable, let current = Calendar.current.date(byAdding: .month, value: 1, to: mostRecent), current > mostRecent { +// await fetchData(fromDate: current) +// } else { +// } } func _removeAllData(fromDate current: Date) { @@ -96,11 +96,11 @@ class SourceFileManager { try await group.waitForAll() } - if current < Date() { - if let nextCurrent = Calendar.current.date(byAdding: .month, value: 1, to: current) { - await fetchData(fromDate: nextCurrent) - } - } +// if current < Date() { +// if let nextCurrent = Calendar.current.date(byAdding: .month, value: 1, to: current) { +// await fetchData(fromDate: nextCurrent) +// } +// } } catch { print("downloadRankingData", error) diff --git a/PadelClub/Views/Navigation/MainView.swift b/PadelClub/Views/Navigation/MainView.swift index eabfa53..8b1e540 100644 --- a/PadelClub/Views/Navigation/MainView.swift +++ b/PadelClub/Views/Navigation/MainView.swift @@ -66,7 +66,6 @@ struct MainView: View { .environmentObject(dataStore) .task { await self._checkSourceFileAvailability() - await self._downloadPreviousDate() } // .refreshable { // Task { @@ -99,8 +98,8 @@ struct MainView: View { } } } - } else if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable { - if mostRecentDateAvailable > SourceFileManager.shared.lastDataSourceDate() ?? .distantPast { + } else if let mostRecentDateAvailable = SourceFileManager.shared.mostRecentDateAvailable, let lastDataSourceDate = SourceFileManager.shared.lastDataSourceDate() { + if mostRecentDateAvailable > lastDataSourceDate { Label(mostRecentDateAvailable.monthYearFormatted + " disponible", systemImage: "exclamationmark.triangle") .labelStyle(.titleAndIcon) } else {