unsubscribe from notifications when policy is none

re: mastodon#520
This commit is contained in:
sk 2023-01-26 15:48:10 +01:00 committed by LucasGGamerM
parent 10d66b732c
commit 55f3d80f3a
1 changed files with 5 additions and 1 deletions

View File

@ -536,9 +536,13 @@ public class SettingsFragment extends MastodonToolbarFragment{
list.getAdapter().notifyItemChanged(index); list.getAdapter().notifyItemChanged(index);
} }
if((prevPolicy==PushSubscription.Policy.NONE)!=(policy==PushSubscription.Policy.NONE)){ if((prevPolicy==PushSubscription.Policy.NONE)!=(policy==PushSubscription.Policy.NONE)){
boolean newState=policy!=PushSubscription.Policy.NONE;
for(PushNotification.Type value : PushNotification.Type.values()){
onNotificationsChanged(value, newState);
}
index++; index++;
while(items.get(index) instanceof SwitchItem si){ while(items.get(index) instanceof SwitchItem si){
si.enabled=si.checked=policy!=PushSubscription.Policy.NONE; si.enabled=si.checked=newState;
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(index); RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(index);
if(holder!=null) if(holder!=null)
((BindableViewHolder<?>)holder).rebind(); ((BindableViewHolder<?>)holder).rebind();