Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<key>CFBundleExecutable</key>
<string>Wallpaper</string>
<key>CFBundleVersion</key>
<string>1.1.1</string>
<string>1.1.2</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<string>1.1.2</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleIconFile</key>
Expand Down
4 changes: 2 additions & 2 deletions Sources/Wallpaper/WallpaperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ struct WallpaperApp: App {
enabled: !manager.images.isEmpty
) {
if manager.isCurrentDisliked {
manager.undoDislike()
Task { await manager.undoDislike() }
} else {
Task { await manager.dislike() }
manager.dislike()
}
}
.help(manager.isCurrentDisliked ? "Unskip" : "Skip this wallpaper")
Expand Down
19 changes: 4 additions & 15 deletions Sources/Wallpaper/WallpaperManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,19 @@ class WallpaperManager {

// MARK: - Like/Dislike/Favorite Actions

func dislike() async {
func dislike() {
guard currentIndex >= 0, currentIndex < images.count else { return }
let image = images[currentIndex]
store.addDislike(image.startdate)
// Remove from favorites if present
store.removeFavorite(image)
await navigateToNextNonDisliked()
}

func undoDislike() {
func undoDislike() async {
guard currentIndex >= 0, currentIndex < images.count else { return }
store.removeDislike(images[currentIndex].startdate)
do { try await applyWallpaper(at: currentIndex) }
catch { errorMessage = error.localizedDescription }
}

func toggleFavorite() {
Expand Down Expand Up @@ -313,18 +314,6 @@ class WallpaperManager {
return NSImage(contentsOf: localURL)
}

private func navigateToNextNonDisliked() async {
// Try newer images first (lower indices), then older images
let candidates = Array(0..<images.count).filter { $0 != currentIndex && !store.isDisliked(images[$0].startdate) }
// Prefer the nearest newer image (lower index)
if let next = candidates.first(where: { $0 < currentIndex }) ?? candidates.first {
currentIndex = next
do { try await applyWallpaper(at: currentIndex) }
catch { errorMessage = error.localizedDescription }
} else {
errorMessage = "All wallpapers are disliked"
}
}

// MARK: - Wallpaper

Expand Down