Fix indexable setting

This commit is contained in:
Grishka 2023-09-22 21:33:21 +03:00
parent f24eba08d3
commit fe1cfa1d7b
4 changed files with 10 additions and 8 deletions

View File

@ -195,7 +195,7 @@ public class AccountSession{
public void savePreferencesIfPending(){ public void savePreferencesIfPending(){
if(preferencesNeedSaving){ if(preferencesNeedSaving){
new UpdateAccountCredentialsPreferences(preferences, null, self.discoverable, !self.noindex) new UpdateAccountCredentialsPreferences(preferences, null, self.discoverable, self.source.indexable)
.setCallback(new Callback<>(){ .setCallback(new Callback<>(){
@Override @Override
public void onSuccess(Account result){ public void onSuccess(Account result){

View File

@ -19,8 +19,10 @@ public class SettingsPrivacyFragment extends BaseSettingsFragment<Void>{
Account self=AccountSessionManager.get(accountID).self; Account self=AccountSessionManager.get(accountID).self;
onDataLoaded(List.of( onDataLoaded(List.of(
discoverableItem=new CheckableListItem<>(R.string.settings_discoverable, 0, CheckableListItem.Style.SWITCH, self.discoverable, R.drawable.ic_thumbs_up_down_24px, ()->toggleCheckableItem(discoverableItem)), discoverableItem=new CheckableListItem<>(R.string.settings_discoverable, 0, CheckableListItem.Style.SWITCH, self.discoverable, R.drawable.ic_thumbs_up_down_24px, ()->toggleCheckableItem(discoverableItem)),
indexableItem=new CheckableListItem<>(R.string.settings_indexable, 0, CheckableListItem.Style.SWITCH, self.indexable, R.drawable.ic_search_24px, ()->toggleCheckableItem(indexableItem)) indexableItem=new CheckableListItem<>(R.string.settings_indexable, 0, CheckableListItem.Style.SWITCH, self.source.indexable!=null ? self.source.indexable : true, R.drawable.ic_search_24px, ()->toggleCheckableItem(indexableItem))
)); ));
if(self.source.indexable==null)
indexableItem.isEnabled=false;
} }
@Override @Override
@ -30,9 +32,9 @@ public class SettingsPrivacyFragment extends BaseSettingsFragment<Void>{
public void onPause(){ public void onPause(){
super.onPause(); super.onPause();
Account self=AccountSessionManager.get(accountID).self; Account self=AccountSessionManager.get(accountID).self;
if(self.discoverable!=discoverableItem.checked || self.indexable!=indexableItem.checked){ if(self.discoverable!=discoverableItem.checked || (self.source.indexable!=null && self.source.indexable!=indexableItem.checked)){
self.discoverable=discoverableItem.checked; self.discoverable=discoverableItem.checked;
self.indexable=indexableItem.checked; self.source.indexable=indexableItem.checked;
AccountSessionManager.get(accountID).savePreferencesLater(); AccountSessionManager.get(accountID).savePreferencesLater();
} }
} }

View File

@ -133,8 +133,6 @@ public class Account extends BaseModel{
*/ */
public Instant muteExpiresAt; public Instant muteExpiresAt;
public boolean noindex; public boolean noindex;
public boolean indexable;
public boolean hideCollections;
@Override @Override
@ -195,8 +193,6 @@ public class Account extends BaseModel{
", suspended="+suspended+ ", suspended="+suspended+
", muteExpiresAt="+muteExpiresAt+ ", muteExpiresAt="+muteExpiresAt+
", noindex="+noindex+ ", noindex="+noindex+
", indexable="+indexable+
", hideCollections="+hideCollections+
'}'; '}';
} }
} }

View File

@ -37,6 +37,8 @@ public class Source extends BaseModel{
* The number of pending follow requests. * The number of pending follow requests.
*/ */
public int followRequestCount; public int followRequestCount;
public Boolean indexable;
public boolean hideCollections;
@Override @Override
public void postprocess() throws ObjectValidationException{ public void postprocess() throws ObjectValidationException{
@ -54,6 +56,8 @@ public class Source extends BaseModel{
", sensitive="+sensitive+ ", sensitive="+sensitive+
", language='"+language+'\''+ ", language='"+language+'\''+
", followRequestCount="+followRequestCount+ ", followRequestCount="+followRequestCount+
", indexable="+indexable+
", hideCollections="+hideCollections+
'}'; '}';
} }
} }