Skip to content

Commit

Permalink
[AN/USER] 티켓 제시 화면 2개 버그 해결 (#519) (#520)
Browse files Browse the repository at this point in the history
* fix: 입장처리가 단 한번만 반영되도록 변경

* fix: 리프레시에 타이머가 제대로 돌지 않는 상황 처리
  • Loading branch information
re4rk authored and BGuga committed Oct 17, 2023
1 parent df1ff0f commit fbee6f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TicketEntryService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
runBlocking {
// TODO: 입장완료 로직인지 확인하는 로직 추가 필요
ticketStateChangeEvent.emit(true)
ticketStateChangeEvent.emit(Unit)
}
}

Expand All @@ -18,6 +18,6 @@ class TicketEntryService : FirebaseMessagingService() {
}

companion object {
val ticketStateChangeEvent: MutableSharedFlow<Boolean> = MutableSharedFlow()
val ticketStateChangeEvent: MutableSharedFlow<Unit> = MutableSharedFlow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.google.zxing.BarcodeFormat
import com.journeyapps.barcodescanner.BarcodeEncoder
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.first

@AndroidEntryPoint
class TicketEntryActivity : AppCompatActivity() {
Expand Down Expand Up @@ -65,13 +66,11 @@ class TicketEntryActivity : AppCompatActivity() {
}
}
repeatOnStarted(this) {
TicketEntryService.ticketStateChangeEvent.collect { event ->
if (event) {
// TODO 티켓 스캔 화면 처리
Toast.makeText(this, "티켓이 스캔되었습니다.", Toast.LENGTH_SHORT).show()
setResult(RESULT_OK, intent)
finish()
}
TicketEntryService.ticketStateChangeEvent.first {
Toast.makeText(this, "티켓이 스캔되었습니다.", Toast.LENGTH_SHORT).show()
setResult(RESULT_OK, intent)
finish()
true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ class TicketEntryViewModel @Inject constructor(
}
}

private suspend fun setTimer(ticketId: Long, ticketCode: TicketCode) {
timer.timerListener = createTimerListener(ticketId)
timer.start(ticketCode.period)
private fun setTimer(ticketId: Long, ticketCode: TicketCode) {
viewModelScope.launch {
timer.timerListener = createTimerListener(ticketId)
timer.start(ticketCode.period)
}
}

private fun createTimerListener(ticketId: Long): TimerListener = object : TimerListener {
Expand Down

0 comments on commit fbee6f3

Please sign in to comment.