Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
searchViewModel.delegate = self

let publisher = self.useCase.savedLocationsPublisher
publisher.receive(on: DispatchQueue.main).sink { [weak self] locations in

Check warning on line 45 in PresentationLayer/UIComponents/Screens/Home/HomeViewModel.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Unused Closure Parameter Violation: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
self?.refresh(completion: nil)
}.store(in: &cancellableSet)

Expand Down Expand Up @@ -95,7 +95,7 @@

case .notDetermined:
Task { @MainActor in
let _ = await useCase.getUserLocation()

Check warning on line 98 in PresentationLayer/UIComponents/Screens/Home/HomeViewModel.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Redundant Discardable Let Violation: Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function (redundant_discardable_let)
refresh(completion: nil)
}
case .unknown:
Expand All @@ -115,7 +115,6 @@
do {
let forecasts = try await fetchForecasts()
self.savedLocationsState = forecasts.isEmpty ? .empty : .forecasts(forecasts)
self.currentLocationState = try await getCurrentLocationState()
} catch let error as NetworkErrorResponse {
let info = error.uiInfo
let obj = info.defaultFailObject(type: .home) { [weak self] in
Expand All @@ -126,9 +125,15 @@

self.failObj = obj
self.isFailed = true
} catch {
print(error)
}

do {
self.currentLocationState = try await getCurrentLocationState()
} catch {
print(error)
self.currentLocationState = .empty
}

self.isLoading = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

.background(Color(colorEnum: .bg))
}
.iPadMaxWidth()
} else if devices.isEmpty || !viewModel.isLoggedIn {
ZStack {
Color(colorEnum: .bg)
Expand All @@ -111,6 +112,7 @@
addStationsButton
}
}
.iPadMaxWidth()
} else {
weatherStations(devices: devices)
.overlay {
Expand All @@ -120,7 +122,7 @@
}

@ViewBuilder
func weatherStations(devices: [DeviceDetails]) -> some View {

Check warning on line 125 in PresentationLayer/UIComponents/Screens/WeatherStations/MyStations/MyStationsView.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Function Body Length Violation: Function body should span 50 lines or less excluding comments and whitespace: currently spans 60 lines (function_body_length)
TrackableScroller(showIndicators: false,
offsetObject: viewModel.scrollOffsetObject) { completion in
viewModel.getDevices(refreshMode: true, completion: completion)
Expand All @@ -132,7 +134,7 @@
stationName: viewModel.uploadInProgressStationName ?? "",
tapAction: {
viewModel.handleUploadBannerTap()
}) {

Check warning on line 137 in PresentationLayer/UIComponents/Screens/WeatherStations/MyStations/MyStationsView.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Multiple Closures with Trailing Closure Violation: Trailing closure syntax should not be used when passing more than one closure argument (multiple_closures_with_trailing_closure)
withAnimation {
viewModel.uploadState = nil
}
Expand Down Expand Up @@ -174,7 +176,7 @@
}
}


Check warning on line 179 in PresentationLayer/UIComponents/Screens/WeatherStations/MyStations/MyStationsView.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Vertical Whitespace Violation: Limit vertical whitespace to a single empty line; currently 2 (vertical_whitespace)
NavigationTitleView(title: .constant(LocalizableString.weatherStationsHomeTitle.localized),
subtitle: .constant(nil)) {
navigationBarRightView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@

mainVM?.$isUserLoggedIn.sink { [weak self] value in
self?.isLoggedIn = value
self?.isFailed = false
self?.failObj = nil
}.store(in: &cancellableSet)

observeFilters()
Expand All @@ -90,7 +92,7 @@
self?.updateProgressUpload()
}.store(in: &cancellableSet)

photosUseCase.uploadErrorPublisher.sink { [weak self] deviceId, error in

Check warning on line 95 in PresentationLayer/UIComponents/Screens/WeatherStations/MyStations/MyStationsViewModel.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Unused Closure Parameter Violation: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
self?.updateUploadInProgressDevice(deviceId: deviceId)
self?.updateProgressUpload()
}.store(in: &cancellableSet)
Expand Down Expand Up @@ -134,7 +136,7 @@
/// - Parameters:
/// - refreshMode: Set true if coming from pull to refresh to prevent showing full screen loader
/// - completion: Called once the request is finished
func getDevices(refreshMode: Bool = false, completion: (() -> Void)? = nil) {

Check warning on line 139 in PresentationLayer/UIComponents/Screens/WeatherStations/MyStations/MyStationsViewModel.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Function Body Length Violation: Function body should span 50 lines or less excluding comments and whitespace: currently spans 52 lines (function_body_length)
guard isLoggedIn else {
completion?()
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private let cacheManager: MockCacheManager = .init()
let cancellableWrapper: CancellableWrapper = .init()


Check warning on line 21 in WeatherXMTests/DomainLayer/UseCases/LocationForecastsUseCaseTests.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Vertical Whitespace Violation: Limit vertical whitespace to a single empty line; currently 2 (vertical_whitespace)
init() {
useCase = .init(explorerRepository: explorerRepository,
userDefaultsRepository: userDefaultsRepository,
Expand All @@ -42,7 +42,7 @@
@Test
func getCachedForecast() async throws {
let cachedforecast = NetworkDeviceForecastResponse(tz: "123",
date: "",
date: Date.now.getFormattedDate(format: .onlyDate),
hourly: [],
address: "Address")
let location = CLLocationCoordinate2D()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class AuthInterceptor: @unchecked Sendable, RequestInterceptor {
}
}.store(in: &cancellableSet)
} catch {}
}
} else {
completion(nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
nonisolated(unsafe) private let keychainRepository: KeychainRepository
private let savedLocationsUDKey = UserDefaults.GenericKey.savedLocations.rawValue
private let forecastsCacheKey = UserDefaults.GenericKey.savedForecasts.rawValue
private let cacheInterval: TimeInterval = 15 * 60 * 60
private let cacheInterval: TimeInterval = 15 * 60 // 15 mins
nonisolated(unsafe) private let notificationsPublisher: NotificationCenter.Publisher = NotificationCenter.default.publisher(for: .savedLocationsUpdated)
nonisolated(unsafe) let cache: TimeValidationCache<[NetworkDeviceForecastResponse]>
public var locationAuthorization: WXMLocationManager.Status {
Expand Down Expand Up @@ -49,12 +49,19 @@

public func getForecast(for location: CLLocationCoordinate2D) throws -> AnyPublisher<DataResponse<[NetworkDeviceForecastResponse], NetworkErrorResponse>, Never> {
if let cachedForecasts: [NetworkDeviceForecastResponse] = cache.getValue(for: location.cacheKey) {
let forecasts = cachedForecasts.filter { forecast in
guard let date = forecast.date.onlyDateStringToDate() else {
return false
}
// Ensure that we return only forecasts later than today
return date.days(from: Date.now) >= 0
}
let response = DataResponse<[NetworkDeviceForecastResponse], NetworkErrorResponse>(request: nil,
response: nil,
data: nil,
metrics: nil,
serializationDuration: 0,
result: .success(cachedForecasts))
result: .success(forecasts))
return Just(response).eraseToAnyPublisher()
}

Expand Down Expand Up @@ -95,7 +102,7 @@
var locations = getSavedLocations()
locations.removeAll(where: { $0 ~== location})


Check warning on line 105 in wxm-ios/DomainLayer/DomainLayer/UseCases/LocationForecastsUseCase.swift

View workflow job for this annotation

GitHub Actions / swiftLint

Vertical Whitespace Violation: Limit vertical whitespace to a single empty line; currently 2 (vertical_whitespace)
if let data = try? JSONEncoder().encode(locations.map { CodableCoordinate($0) }) {
userDefaultsRepository.saveValue(key: savedLocationsUDKey, value: data)
}
Expand Down