diff --git a/.swiftlint.yml b/.swiftlint.yml index 1168e047..de8eee65 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,6 +1,7 @@ excluded: - BookPlayer/Generated/AutoMockable.generated.swift - BookPlayerTests + - BookPlayer/Utils/Extensions/BlurHashDecode.swift cyclomatic_complexity: ignores_case_statements: true # line_length: 120 diff --git a/BookPlayer/Jellyfin/Connection Screen/JellyfinConnectionViewModel.swift b/BookPlayer/Jellyfin/Connection Screen/JellyfinConnectionViewModel.swift index 269f9bfb..fd4e23fe 100644 --- a/BookPlayer/Jellyfin/Connection Screen/JellyfinConnectionViewModel.swift +++ b/BookPlayer/Jellyfin/Connection Screen/JellyfinConnectionViewModel.swift @@ -32,7 +32,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger case connected } - weak var coordinator: JellyfinCoordinator! let jellyfinConnectionService: JellyfinConnectionService @@ -64,7 +63,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger private var disposeBag = Set() - init(jellyfinConnectionService: JellyfinConnectionService) { self.jellyfinConnectionService = jellyfinConnectionService bindObservers() @@ -83,7 +81,7 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger self.form.serverUrl = data.url.absoluteString self.form.serverName = data.serverName self.form.username = data.userName - //self.form.password is not saved (we have an access token instead). Leave the field blank. + // self.form.password is not saved (we have an access token instead). Leave the field blank. self.form.rememberMe = true self.connectionState = .connected } @@ -96,7 +94,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger connectionState = .disconnected } - @MainActor func handleCancelAction() { onTransition?(.cancel) diff --git a/BookPlayer/Jellyfin/JellyfinCoordinator.swift b/BookPlayer/Jellyfin/JellyfinCoordinator.swift index 4de12f36..7bd3d357 100644 --- a/BookPlayer/Jellyfin/JellyfinCoordinator.swift +++ b/BookPlayer/Jellyfin/JellyfinCoordinator.swift @@ -30,7 +30,7 @@ class JellyfinCoordinator: Coordinator, AlertPresenter { func bindObservers() { singleFileDownloadService.eventsPublisher.sink { [weak self] event in switch event { - case .starting(_), .error(_, _, _): + case .starting, .error: // Currently we only show the download issues or progress in the main view // So we hide the jellyfin views when download starts or has an error Task { @MainActor [weak self] in diff --git a/BookPlayer/Jellyfin/Library Screen/JellyfinAudiobookDetailsViewModel.swift b/BookPlayer/Jellyfin/Library Screen/JellyfinAudiobookDetailsViewModel.swift index e1f4aacd..2f266b2b 100644 --- a/BookPlayer/Jellyfin/Library Screen/JellyfinAudiobookDetailsViewModel.swift +++ b/BookPlayer/Jellyfin/Library Screen/JellyfinAudiobookDetailsViewModel.swift @@ -49,7 +49,7 @@ protocol JellyfinAudiobookDetailsViewModelProtocol: ObservableObject { class JellyfinAudiobookDetailsViewModel: JellyfinAudiobookDetailsViewModelProtocol { let item: JellyfinLibraryItem - @Published var details: JellyfinAudiobookDetailsData? = nil + @Published var details: JellyfinAudiobookDetailsData? private var apiClient: JellyfinClient private var fetchTask: Task<(), any Error>? @@ -69,7 +69,7 @@ class JellyfinAudiobookDetailsViewModel: JellyfinAudiobookDetailsViewModelProtoc defer { fetchTask = nil } do { - let response = try await apiClient.send(Paths.getItem(itemID:item.id)) + let response = try await apiClient.send(Paths.getItem(itemID: item.id)) try Task.checkCancellation() let itemInfo = response.value diff --git a/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryItemImageView.swift b/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryItemImageView.swift index c0027414..4d283c44 100644 --- a/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryItemImageView.swift +++ b/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryItemImageView.swift @@ -44,7 +44,7 @@ fileprivate struct JellyfinLibraryItemImageViewWrapper Bool { + static func == (lhs: Self, rhs: Self) -> Bool { return lhs.item.kind == rhs.item.kind && lhs.item.id == rhs.item.id } diff --git a/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryViewModel.swift b/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryViewModel.swift index 025988f9..c440d307 100644 --- a/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryViewModel.swift +++ b/BookPlayer/Jellyfin/Library Screen/JellyfinLibraryViewModel.swift @@ -190,7 +190,7 @@ final class JellyfinLibraryViewModel: JellyfinLibraryViewModelProtocol, BPLogger do { return try createItemImageURLInternal(item, size: size) } catch { - Self.logger.error("Failed to create item image URL (item ID: \(item.id), kind: \(String(reflecting: item.kind)), error: \(error))"); + Self.logger.error("Failed to create item image URL (item ID: \(item.id), kind: \(String(reflecting: item.kind)), error: \(error))") return nil } } diff --git a/BookPlayer/Library/ItemList Screen/ItemListViewModel.swift b/BookPlayer/Library/ItemList Screen/ItemListViewModel.swift index 80352bed..1793632c 100644 --- a/BookPlayer/Library/ItemList Screen/ItemListViewModel.swift +++ b/BookPlayer/Library/ItemList Screen/ItemListViewModel.swift @@ -239,7 +239,7 @@ class ItemListViewModel: ViewModelProtocol { singleFileDownloadService.eventsPublisher.sink { [weak self] event in guard let self else { return } switch event { - case .starting(url: _): + case .starting: self.sendEvent(.showProcessingView(true, title: "downloading_file_title".localized, subtitle: "\("progress_title".localized) 0%")) case .progress(task: _, progress: let progress): let percentage = String(format: "%.2f", progress * 100) @@ -248,7 +248,7 @@ class ItemListViewModel: ViewModelProtocol { title: "downloading_file_title".localized, subtitle: "\("progress_title".localized) \(percentage)%" )) - case .finished(task: _): + case .finished: self.sendEvent(.showProcessingView(false, title: nil, subtitle: nil)) case .error(let errorKind, task: let task, underlyingError: let underlyingError): self.handleSingleFileDownloadError(errorKind, task: task, underlyingError: underlyingError) diff --git a/BookPlayer/Services/SingleFileDownloadService.swift b/BookPlayer/Services/SingleFileDownloadService.swift index a3a439aa..7ce659d1 100644 --- a/BookPlayer/Services/SingleFileDownloadService.swift +++ b/BookPlayer/Services/SingleFileDownloadService.swift @@ -11,7 +11,7 @@ import BookPlayerKit class SingleFileDownloadService { - public enum ErrorKind : Error { + public enum ErrorKind: Error { case general case network }