Skip to content

Commit

Permalink
swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
Lysann Tranvouez committed Nov 28, 2024
1 parent 1db568d commit 638a25a
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger
case connected
}


weak var coordinator: JellyfinCoordinator!

let jellyfinConnectionService: JellyfinConnectionService
Expand Down Expand Up @@ -64,7 +63,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger

private var disposeBag = Set<AnyCancellable>()


init(jellyfinConnectionService: JellyfinConnectionService) {
self.jellyfinConnectionService = jellyfinConnectionService
bindObservers()
Expand All @@ -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
}
Expand All @@ -96,7 +94,6 @@ class JellyfinConnectionViewModel: ViewModelProtocol, ObservableObject, BPLogger
connectionState = .disconnected
}


@MainActor
func handleCancelAction() {
onTransition?(.cancel)
Expand Down
2 changes: 1 addition & 1 deletion BookPlayer/Jellyfin/JellyfinCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>?
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fileprivate struct JellyfinLibraryItemImageViewWrapper<LibraryVM: JellyfinLibrar
.fade(duration: 0.5)
}

static func ==(lhs: Self, rhs: Self) -> Bool {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.item.kind == rhs.item.kind && lhs.item.id == rhs.item.id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions BookPlayer/Library/ItemList Screen/ItemListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion BookPlayer/Services/SingleFileDownloadService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BookPlayerKit

class SingleFileDownloadService
{
public enum ErrorKind : Error {
public enum ErrorKind: Error {
case general
case network
}
Expand Down

0 comments on commit 638a25a

Please sign in to comment.