Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.texthip.thip.data.model.rooms.response

import kotlinx.serialization.Serializable

@Serializable
data class RoomsDeleteDailyGreetingResponse (
val roomId: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ class RoomsRepository @Inject constructor(
).handleBaseResponse().getOrThrow()
}

suspend fun deleteRoomsDailyGreeting(
roomId: Int,
attendanceCheckId: Int
) = runCatching {
roomsService.deleteRoomsDailyGreeting(
roomId = roomId,
attendanceCheckId = attendanceCheckId
).handleBaseResponse().getOrThrow()
}

suspend fun getRoomsRecordsPin(
roomId: Int,
recordId: Int
Expand All @@ -298,4 +308,12 @@ class RoomsRepository @Inject constructor(
recordId = recordId
).handleBaseResponse().getOrThrow()
}

suspend fun leaveRoom(
roomId: Int,
) = runCatching {
roomsService.leaveRoom(
roomId = roomId,
).handleBaseResponse().getOrThrow()
}
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/texthip/thip/data/service/RoomsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.texthip.thip.data.model.rooms.response.RoomsBookPageResponse
import com.texthip.thip.data.model.rooms.response.RoomsCreateDailyGreetingResponse
import com.texthip.thip.data.model.rooms.response.RoomsCreateVoteResponse
import com.texthip.thip.data.model.rooms.response.RoomsDailyGreetingResponse
import com.texthip.thip.data.model.rooms.response.RoomsDeleteDailyGreetingResponse
import com.texthip.thip.data.model.rooms.response.RoomsDeleteRecordResponse
import com.texthip.thip.data.model.rooms.response.RoomsDeleteVoteResponse
import com.texthip.thip.data.model.rooms.response.RoomsPlayingResponse
Expand Down Expand Up @@ -178,9 +179,20 @@ interface RoomsService {
@Body request: RoomsCreateDailyGreetingRequest
): BaseResponse<RoomsCreateDailyGreetingResponse>

@DELETE("rooms/{roomId}/daily-greeting/{attendanceCheckId}")
suspend fun deleteRoomsDailyGreeting(
@Path("roomId") roomId: Int,
@Path("attendanceCheckId") attendanceCheckId: Int
): BaseResponse<RoomsDeleteDailyGreetingResponse>

@GET("rooms/{roomId}/records/{recordId}/pin")
suspend fun getRoomsRecordsPin(
@Path("roomId") roomId: Int,
@Path("recordId") recordId: Int
): BaseResponse<RoomsRecordsPinResponse>

