Skip to content

Commit cba9593

Browse files
author
Iakov Senatov
committed
Fix unnecessary await in performCompress
1 parent 142800f commit cba9593

File tree

3 files changed

+101
-85
lines changed

3 files changed

+101
-85
lines changed

GUI/Sources/ContextMenu/Dialogs/ContextMenuDialogModifier.swift

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
struct ContextMenuDialogModifier: ViewModifier {
1212
let appState: AppState
1313
@Bindable var coordinator: ContextMenuCoordinator
14-
14+
1515
func body(content: Content) -> some View {
1616
content
1717
.overlay {
@@ -20,7 +20,7 @@
2020
}
2121
}
2222
}
23-
23+
2424
@ViewBuilder
2525
private var dialogOverlay: some View {
2626
ZStack {
@@ -33,7 +33,7 @@
3333
coordinator.dismissDialog()
3434
}
3535
}
36-
36+
3737
// Dialog content
3838
if let dialog = coordinator.activeDialog {
3939
dialogContent(for: dialog)
@@ -42,7 +42,7 @@
4242
}
4343
.animation(.easeOut(duration: 0.15), value: coordinator.activeDialog?.id)
4444
}
45-
45+
4646
@ViewBuilder
4747
private func dialogContent(for dialog: ActiveDialog) -> some View {
4848
switch dialog {
@@ -58,7 +58,7 @@
5858
coordinator.dismissDialog()
5959
}
6060
)
61-
61+
6262
case .rename(let file):
6363
RenameDialog(
6464
file: file,
@@ -71,7 +71,7 @@
7171
coordinator.dismissDialog()
7272
}
7373
)
74-
74+
7575
case .pack(let files, let destination):
7676
PackDialog(
7777
mode: .pack,
@@ -93,7 +93,25 @@
9393
coordinator.dismissDialog()
9494
}
9595
)
96-
96+
97+
case .compress(let files, let destination):
98+
PackDialog(
99+
mode: .compress,
100+
files: files,
101+
destinationPath: destination,
102+
onPack: { archiveName, format, finalDestination, deleteSource in
103+
Task {
104+
await coordinator.performCompress(
105+
files: files,
106+
appState: appState
107+
)
108+
}
109+
},
110+
onCancel: {
111+
coordinator.dismissDialog()
112+
}
113+
)
114+
97115
case .createLink(let file, let destination):
98116
CreateLinkDialog(
99117
file: file,
@@ -113,15 +131,15 @@
113131
coordinator.dismissDialog()
114132
}
115133
)
116-
134+
117135
case .fileConflict(let conflict, _):
118136
FileConflictDialog(
119137
conflict: conflict,
120138
onResolve: { resolution in
121139
coordinator.resolveConflict(resolution)
122140
}
123141
)
124-
142+
125143
case .error(let title, let message):
126144
HIGAlertDialog(
127145
icon: "xmark.circle.fill",
@@ -132,7 +150,7 @@
132150
coordinator.dismissDialog()
133151
}
134152
)
135-
153+
136154
case .success(let title, let message):
137155
HIGAlertDialog(
138156
icon: "checkmark.circle.fill",
@@ -143,9 +161,9 @@
143161
coordinator.dismissDialog()
144162
}
145163
)
146-
164+
147165
// MARK: - Batch Operation Dialogs
148-
166+
149167
case .batchCopyConfirmation(let files, let destination, let sourcePanel):
150168
BatchConfirmationDialog(
151169
operationType: .copy,
@@ -164,7 +182,7 @@
164182
coordinator.dismissDialog()
165183
}
166184
)
167-
185+
168186
case .batchMoveConfirmation(let files, let destination, let sourcePanel):
169187
BatchConfirmationDialog(
170188
operationType: .move,
@@ -183,7 +201,7 @@
183201
coordinator.dismissDialog()
184202
}
185203
)
186-
204+
187205
case .batchDeleteConfirmation(let files, let sourcePanel):
188206
BatchConfirmationDialog(
189207
operationType: .delete,
@@ -201,7 +219,7 @@
201219
coordinator.dismissDialog()
202220
}
203221
)
204-
222+
205223
case .batchPackConfirmation(let files, let destination, _):
206224
PackDialog(
207225
mode: .pack,
@@ -219,7 +237,7 @@
219237
coordinator.dismissDialog()
220238
}
221239
)
222-
240+
223241
case .batchProgress(let state):
224242
BatchProgressDialog(
225243
state: state,
@@ -242,15 +260,15 @@
242260
let title: String
243261
let message: String
244262
let onDismiss: () -> Void
245-
263+
246264
var body: some View {
247265
VStack(spacing: 16) {
248266
// App icon with badge
249267
ZStack(alignment: .bottomTrailing) {
250268
Image(nsImage: NSApp.applicationIconImage)
251269
.resizable()
252270
.frame(width: 64, height: 64)
253-
271+
254272
Image(systemName: icon)
255273
.font(.system(size: 24))
256274
.foregroundStyle(iconColor)
@@ -261,19 +279,19 @@
261279
)
262280
.offset(x: 4, y: 4)
263281
}
264-
282+
265283
// Title
266284
Text(title)
267285
.font(.system(size: 13, weight: .semibold))
268286
.multilineTextAlignment(.center)
269-
287+
270288
// Message
271289
Text(message)
272290
.font(.system(size: 11))
273291
.foregroundStyle(.secondary)
274292
.multilineTextAlignment(.center)
275293
.lineLimit(4)
276-
294+
277295
// Button
278296
HIGPrimaryButton(title: "OK", action: onDismiss)
279297
.keyboardShortcut(.defaultAction)

GUI/Sources/ContextMenu/Services/Coordinator/FileOperationExecutors.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
func performCompress(files: [CustomFile], appState: AppState) async {
100100
log.debug("\(#function) files.count=\(files.count)")
101101

102-
guard let moveToArchive = await promptMoveToArchiveOption(filesCount: files.count) else {
102+
guard let moveToArchive = promptMoveToArchiveOption(filesCount: files.count) else {
103103
log.info("\(#function) cancelled by user")
104104
activeDialog = nil
105105
return
@@ -171,15 +171,15 @@
171171
archiveName: archiveName,
172172
format: format
173173
)
174-
174+
175175
// Delete source files if requested
176176
if deleteSource {
177177
for url in urls {
178178
try FileManager.default.trashItem(at: url, resultingItemURL: nil)
179179
log.info("\(#function) trashed source: '\(url.lastPathComponent)'")
180180
}
181181
}
182-
182+
183183
// Determine which panel shows the destination and navigate+select
184184
let archiveName = archiveURL.lastPathComponent
185185
let destPath = destination.path
Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,76 @@
1-
//
2-
// Untitled.swift
3-
// MiMiNavigator
4-
//
5-
// Created by Iakov Senatov on 08.03.2026.
6-
// Copyright © 2026 Senatov. All rights reserved.
7-
//
8-
9-
// DragOverlayView.swift
10-
11-
import AppKit
12-
import FileModelKit
13-
import SwiftUI
14-
15-
struct DragOverlayView: NSViewRepresentable {
16-
@Environment(AppState.self) var appState
17-
@Environment(DragDropManager.self) var dragDropManager
18-
19-
let panelSide: PanelSide
20-
let files: [CustomFile]
21-
22-
func makeNSView(context: Context) -> DragNSView {
23-
let view = DragNSView()
24-
view.panelSide = panelSide
25-
view.files = files
26-
view.dragDropManager = dragDropManager
27-
view.appState = appState
28-
return view
29-
}
1+
//
2+
// Untitled.swift
3+
// MiMiNavigator
4+
//
5+
// Created by Iakov Senatov on 08.03.2026.
6+
// Copyright © 2026 Senatov. All rights reserved.
7+
//
8+
9+
// DragOverlayView.swift
10+
11+
import AppKit
12+
import FileModelKit
13+
import SwiftUI
14+
15+
struct DragOverlayView: NSViewRepresentable {
16+
@Environment(AppState.self) var appState
17+
@Environment(DragDropManager.self) var dragDropManager
18+
19+
let panelSide: PanelSide
20+
let files: [CustomFile]
21+
22+
func makeNSView(context: Context) -> DragNSView {
23+
let view = DragNSView()
24+
view.panelSide = panelSide
25+
view.files = files
26+
view.dragDropManager = dragDropManager
27+
view.appState = appState
28+
return view
29+
}
3030

31-
func updateNSView(_ nsView: DragNSView, context: Context) {
32-
nsView.files = files
31+
func updateNSView(_ nsView: DragNSView, context: Context) {
32+
nsView.files = files
33+
}
3334
}
34-
}
3535

36-
final class DragNSView: NSView, NSDraggingSource {
36+
final class DragNSView: NSView, NSDraggingSource {
3737

38-
var panelSide: PanelSide!
39-
var files: [CustomFile] = []
40-
weak var dragDropManager: DragDropManager?
41-
weak var appState: AppState?
38+
var panelSide: PanelSide!
39+
var files: [CustomFile] = []
40+
weak var dragDropManager: DragDropManager?
41+
weak var appState: AppState?
4242

43-
override func mouseDragged(with event: NSEvent) {
43+
override func mouseDragged(with event: NSEvent) {
4444

45-
guard let appState,
46-
let dragDropManager
47-
else { return }
45+
guard let appState else { return }
4846

49-
let selectedFiles = appState.markedFiles(for: panelSide)
47+
let selectedFiles = appState.markedFiles(for: panelSide)
5048

51-
guard !selectedFiles.isEmpty else { return }
49+
guard !selectedFiles.isEmpty else { return }
5250

53-
log.debug("[DragOverlay] starting AppKit drag with \(selectedFiles.count) file(s)")
51+
log.debug("[DragOverlay] starting AppKit drag with \(selectedFiles.count) file(s)")
5452

55-
let draggingItems: [NSDraggingItem] = selectedFiles.map { file in
53+
let draggingItems: [NSDraggingItem] = selectedFiles.map { file in
5654

57-
let pasteboardItem = NSPasteboardItem()
58-
let fileURL = URL(fileURLWithPath: file)
59-
pasteboardItem.setString(fileURL.absoluteString, forType: .fileURL)
55+
let pasteboardItem = NSPasteboardItem()
56+
let fileURL = URL(fileURLWithPath: file)
57+
pasteboardItem.setString(fileURL.absoluteString, forType: .fileURL)
6058

61-
let draggingItem = NSDraggingItem(pasteboardWriter: pasteboardItem)
59+
let draggingItem = NSDraggingItem(pasteboardWriter: pasteboardItem)
6260

63-
let frame = self.bounds
64-
draggingItem.setDraggingFrame(frame, contents: nil)
61+
let frame = self.bounds
62+
draggingItem.setDraggingFrame(frame, contents: nil)
6563

66-
return draggingItem
67-
}
64+
return draggingItem
65+
}
6866

69-
beginDraggingSession(with: draggingItems, event: event, source: self)
70-
}
67+
beginDraggingSession(with: draggingItems, event: event, source: self)
68+
}
7169

72-
func draggingSession(
73-
_ session: NSDraggingSession,
74-
sourceOperationMaskFor context: NSDraggingContext
75-
) -> NSDragOperation {
76-
return .copy
70+
func draggingSession(
71+
_ session: NSDraggingSession,
72+
sourceOperationMaskFor context: NSDraggingContext
73+
) -> NSDragOperation {
74+
return .copy
75+
}
7776
}
78-
}

0 commit comments

Comments
 (0)