diff --git a/frontend/src-tauri/gen/apple/Haystack/.ShareViewController.swift.swp b/frontend/src-tauri/gen/apple/Haystack/.ShareViewController.swift.swp deleted file mode 100644 index 6cfc8ac..0000000 Binary files a/frontend/src-tauri/gen/apple/Haystack/.ShareViewController.swift.swp and /dev/null differ diff --git a/frontend/src-tauri/gen/apple/Haystack/Base.lproj/MainInterface.storyboard b/frontend/src-tauri/gen/apple/Haystack/Base.lproj/MainInterface.storyboard deleted file mode 100644 index 286a508..0000000 --- a/frontend/src-tauri/gen/apple/Haystack/Base.lproj/MainInterface.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/frontend/src-tauri/gen/apple/Haystack/Haystack.entitlements b/frontend/src-tauri/gen/apple/Haystack/Haystack.entitlements deleted file mode 100644 index 847b16e..0000000 --- a/frontend/src-tauri/gen/apple/Haystack/Haystack.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.application-groups - - group.com.haystack.app - - - diff --git a/frontend/src-tauri/gen/apple/Haystack/Info.plist b/frontend/src-tauri/gen/apple/Haystack/Info.plist deleted file mode 100644 index 65187a3..0000000 --- a/frontend/src-tauri/gen/apple/Haystack/Info.plist +++ /dev/null @@ -1,39 +0,0 @@ - - - - - CFBundleDisplayName - Haystack - NSExtension - - NSExtensionAttributes - - NSExtensionActivationRule - - NSExtensionActivationSupportsImage - - NSExtensionActivationSupportsMovie - - NSExtensionActivationSupportsText - - NSExtensionActivationSupportsURL - - NSExtensionActivationSupportsWebPageWithText - - NSExtensionActivationSupportsAttachmentsWithMaxCount - 0 - NSExtensionActivationSupportsAttachmentsWithMinCount - 1 - - NSExtensionMainStoryboard - MainInterface - NSExtensionPointIdentifier - com.apple.share-services - - NSExtensionPointIdentifier - com.apple.ui-services - NSExtensionPrincipalClass - Haystack.ShareViewController - - - diff --git a/frontend/src-tauri/gen/apple/Haystack/ShareViewController.swift b/frontend/src-tauri/gen/apple/Haystack/ShareViewController.swift deleted file mode 100644 index ed608ab..0000000 --- a/frontend/src-tauri/gen/apple/Haystack/ShareViewController.swift +++ /dev/null @@ -1,196 +0,0 @@ -// -//  ShareViewController.swift -//  Haystack -// -//  Created by Rio Keefe on 03/05/2025. -// - -import UIKit -import Social -import MobileCoreServices - -class ShareViewController: SLComposeServiceViewController { - - let appGroupName = "group.com.haystack.app" // Replace with your actual App Group identifier - let tokenKey = "sharedAuthToken" // This key holds the refresh token. - let uploadURL = URL(string: "https://haystack.johncosta.tech/images/")! - - var refreshToken: String? - private var imageItemProvider: NSItemProvider? - private var extractedImageName: String = "image" // Default name - - override func viewDidLoad() { - super.viewDidLoad() - - if let sharedDefaults = UserDefaults(suiteName: appGroupName) { - refreshToken = sharedDefaults.string(forKey: tokenKey) - print("Retrieved refresh token: \(refreshToken ?? "nil")") - } else { - print("Error accessing App Group UserDefaults.") - } - - // Store the item provider, but don't load the data synchronously yet - if let item = extensionContext?.inputItems.first as? NSExtensionItem, - let provider = item.attachments?.first as? NSItemProvider { - if provider.hasItemConformingToTypeIdentifier(kUTTypeImage as String) { - self.imageItemProvider = provider - // Attempt to get a suggested name early if available - extractedImageName = provider.suggestedName ?? "image" - if let dotRange = extractedImageName.range(of: ".", options: .backwards) { - extractedImageName = String(extractedImageName[.. Bool { - // Content is valid only if we have an item provider for an image AND a bearer token - return imageItemProvider != nil && bearerToken != nil - } - - override func didSelectPost() { - refreshToken { - // This method is called when the user taps the "Post" button. - // Start the asynchronous operation here. - - guard let provider = self.imageItemProvider else { - print("Error: No image item provider found when posting.") - // Inform the user or log an error - self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) - return - } - - guard let token = self.bearerToken else { - print("Error: Bearer token is missing when posting.") - // Inform the user or log an error - self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil) - return - } - - // Load the image data asynchronously - provider.loadItem(forTypeIdentifier: kUTTypeImage as String, options: nil) { [weak self] (item, error) in - guard let self = self else { return } - - if let error = error { - print("Error loading image data for upload: \(error.localizedDescription)") - // Inform the user about the failure - self.extensionContext!.cancelRequest(withError: error) - return - } - - var rawImageData: Data? - var finalImageName = self.extractedImageName // Use the name extracted earlier - - if let url = item as? URL, let data = try? Data(contentsOf: url) { - rawImageData = data - // Refine the name extraction here if necessary, though doing it in viewDidLoad is also an option - finalImageName = url.lastPathComponent - if let dotRange = finalImageName.range(of: ".", options: .backwards) { - finalImageName = String(finalImageName[.. Void) { - let url = URL(string: "https://haystack.johncosta.tech/auth/refresh")! - var request = URLRequest(url: url) - request.httpMethod = "POST" - request.setValue("application/json", forHTTPHeaderField: "Content-Type") - - let body = ["refresh": refreshToken] - request.httpBody = try? JSONSerialization.data(withJSONObject: body, options: []) - - let task = URLSession.shared.dataTask(with: request) { [weak self] (data, response, error) in - guard let self = self else { return } - - if let data = data, - let json = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any], - let accessToken = json["access"] as? String { - - if let sharedDefaults = UserDefaults(suiteName: self.appGroupName) { - sharedDefaults.set(accessToken, forKey: self.tokenKey) - self.bearerToken = accessToken - } - } - - completion() - } - - task.resume() - } - - override func configurationItems() -> [Any]! { - // You can add items here if you want to allow the user to enter additional info - // e.g., a text field for a caption. - // This example only handles image upload, so no config items are needed. - return [] - } -} diff --git a/frontend/src-tauri/gen/apple/Sharing/ShareViewController.swift b/frontend/src-tauri/gen/apple/Sharing/ShareViewController.swift index ed608ab..37abe17 100644 --- a/frontend/src-tauri/gen/apple/Sharing/ShareViewController.swift +++ b/frontend/src-tauri/gen/apple/Sharing/ShareViewController.swift @@ -49,8 +49,8 @@ class ShareViewController: SLComposeServiceViewController { } override func isContentValid() -> Bool { - // Content is valid only if we have an item provider for an image AND a bearer token - return imageItemProvider != nil && bearerToken != nil + // Content is valid only if we have an item provider for an image AND a refresh token + return imageItemProvider != nil && refreshToken != nil } override func didSelectPost() { diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index f0dadae..a0943e4 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -23,8 +23,8 @@ type BaseRequestParams = Partial<{ method: "GET" | "POST" | "DELETE"; }>; -export const base = "https://haystack.johncosta.tech"; -// export const base = "http://192.168.1.199:3040"; +// export const base = "https://haystack.johncosta.tech"; +export const base = "http://192.168.1.199:3040"; const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => { return new Request(`${base}/${path}`, {