Skip to content

Commit

Permalink
feat: refresh 될때 밈리스트 업데이트 안되는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hryeong66 committed Aug 6, 2024
1 parent b84619a commit f7f37b4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Projects/Core/DesignSystem/Sources/View/Meme/MemeListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import PPACModels

public struct MemeListView: View {
@Binding var memeDetailList: [MemeDetail]
private let columns = Array(
repeating: GridItem(
.flexible(),
spacing: 12,
alignment: .center
), count: 2
)
private let memeClickHandler: ((MemeDetail) -> ())?
private let memeCopyHandler: ((MemeDetail) -> ())?
private let onAppearLastMemeHandler: (() -> ())?
Expand Down Expand Up @@ -82,10 +75,13 @@ public struct MemeListView: View {
}
}
}
// FIXME: pull to refresh 했을 때 onAppear가 호출되지 않아서 onChange로 임시 호출, 수정필요
// .onChange(of: memeDetailList) {
// onAppearLastMemeHandler?()
// }
.onChange(of: memeDetailList, initial: false) { oldList, newList in
// refresh되면서 newList가 oldList보다 작아진 순간에만 호출되도록
guard newList.count < oldList.count else { return }
if newList.contains(where: { $0.id == lastMemeId }) {
onAppearLastMemeHandler?()
}
}
.frame(maxWidth: .infinity)
}
.scrollTargetBehavior(.viewAligned)
Expand Down

0 comments on commit f7f37b4

Please sign in to comment.