Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work around mastodon mute bug #2150

Merged
merged 1 commit into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class SearchViewModel @Inject constructor(
return accountManager.getAllAccountsOrderedByActive()
}

fun muteAccount(accountId: String, notifications: Boolean, duration: Int) {
fun muteAccount(accountId: String, notifications: Boolean, duration: Int?) {
timelineCases.mute(accountId, notifications, duration)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface TimelineCases {
fun reblog(status: Status, reblog: Boolean): Single<Status>
fun favourite(status: Status, favourite: Boolean): Single<Status>
fun bookmark(status: Status, bookmark: Boolean): Single<Status>
fun mute(id: String, notifications: Boolean, duration: Int)
fun mute(id: String, notifications: Boolean, duration: Int?)
fun block(id: String)
fun delete(id: String): Single<DeletedStatus>
fun pin(status: Status, pin: Boolean)
Expand Down Expand Up @@ -104,7 +104,7 @@ class TimelineCasesImpl(
}
}

override fun mute(id: String, notifications: Boolean, duration: Int) {
override fun mute(id: String, notifications: Boolean, duration: Int?) {
mastodonApi.muteAccount(id, notifications, duration)
.subscribe({
eventHub.dispatch(MuteEvent(id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.keylesspalace.tusky.databinding.DialogMuteAccountBinding
fun showMuteAccountDialog(
activity: Activity,
accountUsername: String,
onOk: (notifications: Boolean, duration: Int) -> Unit
onOk: (notifications: Boolean, duration: Int?) -> Unit
) {
val binding = DialogMuteAccountBinding.inflate(activity.layoutInflater)
binding.warning.text = activity.getString(R.string.dialog_mute_warning, accountUsername)
Expand All @@ -20,7 +20,16 @@ fun showMuteAccountDialog(
.setView(binding.root)
.setPositiveButton(android.R.string.ok) { _, _ ->
val durationValues = activity.resources.getIntArray(R.array.mute_duration_values)
onOk(binding.checkbox.isChecked, durationValues[binding.duration.selectedItemPosition])

// workaround to make indefinite muting work with Mastodon 3.3.0
// https://github.com/tuskyapp/Tusky/issues/2107
val duration = if(binding.duration.selectedItemPosition == 0) {
null
} else {
durationValues[binding.duration.selectedItemPosition]
}

onOk(binding.checkbox.isChecked, duration)
}
.setNegativeButton(android.R.string.cancel, null)
.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AccountViewModel @Inject constructor(
}
}

fun muteAccount(notifications: Boolean, duration: Int) {
fun muteAccount(notifications: Boolean, duration: Int?) {
changeRelationship(RelationShipAction.MUTE, notifications, duration)
}

Expand Down