mirror of
https://github.com/VernissageApp/Vernissage.git
synced 2024-12-28 18:00:53 +01:00
Comments list improvements
This commit is contained in:
parent
08ce50573e
commit
94ae24d8f3
@ -44,18 +44,21 @@ public class TimelineService {
|
|||||||
var commentViewModels: [CommentViewModel] = []
|
var commentViewModels: [CommentViewModel] = []
|
||||||
|
|
||||||
let client = MastodonClient(baseURL: accountData.serverUrl).getAuthenticated(token: accountData.accessToken ?? String.empty())
|
let client = MastodonClient(baseURL: accountData.serverUrl).getAuthenticated(token: accountData.accessToken ?? String.empty())
|
||||||
try await self.getCommentDescendants(for: statusId, client: client, to: &commentViewModels)
|
try await self.getCommentDescendants(for: statusId, client: client, showDivider: true, to: &commentViewModels)
|
||||||
|
|
||||||
return commentViewModels
|
return commentViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getCommentDescendants(for statusId: String, client: MastodonClientAuthenticated, to commentViewModels: inout [CommentViewModel]) async throws {
|
private func getCommentDescendants(for statusId: String, client: MastodonClientAuthenticated, showDivider: Bool, to commentViewModels: inout [CommentViewModel]) async throws {
|
||||||
let context = try await client.getContext(for: statusId)
|
let context = try await client.getContext(for: statusId)
|
||||||
|
|
||||||
let descendants = context.descendants.toStatusViewModel()
|
let descendants = context.descendants.toStatusViewModel()
|
||||||
for status in descendants {
|
for status in descendants {
|
||||||
commentViewModels.append(CommentViewModel(status: status, showDivider: false))
|
commentViewModels.append(CommentViewModel(status: status, showDivider: showDivider))
|
||||||
try await self.getCommentDescendants(for: status.id, client: client, to: &commentViewModels)
|
|
||||||
|
if status.repliesCount > 0 {
|
||||||
|
try await self.getCommentDescendants(for: status.id, client: client, showDivider: false, to: &commentViewModels)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user