Add save to omnivore shortcut

This commit is contained in:
Jackson Harper 2023-02-07 10:45:21 +08:00
parent 5c636e7482
commit 7c55ed7a4c
3 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,57 @@
//
// SavePasteboardToOmnivore.swift
//
//
// Created by Jackson Harper on 2/6/23.
//
import AppIntents
import Services
import SwiftUI
@available(iOS 16.0, *)
struct SaveLinkToOmnivoreIntent: AppIntent {
static var title: LocalizedStringResource = "Show Sport Progress"
static var parameterSummary: some ParameterSummary {
Summary("Save \(\.$link) to your Omnivore library.")
}
@Parameter(title: "link")
var link: URL
@MainActor
func perform() async throws -> some IntentResult {
do {
let services = Services()
let requestId = UUID().uuidString.lowercased()
let saveResult = try await services.dataService.saveURL(id: requestId, url: link.absoluteString)
return .result(dialog: "Link saved to Omnivore")
} catch {
print("error saving URL: ", error)
}
return .result(dialog: "Error saving link")
}
}
// @available(iOS 16.0, *)
// struct ReadInOmnivoreIntent: AppIntent {
// static var title: LocalizedStringResource = "Read saved link"
// static var description = IntentDescription("Reads a link you have already saved to your library")
// static var openAppWhenRun: Bool = true
//
// @Parameter(title: "requestID")
// var link: String
//
// func perform() async throws -> some IntentResult {
// .result(dialog: "Opening in Omnivore")
// }
// }
//
// @available(iOS 16.0, *)
// struct OmnivoreShortcuts: AppShortcutsProvider {
// static var appShortcuts: [AppShortcut] {
// AppShortcut(intent: SaveLinkToOmnivoreIntent(), phrases: ["Save to \(.applicationName)"])
// }
// }

View file

@ -6,6 +6,7 @@
"saveArticleSavedState" = "Saved to Omnivore";
"saveArticleProcessingState" = "Saved to Omnivore";
"extensionAppUnauthorized" = "Please login to Omnivore from the app before saving your first link.";
"saveToOmnivore" = "Save to Omnivore";
// audio player
"audioPlayerReplay" = "Replay";

View file

@ -7,6 +7,8 @@
"saveArticleProcessingState" = "已经保存到 Omnivore 中";
"extensionAppUnauthorized" = "请在保存您的第一个链接之前从应用程序登录 Omnivore.";
"saveToOmnivore" = "Save to Omnivore";
// audio player
"audioPlayerReplay" = "重播";