mirror of
https://github.com/yattee/yattee.git
synced 2025-04-28 07:50:33 +05:30
Remove redundant query for replies when collapsed and expanded
This commit is contained in:
parent
1b090fcd51
commit
a44a61b017
@ -12,6 +12,7 @@ final class CommentsModel: ObservableObject {
|
|||||||
@Published var disabled = false
|
@Published var disabled = false
|
||||||
|
|
||||||
@Published var replies = [Comment]()
|
@Published var replies = [Comment]()
|
||||||
|
@Published var repliesPageID: String?
|
||||||
@Published var repliesLoaded = false
|
@Published var repliesLoaded = false
|
||||||
|
|
||||||
var accounts: AccountsModel!
|
var accounts: AccountsModel!
|
||||||
@ -77,7 +78,12 @@ final class CommentsModel: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if page == repliesPageID {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
replies = []
|
replies = []
|
||||||
|
repliesPageID = page
|
||||||
repliesLoaded = false
|
repliesLoaded = false
|
||||||
|
|
||||||
api?.comments(player.currentVideo!.videoID, page: page)?
|
api?.comments(player.currentVideo!.videoID, page: page)?
|
||||||
|
@ -144,10 +144,6 @@ struct CommentView: View {
|
|||||||
Button {
|
Button {
|
||||||
repliesID = repliesID == comment.id ? nil : comment.id
|
repliesID = repliesID == comment.id ? nil : comment.id
|
||||||
|
|
||||||
if repliesID.isNil {
|
|
||||||
comments.replies = []
|
|
||||||
}
|
|
||||||
|
|
||||||
guard !repliesID.isNil, !comment.repliesPage.isNil else {
|
guard !repliesID.isNil, !comment.repliesPage.isNil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user