Skip to content

Commit 2f40866

Browse files
committed
Update widget animation
1 parent fefa786 commit 2f40866

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ public final class SuggestionWidgetController: NSObject {
275275

276276
public extension SuggestionWidgetController {
277277
func suggestCode(fileURL: URL) {
278-
widgetViewModel.endIsProcessing()
279278
Task {
279+
markAsProcessing(true)
280+
defer { markAsProcessing(false) }
280281
if let suggestion = await dataSource?.suggestionForFile(at: fileURL) {
281282
suggestionPanelViewModel.content = .suggestion(suggestion)
282283
suggestionPanelViewModel.isPanelDisplayed = true
@@ -285,7 +286,6 @@ public extension SuggestionWidgetController {
285286
}
286287

287288
func discardSuggestion(fileURL: URL) {
288-
widgetViewModel.endIsProcessing()
289289
Task {
290290
await updateContentForActiveEditor(fileURL: fileURL)
291291
}
@@ -302,12 +302,12 @@ public extension SuggestionWidgetController {
302302
func presentError(_ errorDescription: String) {
303303
suggestionPanelViewModel.content = .error(errorDescription)
304304
suggestionPanelViewModel.isPanelDisplayed = true
305-
widgetViewModel.endIsProcessing()
306305
}
307306

308307
func presentChatRoom(fileURL: URL) {
309-
widgetViewModel.endIsProcessing()
310308
Task {
309+
markAsProcessing(true)
310+
defer { markAsProcessing(false) }
311311
if let chat = await dataSource?.chatForFile(at: fileURL) {
312312
chatWindowViewModel.chat = chat
313313
chatWindowViewModel.isPanelDisplayed = true
@@ -347,15 +347,15 @@ public extension SuggestionWidgetController {
347347
}
348348

349349
func closeChatRoom(fileURL: URL) {
350-
widgetViewModel.endIsProcessing()
351350
Task {
352351
await updateContentForActiveEditor(fileURL: fileURL)
353352
}
354353
}
355354

356355
func presentPromptToCode(fileURL: URL) {
357-
widgetViewModel.endIsProcessing()
358356
Task {
357+
markAsProcessing(true)
358+
defer { markAsProcessing(false) }
359359
if let provider = await dataSource?.promptToCodeForFile(at: fileURL) {
360360
suggestionPanelViewModel.content = .promptToCode(provider)
361361
suggestionPanelViewModel.isPanelDisplayed = true
@@ -371,7 +371,6 @@ public extension SuggestionWidgetController {
371371
}
372372

373373
func discardPromptToCode(fileURL: URL) {
374-
widgetViewModel.endIsProcessing()
375374
Task {
376375
await updateContentForActiveEditor(fileURL: fileURL)
377376
}

Core/Sources/SuggestionWidget/WidgetView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class WidgetViewModel: ObservableObject {
1212

1313
private var isProcessingCounters = [IsProcessingCounter]()
1414
private var cleanupIsProcessingCounterTask: Task<Void, Error>?
15-
@Published var isProcessing: Bool
15+
@Published private(set) var isProcessing: Bool
1616
@Published var currentFileURL: URL?
1717

1818
func markIsProcessing(date: Date = Date()) {

0 commit comments

Comments
 (0)