Skip to content

Commit

Permalink
Fix Crop shortcut requesting Size value when both Width and Height ar…
Browse files Browse the repository at this point in the history
…e specified
  • Loading branch information
alin23 committed Oct 14, 2023
1 parent cc9f692 commit 323dd14
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Clop/ClopApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class AppDelegate: LowtechProAppDelegate {
}
@MainActor lazy var mouseUpMonitor = GlobalEventMonitor(mask: [.leftMouseUp]) { event in
self.draggingSet.send(false)
if !DM.dragHovering {
if !DM.dragHovering, DM.itemsToOptimise.isNotEmpty {
DM.dragging = false
DM.itemsToOptimise = []
}
Expand Down
16 changes: 11 additions & 5 deletions Clop/ClopShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,31 @@ struct CropOptimiseFileIntent: AppIntent {
var longEdge: Bool

@Parameter(title: "Width")
var width: Int
var width: Int?

@Parameter(title: "Height")
var height: Int
var height: Int?

@Parameter(title: "Size")
var size: Int
var size: Int?

@MainActor
func perform() async throws -> some IntentResult & ReturnsValue<IntentFile> {
let clip = ClipboardType.fromString(item)
if longEdge, (size ?? 0) == 0 {
throw $size.needsValueError()
}
if !longEdge, (width ?? 0) == 0, (height ?? 0) == 0 {
throw IntentError.message("You need to specify at least one non-zero width or height")
}

let clip = ClipboardType.fromString(item)
let result: ClipboardType?
do {
result = try await optimiseItem(
clip,
id: item,
hideFloatingResult: hideFloatingResult,
cropTo: CropSize(width: longEdge ? size : width, height: longEdge ? size : height, longEdge: longEdge),
cropTo: CropSize(width: (longEdge ? size : width) ?? 0, height: (longEdge ? size : height) ?? 0, longEdge: longEdge),
aggressiveOptimisation: aggressiveOptimisation,
optimisationCount: &shortcutsOptimisationCount,
copyToClipboard: copyToClipboard,
Expand Down
1 change: 1 addition & 0 deletions ReleaseNotes/2.2.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- Lower bundle size by compressing `x86` and `arm` binaries together
- Fix crash on optimise hotkey
- Fix possible multiplication overflow crash
- Fix Crop shortcut requesting Size value when both Width and Height are specified

0 comments on commit 323dd14

Please sign in to comment.