Implement timed mutes. (#2035)

Fixes #2033
This commit is contained in:
Levi Bard 2021-01-15 21:05:36 +01:00 committed by GitHub
commit be60155de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 303 additions and 260 deletions

View file

@ -119,8 +119,8 @@ class AccountViewModel @Inject constructor(
}
}
fun muteAccount(notifications: Boolean) {
changeRelationship(RelationShipAction.MUTE, notifications)
fun muteAccount(notifications: Boolean, duration: Int) {
changeRelationship(RelationShipAction.MUTE, notifications, duration)
}
fun unmuteAccount() {
@ -187,7 +187,7 @@ class AccountViewModel @Inject constructor(
/**
* @param parameter showReblogs if RelationShipAction.FOLLOW, notifications if MUTE
*/
private fun changeRelationship(relationshipAction: RelationShipAction, parameter: Boolean? = null) {
private fun changeRelationship(relationshipAction: RelationShipAction, parameter: Boolean? = null, duration: Int? = null) {
val relation = relationshipData.value?.data
val account = accountData.value?.data
val isMastodon = relationshipData.value?.data?.notifying != null
@ -227,7 +227,7 @@ class AccountViewModel @Inject constructor(
RelationShipAction.UNFOLLOW -> mastodonApi.unfollowAccount(accountId)
RelationShipAction.BLOCK -> mastodonApi.blockAccount(accountId)
RelationShipAction.UNBLOCK -> mastodonApi.unblockAccount(accountId)
RelationShipAction.MUTE -> mastodonApi.muteAccount(accountId, parameter ?: true)
RelationShipAction.MUTE -> mastodonApi.muteAccount(accountId, parameter ?: true, duration)
RelationShipAction.UNMUTE -> mastodonApi.unmuteAccount(accountId)
RelationShipAction.SUBSCRIBE -> {
if(isMastodon)