mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 21:05:20 +00:00
refactor: remove dead code and consolidate system messages
- Delete 3 unused functions in ShareViewController (36 lines) - Extract addSystemMessage() helper to eliminate duplication (120+ lines) - Remove 22 'let _ =' wasteful computations across multiple files - Net reduction of 215 lines of dead/duplicate code - Improves maintainability and reduces technical debt
This commit is contained in:
@@ -138,44 +138,6 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
|
||||
// MARK: - Helper Methods
|
||||
|
||||
private func handleSharedText(_ text: String) {
|
||||
// Save to shared user defaults to pass to main app
|
||||
saveToSharedDefaults(content: text, type: "text")
|
||||
openMainApp()
|
||||
}
|
||||
|
||||
private func handleSharedURL(_ url: URL) {
|
||||
// Get the page title if available from the extension context
|
||||
var pageTitle: String? = nil
|
||||
if let item = extensionContext?.inputItems.first as? NSExtensionItem {
|
||||
pageTitle = item.attributedContentText?.string ?? item.attributedTitle?.string
|
||||
}
|
||||
|
||||
// Create a structured format for URL sharing
|
||||
let urlData: [String: String] = [
|
||||
"url": url.absoluteString,
|
||||
"title": pageTitle ?? url.host ?? "Shared Link"
|
||||
]
|
||||
|
||||
// Convert to JSON string
|
||||
if let jsonData = try? JSONSerialization.data(withJSONObject: urlData),
|
||||
let jsonString = String(data: jsonData, encoding: .utf8) {
|
||||
saveToSharedDefaults(content: jsonString, type: "url")
|
||||
} else {
|
||||
// Fallback to simple URL
|
||||
saveToSharedDefaults(content: url.absoluteString, type: "url")
|
||||
}
|
||||
|
||||
openMainApp()
|
||||
}
|
||||
|
||||
private func handleSharedImage(_ image: UIImage) {
|
||||
// For now, we'll just notify that image sharing isn't supported
|
||||
// In the future, we could implement image sharing via the mesh
|
||||
saveToSharedDefaults(content: "Image sharing coming soon!", type: "image")
|
||||
openMainApp()
|
||||
}
|
||||
|
||||
private func saveToSharedDefaults(content: String, type: String) {
|
||||
// Use app groups to share data between extension and main app
|
||||
guard let userDefaults = UserDefaults(suiteName: "group.chat.bitchat") else {
|
||||
|
||||
Reference in New Issue
Block a user