-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate AddEntryIntent to App intenets (#407)
* Remove Shortcuts * Migrate AddEntryIntent to AppIntent
- Loading branch information
Showing
9 changed files
with
56 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.