From 79fd56f568afefdb729aedb483da0f7e39420c7d Mon Sep 17 00:00:00 2001 From: kchro3 Date: Wed, 8 Nov 2023 23:41:54 -0800 Subject: [PATCH 1/2] improve error message --- TypeaheadAI/ClientManager.swift | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/TypeaheadAI/ClientManager.swift b/TypeaheadAI/ClientManager.swift index 60c45a2..a1c1a05 100644 --- a/TypeaheadAI/ClientManager.swift +++ b/TypeaheadAI/ClientManager.swift @@ -163,18 +163,18 @@ class ClientManager { @AppStorage("freebies") var freebies: Int = 10 #if DEBUG -// private let apiUrlStreaming = URL(string: "https://typeahead-ai.fly.dev/v2/get_stream")! -// private let apiOnboarding = URL(string: "https://typeahead-ai.fly.dev/onboarding")! -// private let apiImage = URL(string: "https://typeahead-ai.fly.dev/v2/get_image")! -// private let apiIntents = URL(string: "https://typeahead-ai.fly.dev/v2/suggest_intents")! -// private let apiImageCaptions = URL(string: "https://typeahead-ai.fly.dev/v2/get_image_caption")! -// private let apiLatest = URL(string: "https://typeahead-ai.fly.dev/v2/latest")! - private let apiUrlStreaming = URL(string: "http://localhost:8080/v2/get_stream")! - private let apiOnboarding = URL(string: "http://localhost:8080/onboarding")! - private let apiImage = URL(string: "http://localhost:8080/v2/get_image")! - private let apiIntents = URL(string: "http://localhost:8080/v2/suggest_intents")! - private let apiImageCaptions = URL(string: "http://localhost:8080/v2/get_image_caption")! - private let apiLatest = URL(string: "http://localhost:8080/v2/latest")! + private let apiUrlStreaming = URL(string: "https://typeahead-ai.fly.dev/v2/get_stream")! + private let apiOnboarding = URL(string: "https://typeahead-ai.fly.dev/onboarding")! + private let apiImage = URL(string: "https://typeahead-ai.fly.dev/v2/get_image")! + private let apiIntents = URL(string: "https://typeahead-ai.fly.dev/v2/suggest_intents")! + private let apiImageCaptions = URL(string: "https://typeahead-ai.fly.dev/v2/get_image_caption")! + private let apiLatest = URL(string: "https://typeahead-ai.fly.dev/v2/latest")! +// private let apiUrlStreaming = URL(string: "http://localhost:8080/v2/get_stream")! +// private let apiOnboarding = URL(string: "http://localhost:8080/onboarding")! +// private let apiImage = URL(string: "http://localhost:8080/v2/get_image")! +// private let apiIntents = URL(string: "http://localhost:8080/v2/suggest_intents")! +// private let apiImageCaptions = URL(string: "http://localhost:8080/v2/get_image_caption")! +// private let apiLatest = URL(string: "http://localhost:8080/v2/latest")! #else private let apiUrlStreaming = URL(string: "https://typeahead-ai.fly.dev/v2/get_stream")! private let apiOnboarding = URL(string: "https://typeahead-ai.fly.dev/onboarding")! @@ -655,7 +655,7 @@ class ClientManager { urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type") guard let (data, resp) = try? await self.session.bytes(for: urlRequest) else { - let error = ClientManagerError.serverError("Could be serious... Please report to Jeff!") + let error = ClientManagerError.serverError("Couldn't connect to server... Retry or use in offline mode.") continuation.finish(throwing: error) return } From 5b163d504bd2000cd7cc6de40dba683d8d54f594 Mon Sep 17 00:00:00 2001 From: kchro3 Date: Sun, 12 Nov 2023 23:31:49 -0800 Subject: [PATCH 2/2] testing --- TypeaheadAI/ModalManager.swift | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/TypeaheadAI/ModalManager.swift b/TypeaheadAI/ModalManager.swift index 441976c..0f05f91 100644 --- a/TypeaheadAI/ModalManager.swift +++ b/TypeaheadAI/ModalManager.swift @@ -71,6 +71,17 @@ class ModalManager: ObservableObject { self.isVisible = false self.online = true self.isPending = false + + // Register for window moved notifications to save the new position + NotificationCenter.default.addObserver( + self, + selector: #selector(windowDidMove(_:)), + name: NSWindow.didMoveNotification, object: toastWindow) + + NotificationCenter.default.addObserver( + self, + selector: #selector(windowDidResize(_:)), + name: NSWindow.didResizeNotification, object: toastWindow) } // TODO: Inject? @@ -477,17 +488,6 @@ class ModalManager: ObservableObject { toastWindow?.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] - // Register for window moved notifications to save the new position - NotificationCenter.default.addObserver( - self, - selector: #selector(windowDidMove(_:)), - name: NSWindow.didMoveNotification, object: toastWindow) - - NotificationCenter.default.addObserver( - self, - selector: #selector(windowDidResize(_:)), - name: NSWindow.didResizeNotification, object: toastWindow) - self.isVisible = true }