Skip to content
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

[feat] 0.0.4 버전 배포 #297

Merged
merged 5 commits into from
Dec 5, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ local.properties
.idea/
.kotlin/
*.keystore
*.jks
/app/release
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">dreamdiary</string>
<string name="app_name">DreamDiary</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
minSdk = 24
targetSdk = 35

versionCode = 2
versionName = "0.0.2"
versionCode = 4
versionName = "0.0.4"
}

configureKotlinAndroid(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class CommentRepository @Inject constructor(
postId: String,
commentId: String,
) {
val postRef = firebaseFirestore.collection("community").document(postId)
postRef.update("commentCount", FieldValue.increment(-1)).await()
firebaseFirestore.collection("community")
.document(postId).collection("comments").document(commentId).delete().await()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
Expand Down Expand Up @@ -236,14 +235,6 @@ private fun CommunityListScreenContent(
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
val bottomAppBarScrollBehavior = BottomAppBarDefaults.exitAlwaysScrollBehavior()

val listState = rememberLazyListState()
var previousRefreshState by remember { mutableStateOf(posts.loadState.refresh) }
LaunchedEffect(posts.loadState.refresh) {
if (previousRefreshState is LoadState.Loading && posts.loadState.refresh is LoadState.NotLoading) {
listState.animateScrollToItem(0)
}
previousRefreshState = posts.loadState.refresh
}
Scaffold(
modifier = modifier
.fillMaxSize()
Expand Down Expand Up @@ -272,7 +263,6 @@ private fun CommunityListScreenContent(
) { innerPadding ->
PostList(
posts = posts,
listState = listState,
onPostClick = onPostClick,
onPostLikeClick = onPostLikeClick,
modifier = Modifier
Expand All @@ -286,17 +276,31 @@ private fun CommunityListScreenContent(
@OptIn(ExperimentalMaterial3Api::class)
private fun PostList(
posts: LazyPagingItems<PostUi>,
listState: LazyListState,
onPostClick: (PostUi) -> Unit,
onPostLikeClick: (PostUi) -> Unit,
modifier: Modifier = Modifier,
) {
val isRefreshing by remember { derivedStateOf { posts.loadState.refresh is LoadState.Loading } }
val isInitialLoading by remember { derivedStateOf { isRefreshing && posts.itemCount <= 1 } }
val listState = rememberLazyListState()

var wasRefreshing by remember { mutableStateOf(false) }
var shouldScrollToTop by remember { mutableStateOf(false) }

LaunchedEffect(posts.loadState.refresh) {
if (wasRefreshing && !isRefreshing && shouldScrollToTop) {
listState.animateScrollToItem(0)
shouldScrollToTop = false
}
wasRefreshing = isRefreshing
}

PullToRefreshBox(
isRefreshing = !isInitialLoading && isRefreshing,
onRefresh = posts::refresh,
onRefresh = {
shouldScrollToTop = true
posts.refresh()
},
modifier = modifier,
) {
LazyColumn(
Expand Down
Loading