This commit is contained in:
Levi Bard 2022-12-08 09:58:58 +01:00 committed by GitHub
parent 88125ef7da
commit 51d02388b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,11 +22,8 @@ import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.fragment.app.commit
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import at.connyduck.calladapter.networkresult.fold
import autodispose2.androidx.lifecycle.AndroidLifecycleScopeProvider
import autodispose2.autoDispose
import com.google.android.material.snackbar.Snackbar
import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
@ -37,7 +34,6 @@ import com.keylesspalace.tusky.entity.Filter
import com.keylesspalace.tusky.util.viewBinding
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasAndroidInjector
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import kotlinx.coroutines.launch
import javax.inject.Inject
@ -175,16 +171,16 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector {
muteTagItem?.isEnabled = false
unmuteTagItem?.isVisible = false
mastodonApi.getFilters().observeOn(AndroidSchedulers.mainThread())
.autoDispose(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))
.subscribe { filters ->
lifecycleScope.launch {
mastodonApi.getFilters().fold(
{ filters ->
for (filter in filters) {
if ((tag == filter.phrase) and filter.context.contains(Filter.HOME)) {
Log.d(TAG, "Tag $hashtag is filtered")
muteTagItem?.isVisible = false
unmuteTagItem?.isVisible = true
mutedFilter = filter
return@subscribe
return@fold
}
}
@ -193,6 +189,11 @@ class StatusListActivity : BottomSheetActivity(), HasAndroidInjector {
muteTagItem?.isEnabled = true
muteTagItem?.isVisible = true
muteTagItem?.isVisible = true
},
{ throwable ->
Log.e(TAG, "Error getting filters: $throwable")
}
)
}
}