Add local source ingest and podcasts

This commit is contained in:
Krishna Kumar
2026-07-02 01:11:03 -05:00
parent 4d875e12d6
commit f8693f4be0
18 changed files with 1044 additions and 31 deletions

View File

@@ -5,6 +5,8 @@ import SwiftUI
/// read-later flag before saving (new) or updating (existing) never a duplicate.
struct ShareView: View {
let url: String
let initialTitle: String?
let initialNotes: String
/// Called when the extension should dismiss. `saved` is true after a successful
/// write, false on cancel.
let onClose: (_ saved: Bool) -> Void
@@ -26,10 +28,14 @@ struct ShareView: View {
private let api: LinkdingAPI?
init(url: String, onClose: @escaping (_ saved: Bool) -> Void) {
init(url: String, initialTitle: String? = nil, initialNotes: String = "", onClose: @escaping (_ saved: Bool) -> Void) {
self.url = url
self.initialTitle = initialTitle
self.initialNotes = initialNotes
self.onClose = onClose
self.api = ServerConfig.loadShared().map(LinkdingAPI.init)
_title = State(initialValue: initialTitle ?? "")
_notes = State(initialValue: initialNotes)
}
private enum Phase { case loading, editing, saving, done, failed }
@@ -225,6 +231,14 @@ struct ShareView: View {
// MARK: - Networking
private func check() async {
guard let parsed = URL(string: url),
let scheme = parsed.scheme?.lowercased(),
scheme == "http" || scheme == "https",
parsed.host?.isEmpty == false else {
errorMessage = "No bookmarkable link found"
phase = .failed
return
}
guard let api else {
errorMessage = "Open Marks first"
phase = .failed
@@ -239,8 +253,11 @@ struct ShareView: View {
notes = bookmark.description
readLater = bookmark.unread
} else {
title = result.metadata?.title ?? ""
title = initialTitle ?? result.metadata?.title ?? ""
suggestedTags = result.autoTags ?? []
if notes.isEmpty {
notes = result.metadata?.description ?? initialNotes
}
}
// Pre-enable the toggle when the current tags match the auto-rule.
createPodcast = PodcastRequests.matchesAutoTag(parsedTags)
@@ -295,6 +312,7 @@ struct ShareView: View {
let create = BookmarkCreate(
url: url,
title: "",
description: notes,
tagNames: parsedTags,
isArchived: false,
unread: readLater,