Skip to content

Fix - No Precise Error Message After Error Due to Password Change #5643

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix For Categories
  • Loading branch information
shashankiitbhu committed Mar 23, 2024
commit ae202e2e3f90b0a55d2681b90462a482e5f7910c
18 changes: 15 additions & 3 deletions app/src/main/java/fr/free/nrw/commons/actions/PageEditClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class PageEditClient(
pageEditInterface.postEdit(pageTitle, summary, text, csrfTokenClient.getTokenBlocking())
.map { editResponse -> editResponse.edit()!!.editSucceeded() }
} catch (throwable: Throwable) {
Observable.just(false)
if (throwable is InvalidLoginTokenException) {
throw throwable
} else {
Observable.just(false)
}
}
}

Expand All @@ -45,7 +49,11 @@ class PageEditClient(
pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.getTokenBlocking())
.map { editResponse -> editResponse.edit()!!.editSucceeded() }
} catch (throwable: Throwable) {
Observable.just(false)
if (throwable is InvalidLoginTokenException) {
throw throwable
} else {
Observable.just(false)
}
}
}

Expand Down Expand Up @@ -85,7 +93,11 @@ class PageEditClient(
value, csrfTokenClient.getTokenBlocking()
).map { it.success }
} catch (throwable: Throwable) {
Observable.just(0)
if (throwable is InvalidLoginTokenException) {
throw throwable
} else {
Observable.just(0)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ interface View {
* Refreshes the categories
*/
void refreshCategories();


/**
* Navigate the user to Login Activity
*/
void navigateToLoginScreen();
}

interface UserActionListener extends BasePresenter<View> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.R
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException
import fr.free.nrw.commons.category.CategoryEditHelper
import fr.free.nrw.commons.category.CategoryItem
import fr.free.nrw.commons.di.CommonsApplicationModule
Expand Down Expand Up @@ -223,12 +224,16 @@ class CategoriesPresenter @Inject constructor(
view.dismissProgressDialog()
view.refreshCategories()
view.goBackToPreviousScreen()
}, { error ->
if (error is InvalidLoginTokenException) {
view.navigateToLoginScreen();
} else {
Timber.e(
"Failed to update categories"
)
}
})
{
Timber.e(
"Failed to update categories"
)
}

)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import com.jakewharton.rxbinding2.view.RxView;
import com.jakewharton.rxbinding2.widget.RxTextView;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.category.CategoryItem;
import fr.free.nrw.commons.contributions.ContributionsFragment;
import fr.free.nrw.commons.databinding.UploadCategoriesFragmentBinding;
Expand All @@ -41,6 +43,8 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate

@Inject
CategoriesContract.UserActionListener presenter;
@Inject
SessionManager sessionManager;
private UploadCategoryAdapter adapter;
private Disposable subscribe;
/**
Expand Down Expand Up @@ -295,6 +299,22 @@ public void refreshCategories() {
mediaDetailFragment.updateCategories();
}

/**
*
*/
@Override
public void navigateToLoginScreen() {
final String username = sessionManager.getUserName();
final CommonsApplication.BaseLogoutListener logoutListener = new CommonsApplication.BaseLogoutListener(
getActivity(),
requireActivity().getString(R.string.invalid_login_message),
username
);

CommonsApplication.getInstance().clearApplicationData(
requireActivity(), logoutListener);
}

public void onNextButtonClicked() {
if (media != null) {
presenter.updateCategories(media, wikiText);
Expand Down