Skip to content

Commit

Permalink
Migrate AddEntryIntent to App intenets (#407)
Browse files Browse the repository at this point in the history
* Remove Shortcuts

* Migrate AddEntryIntent to AppIntent
  • Loading branch information
huseyz authored Jan 22, 2024
1 parent d4defcd commit d9bc0b2
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 529 deletions.
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

0 comments on commit d9bc0b2

Please sign in to comment.