tracking further fixes

This commit is contained in:
2026-08-03 01:50:10 +02:00
parent 3a0d094070
commit 5dd596f0fb
+17 -11
View File
@@ -81,7 +81,8 @@ final class ViewController: UIViewController, UIGestureRecognizerDelegate {
var currentPath: URL!
var lastLayoutSize: CGSize = .zero
var aniListToken: String? = getAniListToken()
var aniListTracking = false
var aniListTracking: [Int: Bool] = [:]
var currentItemIndex = 0
var leftTap: UITapGestureRecognizer!
var rightTap: UITapGestureRecognizer!
@@ -801,7 +802,7 @@ final class ViewController: UIViewController, UIGestureRecognizerDelegate {
LocalState(
progress: newProgress, backgroundColor: self.convertColorToString(color),
useDefaultPageTurnMode: self.useDefaultPageTurnMode,
aniListTracking: self.aniListTracking
aniListTracking: self.aniListTracking[self.currentItemIndex] ?? false
)
).write(
to: self.currentPath.appendingPathComponent("state.json")
@@ -823,7 +824,7 @@ final class ViewController: UIViewController, UIGestureRecognizerDelegate {
let json = try Data(String(contentsOfFile: path).utf8)
let local = try JSONDecoder().decode(LocalState.self, from: json)
useDefaultPageTurnMode = local.useDefaultPageTurnMode
aniListTracking = local.aniListTracking
aniListTracking[currentItemIndex] = local.aniListTracking
switch local.progress {
case let .leftToRight(volumeIndex, chapterIndex, imageIndex):
progress.v = volumeIndex
@@ -1624,6 +1625,7 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
) {
if collectionView == comicCollectionView {
let selectedComic = comics[indexPath.item]
currentItemIndex = indexPath.item
readComic(name: selectedComic.metadata.title!)
}
@@ -2384,7 +2386,9 @@ extension ViewController {
title: "AniList",
children: aniListOptionItems,
destructive: false,
available: { [self] in return metadata.anilistId != nil && aniListToken != nil },
available: { [self] in
return comics[indexPath.item].metadata.anilistId != nil && aniListToken != nil || true
},
action: { [weak self] in
self?.dismiss(animated: false)
}
@@ -2420,20 +2424,22 @@ extension ViewController {
var title = action.rawValue
switch action {
case .updateStatus: children = aniListUpdateStatusItems(indexPath)
case .fetchMetadata: print("")
case .fetchMetadata: _ = 0
case .track:
if aniListTracking {
title += " (Enabled)"
} else {
title += " (Disabled)"
}
if aniListTracking[indexPath.item] ?? false {
title += " (Enabled)"
} else {
title += " (Disabled)"
}
}
return ComicOptionItem(
title: title, children: children,
destructive: false, available: { true },
action: { [weak self] in
if action == .track {
self?.aniListTracking.toggle()
var v = self?.aniListTracking[indexPath.item] ?? false
v.toggle()
self?.aniListTracking[indexPath.item] = v
self?.saveLocalState()
}
self?.dismiss(animated: false)