From 6d373100d922f55f72150e4313b46c293d1872de Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 10 Jul 2026 15:11:12 -0400 Subject: [PATCH] Keep share extension helpers target-local --- bitchat/Services/SharedContentHandoff.swift | 9 --------- bitchatShareExtension/ShareViewController.swift | 8 +++++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/bitchat/Services/SharedContentHandoff.swift b/bitchat/Services/SharedContentHandoff.swift index 0db94a19..0e3dce83 100644 --- a/bitchat/Services/SharedContentHandoff.swift +++ b/bitchat/Services/SharedContentHandoff.swift @@ -45,10 +45,6 @@ struct SharedContentPayload: Codable, Sendable, Equatable, Identifiable { SharedContentPayload(kind: .text, content: content, createdAt: createdAt) } - static func url(_ url: URL, title: String?, createdAt: Date = Date()) -> SharedContentPayload { - SharedContentPayload(kind: .url, content: url.absoluteString, title: title, createdAt: createdAt) - } - var composerText: String { content } var preview: String { @@ -148,11 +144,6 @@ final class SharedContentStore { self.decoder = JSONDecoder() } - convenience init?(suiteName: String) { - guard let defaults = UserDefaults(suiteName: suiteName) else { return nil } - self.init(defaults: defaults) - } - /// Replaces any older pending share with a validated, bounded envelope. func stage(_ payload: SharedContentPayload, now: Date = Date()) throws { try payload.validate(now: now) diff --git a/bitchatShareExtension/ShareViewController.swift b/bitchatShareExtension/ShareViewController.swift index af435ddb..d46f1c1f 100644 --- a/bitchatShareExtension/ShareViewController.swift +++ b/bitchatShareExtension/ShareViewController.swift @@ -148,8 +148,9 @@ final class ShareViewController: UIViewController { // MARK: - Save + Finish private func saveAndFinish(url: URL, title: String?) { - let payload = SharedContentPayload.url( - url, + let payload = SharedContentPayload( + kind: .url, + content: url.absoluteString, title: title ?? url.host ?? Strings.sharedLinkTitleFallback ) stageAndFinish(payload) @@ -160,10 +161,11 @@ final class ShareViewController: UIViewController { } private func stageAndFinish(_ payload: SharedContentPayload) { - guard let store = SharedContentStore(suiteName: Self.groupID) else { + guard let defaults = UserDefaults(suiteName: Self.groupID) else { finishWithMessage(Strings.failedToSave) return } + let store = SharedContentStore(defaults: defaults) do { try store.stage(payload)