Skip to content

Commit

Permalink
Merge pull request #104 from Nexters/fix/login
Browse files Browse the repository at this point in the history
[FIX] 로그인 관련 예외 처리 추가
  • Loading branch information
easyhooon authored Mar 5, 2024
2 parents 3cd513a + 5ebe472 commit 711d869
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
9 changes: 9 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@
# R8 full mode strips generic signatures from return types if not kept.
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ internal object ApplicationConfig {
const val MinSdk = 26
const val TargetSdk = 34
const val CompileSdk = 34
const val VersionCode = 1
const val VersionName = "1.0.0"
const val VersionCode = 3
const val VersionName = "1.0.2"
val JavaVersion = org.gradle.api.JavaVersion.VERSION_17
const val JavaVersionAsInt = 17
}
25 changes: 25 additions & 0 deletions feature/intro/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# https://stackoverflow.com/questions/70037537/proguard-missing-classes-detected-while-running-r8-after-adding-package-names-in
-dontwarn java.lang.invoke.StringConcatFactory

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ internal fun IntroRoute(
}
} else {
Timber.d("accessToken 이 유효함")
Timber.d("id: ${tokeninfo?.id}, expiresIn: ${tokeninfo?.expiresIn}, appId: ${tokeninfo?.appId}")
viewModel.autoLoginSuccess()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.viewmodel.container
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
Expand All @@ -24,7 +25,16 @@ class IntroViewModel @Inject constructor(
}

private fun validateToken() = intent {
postSideEffect(IntroSideEffect.ValidateToken)
delay(1000)
viewModelScope.launch {
val accessToken = repository.getAccessToken()
if (accessToken.isNotEmpty()) {
Timber.d("accessToken: $accessToken")
postSideEffect(IntroSideEffect.ValidateToken)
} else {
postSideEffect(IntroSideEffect.AutoLoginFail)
}
}
}

fun autoLoginFail() = intent {
Expand All @@ -37,16 +47,4 @@ class IntroViewModel @Inject constructor(
fun autoLoginSuccess() = intent {
postSideEffect(IntroSideEffect.AutoLoginSuccess)
}

private fun getAccessToken() = intent {
viewModelScope.launch {
delay(1000)
val accessToken = repository.getAccessToken()
if (accessToken.isNotEmpty()) {
postSideEffect(IntroSideEffect.AutoLoginSuccess)
} else {
postSideEffect(IntroSideEffect.AutoLoginFail)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
import org.orbitmvi.orbit.viewmodel.container
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
Expand Down Expand Up @@ -77,12 +76,6 @@ class MyPageViewModel @Inject constructor(
}
}

private fun setSelectedMyAlbum(index: Int) = intent {
reduce {
state.copy(selectedMyAlbum = index)
}
}

fun shareMyAlbum() = intent {
viewModelScope.launch {
reduce {
Expand All @@ -105,16 +98,13 @@ class MyPageViewModel @Inject constructor(
}

fun onAlbumClick(index: Int) = intent {
Timber.d("before: state.selectedMyAlbum: ${state.selectedMyAlbum}")
setSelectedMyAlbum(index)
Timber.d("selectedIndex: $index")
Timber.d("state.selectedMyAlbum: ${state.selectedMyAlbum}")
Timber.d("MyAlbumImageUrlList: ${state.myAlbumFullImageList[state.selectedMyAlbum].images.map { it.imageUrl }}")
Timber.d("StyleName: ${state.myAlbumFullImageList[state.selectedMyAlbum].images.map { it.imageStyle.name }.first()}")
reduce {
state.copy(selectedMyAlbum = index)
}
postSideEffect(
MyPageSideEffect.NavigateToMyAlbum(
state.myAlbumFullImageList[index].images.map { it.imageUrl },
state.myAlbumFullImageList[index].images.map { it.imageStyle.name }.first(),
state.myAlbumFullImageList[state.selectedMyAlbum].images.map { it.imageUrl },
state.myAlbumFullImageList[state.selectedMyAlbum].images.map { it.imageStyle.name }.first(),
),
)
}
Expand Down

0 comments on commit 711d869

Please sign in to comment.