diff --git a/ImageViewer/ViewController.swift b/ImageViewer/ViewController.swift index 112bb75..3813a72 100644 --- a/ImageViewer/ViewController.swift +++ b/ImageViewer/ViewController.swift @@ -227,23 +227,24 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate { getMetadataFromFileName(path: dir) } + currentPath = dir + + metadata = try JSONDecoder().decode( + Metadata.self, + from: + Data( + try String( + contentsOfFile: dir.appendingPathComponent( + "metadata.json" + ) + .path + ).utf8) + ) + loadLocalState() comics.append( Comic( - cover: - UIImage( - contentsOfFile: dir.appendingPathComponent("cover.jpg").path)!, - metadata: - try JSONDecoder().decode( - Metadata.self, - from: - Data( - try String( - contentsOfFile: dir.appendingPathComponent( - "metadata.json" - ) - .path - ).utf8) - ), + cover: UIImage(contentsOfFile: getImagePath(progress: ProgressIndices(v: progress.v, c: 0, i: 0)).path)!, + metadata: metadata, path: dir )) }