@DELETE("rooms/{roomId}/leave")
suspend fun leaveRoom(
@Path("roomId") roomId: Int
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -204,7 +203,6 @@ private fun FeedCommentContent(
var showDeleteDialog by remember { mutableStateOf(false) }
var showToast by remember { mutableStateOf(false) }
var toastMessage by remember { mutableStateOf("") }
val context = LocalContext.current

LaunchedEffect(showToast) {
if (showToast) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun GroupMySectionHeader(onClick: (() -> Unit)? = null) {
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.my_group),
text = stringResource(R.string.my_group_room),
style = typography.title_b700_s20_h24,
color = colors.White
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ fun GroupMyScreen(
) {
val uiState by viewModel.uiState.collectAsState()

LaunchedEffect(key1 = Unit) {
viewModel.refreshData()
}
Comment on lines +51 to +53
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

초기 로딩 중복 여부 확인

LaunchedEffect(Unit)에서 refreshData()를 호출하면 ViewModel init에서도 초기 로딩을 한다면 이중 호출이 됩니다. 한쪽으로 일원화하는지 확인해 주세요.

다음 스크립트로 중복 가능성을 점검할 수 있습니다:


🏁 Script executed:

#!/bin/bash
# GroupMyViewModel에서 init 블록이나 초기 데이터 로딩 여부 확인
rg -nP 'class\s+GroupMyViewModel\b' -A120 | rg -n 'init\s*\{|refreshData\s*\(' -n -C2

Length of output: 1093


초기 데이터 로딩 중복 제거
GroupMyViewModel의 init { loadMyRooms(reset = true) }와 GroupMyScreen의 LaunchedEffect(Unit)에서 호출하는 viewModel.refreshData()(loadMyRooms)가 중복됩니다. 한쪽 호출을 제거해 단일 진입점으로 통일해 주세요.

🤖 Prompt for AI Agents
In app/src/main/java/com/texthip/thip/ui/group/myroom/screen/GroupMyScreen.kt
around lines 51-53, the initial data load is duplicated: GroupMyViewModel
already calls loadMyRooms(reset = true) in its init block and GroupMyScreen
calls viewModel.refreshData() inside a LaunchedEffect(Unit); remove the
LaunchedEffect call in GroupMyScreen so the ViewModel's init remains the single
entry point for initial data loading, keeping UI code free of duplicate startup
logic and relying on the ViewModel to manage its own lifecycle-triggered load.


GroupMyContent(
uiState = uiState,
onCardClick = onCardClick,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.texthip.thip.ui.group.room.screen

import android.widget.Toast
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInVertically
Expand Down Expand Up @@ -28,6 +29,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.blur
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -60,21 +63,52 @@ fun GroupRoomChatScreen(
) {
var inputText by remember { mutableStateOf("") }
val uiState by viewModel.uiState.collectAsState()
val context = LocalContext.current

var activeToast by remember { mutableStateOf<ToastType?>(null) }
var showToast by remember { mutableStateOf(false) }
var toastMessage by remember { mutableStateOf("") }
val colorWhite = colors.White
val colorRed = colors.Red
var toastColor by remember { mutableStateOf(colorWhite) }

val dailyGreetingLimitMessage = stringResource(R.string.group_room_chat_max)
val deleteSuccessMessage = stringResource(R.string.group_room_chat_delete_success)

Comment on lines +74 to 76
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

FIRST_WRITE 토스트 메시지 매핑 오류

FIRST_WRITE가 현재 “하루 최대 작성 수 초과” 메시지로 표시됩니다. 첫 작성 축하/완료성 메시지로 분리해 주세요.

-    val dailyGreetingLimitMessage = stringResource(R.string.group_room_chat_max)
-    val deleteSuccessMessage = stringResource(R.string.group_room_chat_delete_success)
+    val dailyGreetingLimitMessage = stringResource(R.string.group_room_chat_max)
+    val firstWriteMessage = stringResource(R.string.group_room_chat_first_write)
+    val deleteSuccessMessage = stringResource(R.string.group_room_chat_delete_success)-                        ToastType.FIRST_WRITE -> {
-                            toastMessage = dailyGreetingLimitMessage
-                            toastColor = colorWhite
-                        }
+                        ToastType.FIRST_WRITE -> {
+                            toastMessage = firstWriteMessage
+                            toastColor = colorWhite
+                        }

화면 외부 변경(리소스 추가)도 필요합니다:

<!-- res/values/strings.xml -->
<string name="group_room_chat_first_write">첫 오늘의 한마디를 남겼어요!</string>

Also applies to: 81-96

🤖 Prompt for AI Agents
In
app/src/main/java/com/texthip/thip/ui/group/room/screen/GroupRoomChatScreen.kt
around lines 74-76 (and similarly lines 81-96), the FIRST_WRITE toast is
incorrectly mapped to the daily limit message; update the mapping so FIRST_WRITE
uses a new string resource R.string.group_room_chat_first_write (a celebratory
"first write" message) instead of group_room_chat_max, and add the corresponding
string entry to res/values/strings.xml with the provided text so the toast
displays the correct first-write message.

LaunchedEffect(key1 = Unit) {
viewModel.eventFlow.collectLatest { event ->
when (event) {
is GroupRoomChatEvent.ShowToast -> {
activeToast = event.type
when (event.type) {
ToastType.DAILY_GREETING_LIMIT -> {
toastMessage = dailyGreetingLimitMessage
toastColor = colorRed
}
ToastType.FIRST_WRITE -> {
toastMessage = dailyGreetingLimitMessage
toastColor = colorWhite
}
ToastType.DELETE_GREETING_SUCCESS -> {
toastMessage = deleteSuccessMessage
toastColor = colorWhite
}
}
showToast = true
}
is GroupRoomChatEvent.ShowErrorToast -> {
Toast.makeText(context, event.message, Toast.LENGTH_SHORT).show()
}

else -> Unit
}
}
}

LaunchedEffect(showToast) {
if (showToast) {
delay(3000)
showToast = false
}
}

GroupRoomChatContent(
uiState = uiState,
onEvent = viewModel::onEvent,
Expand All @@ -85,8 +119,9 @@ fun GroupRoomChatScreen(
inputText = ""
},
onNavigateBack = onBackClick,
activeToast = activeToast,
onDismissToast = { activeToast = null }
showToast = showToast,
toastMessage = toastMessage,
toastColor = toastColor
)
}

Expand All @@ -98,8 +133,9 @@ fun GroupRoomChatContent(
onInputTextChanged: (String) -> Unit,
onSendClick: () -> Unit,
onNavigateBack: () -> Unit,
activeToast: ToastType?,
onDismissToast: () -> Unit
showToast: Boolean,
toastMessage: String,
toastColor: Color,
) {
var isBottomSheetVisible by remember { mutableStateOf(false) }
var selectedMessage by remember { mutableStateOf<TodayCommentList?>(null) }
Expand Down Expand Up @@ -240,54 +276,25 @@ fun GroupRoomChatContent(
}

AnimatedVisibility(
visible = activeToast != null,
// visible 조건을 showToast로 변경
visible = showToast,
enter = slideInVertically(
initialOffsetY = { -it }, // 위에서 아래로
initialOffsetY = { -it },
animationSpec = tween(durationMillis = 2000)
),
exit = slideOutVertically(
targetOffsetY = { -it }, // 위로 사라짐
targetOffsetY = { -it },
animationSpec = tween(durationMillis = 2000)
),
modifier = Modifier
.align(Alignment.TopCenter)
.padding(horizontal = 20.dp, vertical = 16.dp)
.zIndex(3f)
) {
LaunchedEffect(activeToast) {
if (activeToast != null) {
delay(3000L)
onDismissToast()
}
}

AnimatedVisibility(
visible = activeToast != null,
enter = slideInVertically(
initialOffsetY = { -it },
animationSpec = tween(durationMillis = 2000)
),
exit = slideOutVertically(
targetOffsetY = { -it },
animationSpec = tween(durationMillis = 2000)
),
modifier = Modifier
.align(Alignment.TopCenter)
.padding(horizontal = 20.dp, vertical = 16.dp)
.zIndex(3f)
) {
when (activeToast) {
ToastType.DAILY_GREETING_LIMIT -> {
ToastWithDate(color = colors.Red)
}

ToastType.FIRST_WRITE -> {
ToastWithDate()
}

null -> {}
}
}
ToastWithDate(
message = toastMessage,
color = toastColor
)
}
}

Expand All @@ -298,7 +305,9 @@ fun GroupRoomChatContent(
text = stringResource(R.string.delete),
color = colors.Red,
onClick = {
// TODO: 삭제 처리
selectedMessage?.let { message ->
onEvent(GroupRoomChatEvent.DeleteGreeting(message.attendanceCheckId))
}
isBottomSheetVisible = false
}
)
Expand Down Expand Up @@ -352,8 +361,9 @@ private fun GroupRoomChatScreenPreview() {
onInputTextChanged = { newText -> inputText = newText },
onSendClick = {},
onNavigateBack = {},
activeToast = null,
onDismissToast = {}
showToast = false,
toastMessage = "",
toastColor = colors.White
)
}
}
Loading