Skip to content

Commit

Permalink
Fix folders not displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniCarlo committed Jun 20, 2023
1 parent fbb981a commit 2a38e51
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Shared/Services/LibraryService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,30 +262,33 @@ public final class LibraryService: LibraryServiceProtocol {
}

func parseFetchedItems(from results: [[String: Any]]?) -> [SimpleLibraryItem]? {
return results?.compactMap({ dictionary -> SimpleLibraryItem? in
return results?.compactMap({ [weak self] dictionary -> SimpleLibraryItem? in
guard
let title = dictionary["title"] as? String,
let details = dictionary["details"] as? String,
let speed = dictionary["speed"] as? Float,
let currentTime = dictionary["currentTime"] as? Double,
let duration = dictionary["duration"] as? Double,
let percentCompleted = dictionary["percentCompleted"] as? Double,
let isFinished = dictionary["isFinished"] as? Bool,
let relativePath = dictionary["relativePath"] as? String,
let orderRank = dictionary["orderRank"] as? Int16,
let originalFileName = dictionary["originalFileName"] as? String,
let rawType = dictionary["type"] as? Int16,
let type = SimpleItemType(rawValue: rawType)
else { return nil }

/// Patch for optional CoreData properties until we migrate to Realm
if dictionary["details"] == nil {
self?.rebuildFolderDetails(relativePath)
}

return SimpleLibraryItem(
title: title,
details: details,
details: dictionary["details"] as? String ?? "",
speed: Double(speed),
currentTime: currentTime,
duration: duration,
percentCompleted: percentCompleted,
isFinished: isFinished,
isFinished: dictionary["isFinished"] as? Bool ?? false,
relativePath: relativePath,
remoteURL: dictionary["remoteURL"] as? URL,
artworkURL: dictionary["artworkURL"] as? URL,
Expand Down

0 comments on commit 2a38e51

Please sign in to comment.