Add edit bookmark, offline cache, and unread filter

- Edit bookmark: full PATCH via swipe action or long-press context menu;
  EditBookmarkView covers URL, title, description, tags, and unread toggle
- Offline cache: bookmarks persisted to ApplicationSupport JSON and shown
  instantly on launch; cache is per-server, skipped when unread filter is on
- Unread filter: toolbar toggle sends ?unread=true to the API; title updates
  to "Unread"; no stale-cache flash when toggling
- Extract normalizedURL and parsedTags into String+Helpers, removing three
  copies of URL normalization and two of tag parsing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Krishna Kumar
2026-05-21 11:51:54 -05:00
parent b7ef5c2215
commit 1b40f50aab
11 changed files with 269 additions and 20 deletions

View File

@@ -57,12 +57,13 @@ actor LinkdingAPI {
return req
}
func fetchBookmarks(search: String = "", offset: Int = 0, limit: Int = 50) async throws -> BookmarkResponse {
func fetchBookmarks(search: String = "", offset: Int = 0, limit: Int = 50, unread: Bool = false) async throws -> BookmarkResponse {
var items: [URLQueryItem] = [
.init(name: "limit", value: "\(limit)"),
.init(name: "offset", value: "\(offset)")
]
if !search.isEmpty { items.append(.init(name: "q", value: search)) }
if unread { items.append(.init(name: "unread", value: "true")) }
let url = try makeUrl(path: "/api/bookmarks/", queryItems: items)
let (data, response) = try await session.data(for: authorizedRequest(url: url))
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
@@ -87,8 +88,8 @@ actor LinkdingAPI {
return try decoder.decode(Bookmark.self, from: data)
}
func updateBookmark(id: Int, tagNames: [String]) async throws -> Bookmark {
let body = try JSONEncoder().encode(["tag_names": tagNames])
func updateBookmark(id: Int, update: BookmarkUpdate) async throws -> Bookmark {
let body = try JSONEncoder().encode(update)
let url = try makeUrl(path: "/api/bookmarks/\(id)/")
let (data, response) = try await session.data(for: authorizedRequest(url: url, method: "PATCH", body: body))
guard (response as? HTTPURLResponse)?.statusCode == 200 else {