Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5afd3a99 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

issue_5413_2 [WIP]: Rename retryFetchingTokenAfterTimeout() to...

issue_5413_2 [WIP]: Rename retryFetchingTokenAfterTimeout() to checkTokenOnTimeout() which checks token validity and does not outright request for regeneration.
parent 89806eac
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -121,18 +121,31 @@ class MainActivityViewModel @Inject constructor(
        return (SystemClock.uptimeMillis() - firstAuthDataFetchTime) <= timeoutDurationInMillis
    }

    /*
    /**
     * This method resets the last recorded token fetch time.
     * Then it posts authValidity as false. This causes the observer in MainActivity to destroyCredentials
     * and fetch new token.
     *
     * Then if [authData] is not null, it checks the validity of it,
     * which automatically updates [authValidity].
     * If [authValidity] is true, the observer in MainActivity calls [generateAuthData],
     * which passes the same [authData] to the current displaying fragment once more,
     * to trigger data refresh.
     *
     * If [authData] is null, it posts false in [authValidity], which
     * causes the observer in MainActivity to destroyCredentials and fetch new token.
     * This again causes the current displaying fragment to re-trigger data refresh.
     *
     * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5404
     * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5413 [2]
     */
    fun retryFetchingTokenAfterTimeout() {
    fun checkTokenOnTimeout() {
        firstAuthDataFetchTime = 0
        setFirstTokenFetchTime()
        if (authData.value != null) {
            validateAuthData()
        } else {
            authValidity.postValue(false)
        }
    }

    fun uploadFaultyTokenToEcloud(description: String) {
        viewModelScope.launch {
+1 −1
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) {
                positiveButtonBlock = {
                    showLoadingUI()
                    resetTimeoutDialogLock()
                    mainActivityViewModel.retryFetchingTokenAfterTimeout()
                    mainActivityViewModel.checkTokenOnTimeout()
                },
                negativeButtonText = getString(android.R.string.ok),
                negativeButtonBlock = {
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ class ApplicationListFragment : TimeoutFragment(R.layout.fragment_application_li
                positiveButtonBlock = {
                    showLoadingUI()
                    resetTimeoutDialogLock()
                    mainActivityViewModel.retryFetchingTokenAfterTimeout()
                    mainActivityViewModel.checkTokenOnTimeout()
                },
                negativeButtonText = getString(android.R.string.ok),
                negativeButtonBlock = {},
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ class AppsFragment : TimeoutFragment(R.layout.fragment_apps) {
                negativeButtonBlock = {
                    showLoadingUI()
                    resetTimeoutDialogLock()
                    mainActivityViewModel.retryFetchingTokenAfterTimeout()
                    mainActivityViewModel.checkTokenOnTimeout()
                },
                allowCancel = true,
            )
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class GamesFragment : TimeoutFragment(R.layout.fragment_games) {
                negativeButtonBlock = {
                    showLoadingUI()
                    resetTimeoutDialogLock()
                    mainActivityViewModel.retryFetchingTokenAfterTimeout()
                    mainActivityViewModel.checkTokenOnTimeout()
                },
                allowCancel = true,
            )
Loading