-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/#30] 게시물 상세페이지 API #31
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...src/main/java/com/hsLink/hslink/data/dto/response/community/CommunityDetailResponseDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.hsLink.hslink.data.dto.response.community | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class CommunityDetailResponseDto( | ||
| @SerialName("id") | ||
| val id: Int, | ||
| @SerialName("author") | ||
| val author: String, | ||
| @SerialName("studentId") | ||
| val studentId: String, | ||
| @SerialName("authorStatus") | ||
| val authorStatus: String, | ||
| @SerialName("title") | ||
| val title: String, | ||
| @SerialName("body") | ||
| val body: String, | ||
| @SerialName("mine") | ||
| val mine: Boolean, | ||
| @SerialName("comments") | ||
| val comments: List<CommentDto>, | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class CommentDto( | ||
| @SerialName("id") | ||
| val id: Int, | ||
| @SerialName("commenter") | ||
| val commenter: String, | ||
| @SerialName("commenterStatus") | ||
| val commenterStatus: String, | ||
| @SerialName("content") | ||
| val content: String, | ||
| @SerialName("mine") | ||
| val mine: Boolean, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
Verify error handling for invalid postId fallback.
The code extracts
postIdfrombackStackEntry.argumentswith a fallback value of-1(Line 25). If the navigation arguments are missing or malformed,-1will be passed toCommunityPostRoute. Ensure that downstream code (particularly the API call and UI) properly handles this invalid ID case, or consider throwing an error/navigating back if the postId is missing.Run the following script to check how -1 (or invalid postId) is handled in the detail flow:
🏁 Script executed:
Length of output: 6512
Let me verify how the invalid postId is handled in the UI and whether there are guards in place:
Now let me check the CommunityPostScreen to see if there's any UI handling for invalid postId:
Let me search for the actual CommunityPostScreen implementation to see the full picture:
Based on the script output and web research, I can now make a definitive assessment. The review comment raises a valid concern about error handling for invalid postId values. Let me verify the complete error handling flow by examining how the error state is handled in the screen:
Analysis Summary:
From the script execution results, I found:
-1repository.getCommunityDetail(postId)with.onFailureerror handlerrunCatchingfor exception handlingviewModel.getPostDetail(postId)inLaunchedEffect(postId)Current State: Error handling exists downstream (ViewModel's
.onFailurehandler), but there is no early validation for the invalid-1postId before making the API call. Kotlin best practices recommend throwing exceptions for logic errors with conditions like invalid IDs, and Jetpack Compose documentation notes that providing default values and covering edge cases makes code safer.Issues identified:
-1(wasteful network request for known invalid ID)LaunchedEffectconditionRecommendation: Add validation for
postId != -1before callingviewModel.getPostDetail()to prevent unnecessary API calls and provide faster user feedback.Add postId validation in CommunityPostScreen before API call.
Include a guard condition in
LaunchedEffectto check if postId is valid (-1 indicates missing argument), and navigate back or show error immediately without making an unnecessary API request:This prevents wasteful API calls and provides faster error feedback when navigation arguments are missing.
🤖 Prompt for AI Agents