-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT/#396] 푸시알림 상태 변경 / 서버통신 구현 #398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
278ca75
b9d7155
df03763
7bfd4c5
0e09c28
fce4cfb
e95fb65
ea565ff
f641f5a
5eb3c08
0310185
3332ac3
defb28c
97c5c7a
c134828
8a86ca7
ab37251
d6d9275
fa9dde3
8bfb7aa
a42ed2a
93e4e37
b81f23f
05886e7
da0c921
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.terning.core.designsystem.extension | ||
|
|
||
| import kotlinx.coroutines.channels.Channel | ||
| import kotlinx.coroutines.channels.SendChannel | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.consumeAsFlow | ||
| import kotlinx.coroutines.flow.flow | ||
|
|
||
| fun <T, K> Flow<T>.groupBy(getKey: (T) -> K): Flow<Pair<K, Flow<T>>> = flow { | ||
| val storage = mutableMapOf<K, SendChannel<T>>() | ||
| try { | ||
| collect { t -> | ||
| val key = getKey(t) | ||
| val channel = storage.getOrPut(key) { | ||
| Channel<T>(capacity = Channel.BUFFERED).also { | ||
| emit(key to it.consumeAsFlow()) | ||
| } | ||
| } | ||
| channel.send(t) | ||
| } | ||
| } finally { | ||
| storage.values.forEach { it.close() } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.terning.core.designsystem.type | ||
|
|
||
| enum class AlarmType(val value: String) { | ||
| ENABLED("ENABLED"), | ||
| DISABLED("DISABLED") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.terning.data.mypage.dto.request | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class AlarmStatusRequestDto( | ||
| @SerialName("newStatus") | ||
| val newStatus: String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.terning.data.mypage.mapper | ||
|
|
||
| import com.terning.data.mypage.dto.request.AlarmStatusRequestDto | ||
| import com.terning.domain.mypage.entity.AlarmStatus | ||
|
|
||
| fun AlarmStatus.toAlarmStatusRequestDto(): AlarmStatusRequestDto = | ||
| AlarmStatusRequestDto( | ||
| newStatus = newStatus | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.terning.domain.mypage.entity | ||
|
|
||
| data class AlarmStatus( | ||
| val newStatus: String | ||
| ) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,8 +94,12 @@ fun MyPageRoute( | |||||||||||||||
| rememberPermissionState(permission = notificationPermission) | ||||||||||||||||
| var isChecked by remember { | ||||||||||||||||
| mutableStateOf( | ||||||||||||||||
| if (!permissionState.status.isGranted) false | ||||||||||||||||
| else viewModel.getAlarmAvailability() | ||||||||||||||||
| if (!permissionState.status.isGranted) { | ||||||||||||||||
| viewModel.updateAlarmAvailability(false) | ||||||||||||||||
| false | ||||||||||||||||
| } else { | ||||||||||||||||
| viewModel.getAlarmAvailability() | ||||||||||||||||
| } | ||||||||||||||||
| ) | ||||||||||||||||
| } | ||||||||||||||||
| val notificationSettingsLauncher = | ||||||||||||||||
|
|
@@ -106,17 +110,15 @@ fun MyPageRoute( | |||||||||||||||
| viewModel.updateAlarmAvailability(isGranted) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| LaunchedEffect(Unit) { | ||||||||||||||||
| DisposableEffect(lifecycleOwner) { | ||||||||||||||||
| systemUiController.setStatusBarColor(color = Back) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| DisposableEffect(lifecycleOwner) { | ||||||||||||||||
| onDispose { | ||||||||||||||||
| systemUiController.setStatusBarColor(color = White) | ||||||||||||||||
| } | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 113부터 119가 예전 코드라 태그가 안되네요;;
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 혹시 어떻게 합친다는 의미인지 여쭤봐도 될까용...??
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아! 코드를 제시해주셨군요!! 😅😅 반영해놓겠습니다~ 공부해올게요. |
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| LaunchedEffect(key1 = true) { | ||||||||||||||||
| LaunchedEffect(Unit) { | ||||||||||||||||
| viewModel.getProfile() | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 변수는 상태 객체 자체가 바뀌지 않고, 내부 값만 변경되는 구조라서 val로 선언해도 괜찮을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말씀해주신 부분 보고 저도 생각을 해 보았는데요..!
사실 저는
by를 써주면isChecked변수를 사용할 때.value를 같이 사용하지 않아도 돼서 가독성이 좋아진다고 생각했었어요..!그런데 이렇게
by를 써주게 되면 get/set에 대한 위임이 이루어지면서 값이 바뀔 수 있는 var로 사용되어야 하더라구요val로 선언하고
.value를 같이 사용해주는 것이 좋을까요?다른 분들의 의견도 궁금하네요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var의 경우 상태 객체 자체를 바꿀 수 있어서 조금의 실수라도 방지하기 위해 val을 사용하는게 좋다고 생각했습니다!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 by에 한표 드립니당!! 가독성이 더 좋아지고 더 직관적인 것 같아서요!! 그리고 by 사용하면 var이어도 상태 객체 자체를 바꾸지는 못할걸요.....?(아마도... 그치만 아닐 수 있음 주의)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
조금 더 찾아보니까 by를 사용하면 상태 값 자체에 접근할 수 있고 효빈이 말처럼 객체 자체를 바꾸진 못한다고 하네요!
이 상황에선 간결성을 위해
var을 유지하는게 맞는 것 같아요!덕분에 하나 배워갑니다~