fix
This commit is contained in:
parent
f1790156f9
commit
d297e50575
@ -73,7 +73,6 @@ struct IndexMainView: View {
|
||||
}
|
||||
|
||||
ProgressView()
|
||||
.id(UUID())
|
||||
.background(GeometryReader { geometry in
|
||||
let minY = geometry.frame(in: .global).minY
|
||||
Color.clear.preference(key: FooterOffsetPreferenceKey.self, value: Int(minY))
|
||||
@ -142,12 +141,7 @@ struct IndexMainView: View {
|
||||
await self.indexModel.loadData(userId: self.userId)
|
||||
}
|
||||
.onPreferenceChange(DramaGroupElementPreferenceKey.self) { frames in
|
||||
let visibleFrames = frames.filter { $0.value >= 0}
|
||||
if let minFrame = visibleFrames.min(by: { $0.value <= $1.value}) {
|
||||
DispatchQueue.main.async {
|
||||
indexModel.setFixedDrameGroup(groupId: minFrame.key)
|
||||
}
|
||||
}
|
||||
indexModel.visiblePublisher.send(frames)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -78,6 +78,9 @@ final class IndexModel {
|
||||
@ObservationIgnored
|
||||
var loadMorePublisher = PassthroughSubject<(String, Int), Never>()
|
||||
|
||||
@ObservationIgnored
|
||||
var visiblePublisher = PassthroughSubject<[String: CGFloat], Never>()
|
||||
|
||||
@ObservationIgnored
|
||||
private var bag = Set<AnyCancellable>()
|
||||
|
||||
@ -101,6 +104,19 @@ final class IndexModel {
|
||||
}
|
||||
}
|
||||
.store(in: &bag)
|
||||
|
||||
self.visiblePublisher
|
||||
.debounce(for: 0.05, scheduler: RunLoop.main)
|
||||
.dropFirst()
|
||||
.sink { frames in
|
||||
let visibleFrames = frames.filter { $0.value >= 0}
|
||||
if let minFrame = visibleFrames.min(by: { $0.value <= $1.value}) {
|
||||
DispatchQueue.main.async {
|
||||
self.setFixedDrameGroup(groupId: minFrame.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &bag)
|
||||
}
|
||||
|
||||
func loadData(userId: String) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user