fix sensitive media in search and notifications (#2335)
This commit is contained in:
parent
8335a3bb3c
commit
329df1280b
|
@ -56,8 +56,15 @@ class SearchViewModel @Inject constructor(
|
||||||
private val loadedStatuses: MutableList<Pair<Status, StatusViewData.Concrete>> = mutableListOf()
|
private val loadedStatuses: MutableList<Pair<Status, StatusViewData.Concrete>> = mutableListOf()
|
||||||
|
|
||||||
private val statusesPagingSourceFactory = SearchPagingSourceFactory(mastodonApi, SearchType.Status, loadedStatuses) {
|
private val statusesPagingSourceFactory = SearchPagingSourceFactory(mastodonApi, SearchType.Status, loadedStatuses) {
|
||||||
it.statuses.map { status -> Pair(status, status.toViewData(alwaysShowSensitiveMedia, alwaysOpenSpoiler, true)) }
|
it.statuses.map { status ->
|
||||||
.apply {
|
val statusViewData = status.toViewData(
|
||||||
|
isShowingContent = alwaysShowSensitiveMedia || !status.actionableStatus.sensitive,
|
||||||
|
isExpanded = alwaysOpenSpoiler,
|
||||||
|
isCollapsed = true
|
||||||
|
)
|
||||||
|
|
||||||
|
Pair(status, statusViewData)
|
||||||
|
}.apply {
|
||||||
loadedStatuses.addAll(this)
|
loadedStatuses.addAll(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,8 +107,7 @@ class SearchViewModel @Inject constructor(
|
||||||
if (loadedStatuses.remove(status))
|
if (loadedStatuses.remove(status))
|
||||||
statusesPagingSourceFactory.invalidate()
|
statusesPagingSourceFactory.invalidate()
|
||||||
},
|
},
|
||||||
{
|
{ err ->
|
||||||
err ->
|
|
||||||
Log.d(TAG, "Failed to delete status", err)
|
Log.d(TAG, "Failed to delete status", err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -185,9 +185,11 @@ public class NotificationsFragment extends SFragment implements
|
||||||
Notification notification = input.asRight()
|
Notification notification = input.asRight()
|
||||||
.rewriteToStatusTypeIfNeeded(accountManager.getActiveAccount().getAccountId());
|
.rewriteToStatusTypeIfNeeded(accountManager.getActiveAccount().getAccountId());
|
||||||
|
|
||||||
|
boolean sensitiveStatus = notification.getStatus() != null && notification.getStatus().getActionableStatus().getSensitive();
|
||||||
|
|
||||||
return ViewDataUtils.notificationToViewData(
|
return ViewDataUtils.notificationToViewData(
|
||||||
notification,
|
notification,
|
||||||
alwaysShowSensitiveMedia,
|
alwaysShowSensitiveMedia || !sensitiveStatus,
|
||||||
alwaysOpenSpoiler,
|
alwaysOpenSpoiler,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue