Filter for content warnings (IOS-37)

This commit is contained in:
Nathan Mattes 2023-04-22 23:00:55 +02:00
parent f5fca28cb0
commit 8b1316814a
2 changed files with 58 additions and 5 deletions

View File

@ -11,9 +11,9 @@
<key>INIntentDefinitionSystemVersion</key>
<string>22D68</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>14C18</string>
<string>14E222b</string>
<key>INIntentDefinitionToolsVersion</key>
<string>14.2</string>
<string>14.3</string>
<key>INIntents</key>
<array>
<dict>
@ -389,7 +389,7 @@
<key>INIntentIneligibleForSuggestions</key>
<true/>
<key>INIntentLastParameterTag</key>
<integer>5</integer>
<integer>7</integer>
<key>INIntentName</key>
<string>Hashtag</string>
<key>INIntentParameters</key>
@ -440,6 +440,48 @@
<key>INIntentParameterType</key>
<string>String</string>
</dict>
<dict>
<key>INIntentParameterConfigurable</key>
<true/>
<key>INIntentParameterDisplayName</key>
<string>Ignore content warnings</string>
<key>INIntentParameterDisplayNameID</key>
<string>xcBHPA</string>
<key>INIntentParameterDisplayPriority</key>
<integer>2</integer>
<key>INIntentParameterMetadata</key>
<dict>
<key>INIntentParameterMetadataFalseDisplayName</key>
<string>false</string>
<key>INIntentParameterMetadataFalseDisplayNameID</key>
<string>wftYbm</string>
<key>INIntentParameterMetadataTrueDisplayName</key>
<string>true</string>
<key>INIntentParameterMetadataTrueDisplayNameID</key>
<string>QkKsLf</string>
</dict>
<key>INIntentParameterName</key>
<string>ignoreContentWarnings</string>
<key>INIntentParameterPromptDialogs</key>
<array>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Configuration</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Primary</string>
</dict>
</array>
<key>INIntentParameterTag</key>
<integer>7</integer>
<key>INIntentParameterType</key>
<string>Boolean</string>
</dict>
</array>
<key>INIntentResponse</key>
<dict>

View File

@ -49,10 +49,17 @@ extension HashtagWidgetProvider {
do {
let mostRecentStatuses = try await WidgetExtension.appContext
.apiService
.hashtagTimeline(domain: authBox.domain, limit: 1, hashtag: desiredHashtag, authenticationBox: authBox)
.hashtagTimeline(domain: authBox.domain, limit: 40, hashtag: desiredHashtag, authenticationBox: authBox)
.value
if let mostRecentStatus = mostRecentStatuses.first {
let filteredStatuses: [Mastodon.Entity.Status]
if configuration.ignoreContentWarnings?.boolValue == true {
filteredStatuses = mostRecentStatuses
} else {
filteredStatuses = mostRecentStatuses.filter { $0.sensitive == false }
}
if let mostRecentStatus = filteredStatuses.first {
let hashtagEntry = HashtagEntry(
accountName: mostRecentStatus.account.displayNameWithFallback,
@ -70,6 +77,10 @@ extension HashtagWidgetProvider {
)
completion(hashtagTimelineEntry)
} else {
let noStatusFound = HashtagWidgetTimelineEntry.notFound
completion(noStatusFound)
}
} catch {
completion(.notFound)