Removed "Community Recommended Sort type" option

Caused some issues, described in #151. Also, this is not a feature in Lemmy, should have been removed anyway.
This commit is contained in:
Balazs Toldi 2024-06-21 21:19:31 +02:00
parent 1390460438
commit ae389527b6
3 changed files with 5 additions and 61 deletions

View File

@ -228,8 +228,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
int mMessageFullname; int mMessageFullname;
@State @State
SortType.Type sortType; SortType.Type sortType;
@State
boolean mRespectSubredditRecommendedSortType;
@State @State
long viewPostDetailFragmentId; long viewPostDetailFragmentId;
@State @State
@ -333,7 +332,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false); mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false); mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
if (savedInstanceState == null) { if (savedInstanceState == null) {
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
viewPostDetailFragmentId = System.currentTimeMillis(); viewPostDetailFragmentId = System.currentTimeMillis();
} else { } else {
scrollPosition = savedInstanceState.getInt(SCROLL_POSITION_STATE); scrollPosition = savedInstanceState.getInt(SCROLL_POSITION_STATE);
@ -577,7 +575,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
mMessageFullname = getArguments().getInt(EXTRA_MESSAGE_FULLNAME); mMessageFullname = getArguments().getInt(EXTRA_MESSAGE_FULLNAME);
if (!mRespectSubredditRecommendedSortType || isSingleCommentThreadMode) { if (isSingleCommentThreadMode) {
sortType = loadSortType(); sortType = loadSortType();
activity.setTitle(sortType.fullName); activity.setTitle(sortType.fullName);
} }
@ -824,8 +822,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) { if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply(); mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply();
} }
mRespectSubredditRecommendedSortType = false; fetchComments(false, sortType.getType());
fetchCommentsRespectRecommendedSort(false, sortType.getType());
} }
@NonNull @NonNull
@ -1400,9 +1397,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mRecyclerView.setAdapter(mConcatAdapter); mRecyclerView.setAdapter(mConcatAdapter);
} }
if (mRespectSubredditRecommendedSortType) {
fetchCommentsRespectRecommendedSort(false);
}
ViewPostDetailFragment.this.children = children; ViewPostDetailFragment.this.children = children;
} }
@ -1427,49 +1422,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState, SortType.Type sortType) {
if (mRespectSubredditRecommendedSortType && mPost != null) {
if (mPost.getSuggestedSort() != null && !mPost.getSuggestedSort().equals("null") && !mPost.getSuggestedSort().equals("")) {
try {
SortType.Type sortTypeType = SortType.Type.valueOf(mPost.getSuggestedSort().toUpperCase(Locale.US));
activity.setTitle(sortTypeType.fullName);
ViewPostDetailFragment.this.sortType = sortTypeType;
fetchComments(changeRefreshState, ViewPostDetailFragment.this.sortType);
return;
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mPost.getSubredditNamePrefixed(), mAccessToken,
new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
String suggestedCommentSort = "top";
SortType.Type sortTypeType;
try {
sortTypeType = SortType.Type.fromValue(suggestedCommentSort);
} catch (IllegalArgumentException e) {
e.printStackTrace();
sortTypeType = loadSortType();
}
activity.setTitle(sortTypeType.fullName);
ViewPostDetailFragment.this.sortType = sortTypeType;
fetchComments(changeRefreshState, ViewPostDetailFragment.this.sortType);
}
@Override
public void onFetchSubredditDataFail(boolean isQuarantined) {
mRespectSubredditRecommendedSortType = false;
SortType.Type sortTypeType = loadSortType();
activity.setTitle(sortTypeType.fullName);
ViewPostDetailFragment.this.sortType = sortTypeType;
}
});
} else {
fetchComments(changeRefreshState, sortType);
}
}
private void fetchComments(boolean changeRefreshState, SortType.Type sortType) { private void fetchComments(boolean changeRefreshState, SortType.Type sortType) {
isFetchingComments = true; isFetchingComments = true;
mCommentsAdapter.setSingleComment(mSingleCommentId, isSingleCommentThreadMode); mCommentsAdapter.setSingleComment(mSingleCommentId, isSingleCommentThreadMode);
@ -1559,7 +1511,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} }
private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState) { private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState) {
fetchCommentsRespectRecommendedSort(changeRefreshState, sortType); fetchComments(changeRefreshState, sortType);
} }
void fetchMoreComments() { void fetchMoreComments() {
@ -1783,7 +1735,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
isSingleCommentThreadMode = false; isSingleCommentThreadMode = false;
mSingleCommentId = null; mSingleCommentId = null;
mSingleCommentParentId = null; mSingleCommentParentId = null;
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
refresh(false, true); refresh(false, true);
} }

View File

@ -172,7 +172,6 @@ public class SharedPreferencesUtils {
public static final String DATA_SAVING_MODE_ONLY_ON_CELLULAR_DATA = "1"; public static final String DATA_SAVING_MODE_ONLY_ON_CELLULAR_DATA = "1";
public static final String DATA_SAVING_MODE_ALWAYS = "2"; public static final String DATA_SAVING_MODE_ALWAYS = "2";
public static final String NATIONAL_FLAGS = "national_flags"; public static final String NATIONAL_FLAGS = "national_flags";
public static final String RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE = "respect_subreddit_recommended_comment_sort_type";
public static final String UFO_CAPTURING_ANIMATION = "ufo_capturing_animation"; public static final String UFO_CAPTURING_ANIMATION = "ufo_capturing_animation";
public static final String HIDE_SUBREDDIT_DESCRIPTION = "hide_subreddit_description"; public static final String HIDE_SUBREDDIT_DESCRIPTION = "hide_subreddit_description";
public static final String DISABLE_IMAGE_PREVIEW = "disable_image_preview"; public static final String DISABLE_IMAGE_PREVIEW = "disable_image_preview";

View File

@ -38,10 +38,4 @@
app:title="@string/settings_user_default_sort_time_title" app:title="@string/settings_user_default_sort_time_title"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="respect_subreddit_recommended_comment_sort_type"
app:title="@string/settings_respect_community_recommended_comment_sort_type_title"
app:summary="@string/settings_respect_community_recommended_comment_sort_type_summary" />
</PreferenceScreen> </PreferenceScreen>