Skip to content

Commit f904bed

Browse files
committed
fix: Account set flow with "refershOnSuccess" optional + AboutMe.kt loading banner
1 parent 71f3a54 commit f904bed

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

.github/workflows/bits&bytes_develop_tfa_push_debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
5555
upsert_string app/src/main/res/values/strings.xml "asset_statements" '${{ secrets.BITS_N_BYTES_ASSET_STATEMENTS }}'
5656
upsert_string app/src/variant/res/values/strings.xml "asset_statements" '${{ secrets.BITS_N_BYTES_ASSET_STATEMENTS }}'
57-
57+
5858
- name: Add Google required resources to strings.xml resource (actual value for demo only)
5959
run: |
6060
sed -i '/<\/resources>/i \ <string name="google_server_client_id">${{ secrets.GOOGLE_WEB_SERVER_CLIENT_ID }}</string>' app/src/main/res/values/strings.xml

app/src/main/java/com/sap/cdc/bitsnbytes/feature/auth/AuthenticationFlowDelegate.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ class AuthenticationFlowDelegate(context: Context) {
178178
parameters: MutableMap<String, String> = mutableMapOf(),
179179
authCallbacks: AuthCallbacks.() -> Unit
180180
) {
181-
authenticationService.account().set(parameters) {
181+
authenticationService.account().set(
182+
parameters = parameters,
183+
refreshOnSuccess = true
184+
) {
182185
// Register original callbacks first
183186
authCallbacks()
184187

app/src/main/java/com/sap/cdc/bitsnbytes/ui/view/screens/AboutMe.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import androidx.compose.ui.unit.dp
3434
import androidx.compose.ui.unit.sp
3535
import com.sap.cdc.bitsnbytes.apptheme.AppTheme
3636
import com.sap.cdc.bitsnbytes.ui.view.composables.ActionOutlineInverseButton
37-
import com.sap.cdc.bitsnbytes.ui.view.composables.IndeterminateLinearIndicator
37+
import com.sap.cdc.bitsnbytes.ui.view.composables.LoadingStateColumn
3838
import com.sap.cdc.bitsnbytes.ui.view.composables.SimpleErrorMessages
3939
import com.sap.cdc.bitsnbytes.ui.view.composables.SuccessBanner
4040
import com.sap.cdc.bitsnbytes.ui.viewmodel.AccountViewModelPreview
@@ -71,11 +71,12 @@ fun AboutMeView(viewModel: IAccountViewModel) {
7171
)
7272
}
7373

74-
Column(
74+
LoadingStateColumn(
7575
modifier = Modifier
7676
.background(Color(0xFFF5F5F5))
7777
.fillMaxWidth()
7878
.fillMaxHeight(),
79+
loading = loading
7980
) {
8081
// About me section header with gray background
8182
Box(
@@ -166,7 +167,6 @@ fun AboutMeView(viewModel: IAccountViewModel) {
166167
}
167168
}
168169

169-
Spacer(modifier = Modifier.weight(1f))
170170

171171
// Error message
172172
if (setError.isNotEmpty()) {
@@ -207,17 +207,6 @@ fun AboutMeView(viewModel: IAccountViewModel) {
207207
)
208208
}
209209

210-
// Loading indicator
211-
if (loading) {
212-
Box(
213-
modifier = Modifier
214-
.fillMaxWidth()
215-
.padding(top = 16.dp)
216-
) {
217-
IndeterminateLinearIndicator(loading)
218-
}
219-
}
220-
221210
// Auto-hide after 2 seconds
222211
if (showBanner) {
223212
LaunchedEffect(Unit) {

library/src/main/java/com/sap/cdc/android/sdk/feature/auth/flow/account/AuthAccountFlow.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class AuthAccountFlow(coreClient: CoreClient, sessionService: SessionService) :
5757
*/
5858
suspend fun setAccountInfo(
5959
parameters: MutableMap<String, String>? = mutableMapOf(),
60+
refreshOnSuccess: Boolean = false,
6061
callbacks: AuthCallbacks,
6162
) {
6263
CDCDebuggable.log(
@@ -78,8 +79,15 @@ class AuthAccountFlow(coreClient: CoreClient, sessionService: SessionService) :
7879
}
7980

8081
// Success case
81-
val authSuccess = createAuthSuccess(request)
82-
callbacks.onSuccess?.invoke(authSuccess)
82+
if (!refreshOnSuccess) {
83+
// If not refreshing, return the current response
84+
val authSuccess = createAuthSuccess(request)
85+
callbacks.onSuccess?.invoke(authSuccess)
86+
return
87+
}
88+
89+
// Perform a getAccountInfo to refresh the data
90+
getAccountInfo(mutableMapOf(), callbacks)
8391
}
8492

8593
/**

library/src/main/java/com/sap/cdc/android/sdk/feature/auth/flow/account/IAuthAccount.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ interface IAuthAccount {
1313

1414
suspend fun set(
1515
parameters: MutableMap<String, String>,
16-
configure: AuthCallbacks.() -> Unit
16+
refreshOnSuccess: Boolean = false,
17+
configure: AuthCallbacks.() -> Unit,
1718
)
1819

1920
suspend fun authCode(
@@ -37,10 +38,12 @@ internal class AuthAccount(
3738

3839
override suspend fun set(
3940
parameters: MutableMap<String, String>,
40-
configure: AuthCallbacks.() -> Unit
41+
refreshOnSuccess: Boolean,
42+
configure: AuthCallbacks.() -> Unit,
4143
) {
4244
val callbacks = AuthCallbacks().apply(configure)
43-
AuthAccountFlow(coreClient, sessionService).setAccountInfo(parameters, callbacks)
45+
AuthAccountFlow(coreClient, sessionService).setAccountInfo(
46+
parameters = parameters, refreshOnSuccess = refreshOnSuccess, callbacks = callbacks)
4447
}
4548

4649
override suspend fun authCode(

0 commit comments

Comments
 (0)