Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate AddEntryIntent to App intenets #407

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Intents/AddEntryIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import AppIntents
import WallabagKit

struct AddEntryIntent: WallabagIntent {

static var title: LocalizedStringResource = "Add Entry"

static var description: IntentDescription = IntentDescription("Add entry to your instance")

@Parameter(title: "Url")
var url: URL

static var parameterSummary: some ParameterSummary {
Summary("Add \(\.$url)")
}

func perform() async throws -> some IntentResult {
_ = try await kit.send(to: WallabagEntryEndpoint.add(url: url.absoluteString))
.receive(on: DispatchQueue.main)
.values
.first(where: {(_: WallabagEntry) in true})
return .result()
}
}
16 changes: 16 additions & 0 deletions Intents/WallabagIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import WallabagKit
import AppIntents
import SharedLib

protocol WallabagIntent: AppIntent {}

extension WallabagIntent {
var kit: WallabagKit {
let kit = WallabagKit(host: WallabagUserDefaults.host)
kit.clientId = WallabagUserDefaults.clientId
kit.clientSecret = WallabagUserDefaults.clientSecret
kit.username = WallabagUserDefaults.login
kit.password = WallabagUserDefaults.password
return kit
}
}
42 changes: 0 additions & 42 deletions Shortcuts/AddEntryIntentHandler.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Shortcuts/Info.plist

This file was deleted.

12 changes: 0 additions & 12 deletions Shortcuts/IntentHandler.swift

This file was deleted.

170 changes: 0 additions & 170 deletions Shortcuts/Intents.intentdefinition

This file was deleted.

10 changes: 0 additions & 10 deletions Shortcuts/Shortcuts.entitlements

This file was deleted.

Loading