mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-22 21:08:15 +01:00
Widget: Remove optional parameters
This commit is contained in:
parent
a6fd8d1137
commit
7328c00006
@ -28,20 +28,14 @@ struct HashtagPostsWidgetProvider: AppIntentTimelineProvider {
|
||||
}
|
||||
|
||||
private func timeline(for configuration: HashtagPostsWidgetConfiguration, context: Context) async -> Timeline<PostsWidgetEntry> {
|
||||
guard let account = configuration.account, let hashgtag = configuration.hashgtag else {
|
||||
return Timeline(entries: [.init(date: Date(),
|
||||
timeline: .hashtag(tag: "Mastodon", accountId: nil),
|
||||
statuses: [],
|
||||
images: [:])],
|
||||
policy: .atEnd)
|
||||
}
|
||||
do {
|
||||
let statuses = await loadStatuses(for: .hashtag(tag: hashgtag, accountId: nil),
|
||||
account: account,
|
||||
let statuses = await loadStatuses(for: .hashtag(tag: configuration.hashgtag, accountId: nil),
|
||||
account: configuration.account,
|
||||
widgetFamily: context.family)
|
||||
let images = try await loadImages(urls: statuses.map{ $0.account.avatar } )
|
||||
return Timeline(entries: [.init(date: Date(),
|
||||
timeline: .hashtag(tag: hashgtag, accountId: nil),
|
||||
timeline: .hashtag(tag: configuration.hashgtag,
|
||||
accountId: nil),
|
||||
statuses: statuses,
|
||||
images: images)], policy: .atEnd)
|
||||
} catch {
|
||||
|
@ -6,10 +6,10 @@ struct HashtagPostsWidgetConfiguration: WidgetConfigurationIntent {
|
||||
static let description = IntentDescription("Choose the account and hashtag for this widget")
|
||||
|
||||
@Parameter(title: "Account")
|
||||
var account: AppAccountEntity?
|
||||
var account: AppAccountEntity
|
||||
|
||||
@Parameter(title: "Hashtag")
|
||||
var hashgtag: String?
|
||||
var hashgtag: String
|
||||
}
|
||||
|
||||
extension HashtagPostsWidgetConfiguration {
|
||||
|
@ -27,21 +27,13 @@ struct LatestPostsWidgetProvider: AppIntentTimelineProvider {
|
||||
}
|
||||
|
||||
private func timeline(for configuration: LatestPostsWidgetConfiguration, context: Context) async -> Timeline<PostsWidgetEntry> {
|
||||
guard let account = configuration.account, let timeline = configuration.timeline else {
|
||||
return Timeline(entries: [.init(date: Date(),
|
||||
timeline: .home,
|
||||
statuses: [],
|
||||
images: [:])],
|
||||
policy: .atEnd)
|
||||
}
|
||||
|
||||
do {
|
||||
let statuses = await loadStatuses(for: timeline.timeline,
|
||||
account: account,
|
||||
widgetFamily: context.family)
|
||||
let statuses = await loadStatuses(for: configuration.timeline.timeline,
|
||||
account: configuration.account,
|
||||
widgetFamily: context.family)
|
||||
let images = try await loadImages(urls: statuses.map{ $0.account.avatar } )
|
||||
return Timeline(entries: [.init(date: Date(),
|
||||
timeline: timeline.timeline,
|
||||
timeline: configuration.timeline.timeline,
|
||||
statuses: statuses,
|
||||
images: images)], policy: .atEnd)
|
||||
} catch {
|
||||
|
@ -6,10 +6,10 @@ struct LatestPostsWidgetConfiguration: WidgetConfigurationIntent {
|
||||
static let description = IntentDescription("Choose the account and timeline for this widget")
|
||||
|
||||
@Parameter(title: "Account")
|
||||
var account: AppAccountEntity?
|
||||
var account: AppAccountEntity
|
||||
|
||||
@Parameter(title: "Timeline")
|
||||
var timeline: TimelineFilterEntity?
|
||||
var timeline: TimelineFilterEntity
|
||||
}
|
||||
|
||||
extension LatestPostsWidgetConfiguration {
|
||||
|
Loading…
Reference in New Issue
Block a user