fix sensitive media in search and notifications (#2335)

This commit is contained in:
Konrad Pozniak 2022-02-12 09:56:08 +01:00 committed by GitHub
parent 8335a3bb3c
commit 329df1280b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -56,10 +56,17 @@ class SearchViewModel @Inject constructor(
private val loadedStatuses: MutableList<Pair<Status, StatusViewData.Concrete>> = mutableListOf()
private val statusesPagingSourceFactory = SearchPagingSourceFactory(mastodonApi, SearchType.Status, loadedStatuses) {
it.statuses.map { status -> Pair(status, status.toViewData(alwaysShowSensitiveMedia, alwaysOpenSpoiler, true)) }
.apply {
loadedStatuses.addAll(this)
}
it.statuses.map { status ->
val statusViewData = status.toViewData(
isShowingContent = alwaysShowSensitiveMedia || !status.actionableStatus.sensitive,
isExpanded = alwaysOpenSpoiler,
isCollapsed = true
)
Pair(status, statusViewData)
}.apply {
loadedStatuses.addAll(this)
}
}
private val accountsPagingSourceFactory = SearchPagingSourceFactory(mastodonApi, SearchType.Account) {
it.accounts
@ -100,8 +107,7 @@ class SearchViewModel @Inject constructor(
if (loadedStatuses.remove(status))
statusesPagingSourceFactory.invalidate()
},
{
err ->
{ err ->
Log.d(TAG, "Failed to delete status", err)
}
)

View file

@ -185,9 +185,11 @@ public class NotificationsFragment extends SFragment implements
Notification notification = input.asRight()
.rewriteToStatusTypeIfNeeded(accountManager.getActiveAccount().getAccountId());
boolean sensitiveStatus = notification.getStatus() != null && notification.getStatus().getActionableStatus().getSensitive();
return ViewDataUtils.notificationToViewData(
notification,
alwaysShowSensitiveMedia,
alwaysShowSensitiveMedia || !sensitiveStatus,
alwaysOpenSpoiler,
true
);