Skip to content

Commit

Permalink
feat: Add AccountUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Oct 18, 2024
1 parent 9713b5b commit be2f867
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.infomaniak.swisstransfer.ui
import android.app.Application
import com.infomaniak.multiplatform_swisstransfer.SwissTransferInjection
import com.infomaniak.swisstransfer.BuildConfig
import com.infomaniak.swisstransfer.ui.utils.AccountUtils
import dagger.hilt.android.HiltAndroidApp
import io.sentry.SentryEvent
import io.sentry.SentryOptions
Expand All @@ -40,7 +41,8 @@ class MainApplication : Application() {

override fun onCreate() {
super.onCreate()
globalCoroutineScope.launch { swissTransferInjection.accountManager.loadUser(userId = 0) }

configureAccountUtils()

SentryAndroid.init(this) { options: SentryAndroidOptions ->
// Register the callback as an option
Expand All @@ -50,4 +52,8 @@ class MainApplication : Application() {
}
}
}

private fun configureAccountUtils() {
globalCoroutineScope.launch { AccountUtils.init(swissTransferInjection) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.swisstransfer.ui.utils

import com.infomaniak.multiplatform_swisstransfer.SwissTransferInjection

object AccountUtils {

private const val DEFAULT_USER_ID = 0

suspend fun init(swissTransferInjection: SwissTransferInjection) {
swissTransferInjection.accountManager.loadUser(userId = DEFAULT_USER_ID)
}
}

0 comments on commit be2f867

Please sign in to comment.