mirror of
https://github.com/VernissageApp/Vernissage.git
synced 2024-12-28 18:00:53 +01:00
Refactor
This commit is contained in:
parent
5fbaacd365
commit
08ce50573e
@ -43,16 +43,8 @@ public class TimelineService {
|
|||||||
public func getComments(for statusId: String, and accountData: AccountData) async throws -> [CommentViewModel] {
|
public func getComments(for statusId: String, and accountData: AccountData) async throws -> [CommentViewModel] {
|
||||||
var commentViewModels: [CommentViewModel] = []
|
var commentViewModels: [CommentViewModel] = []
|
||||||
|
|
||||||
// Get first level of comments.
|
|
||||||
let client = MastodonClient(baseURL: accountData.serverUrl).getAuthenticated(token: accountData.accessToken ?? String.empty())
|
let client = MastodonClient(baseURL: accountData.serverUrl).getAuthenticated(token: accountData.accessToken ?? String.empty())
|
||||||
let context = try await client.getContext(for: statusId)
|
try await self.getCommentDescendants(for: statusId, client: client, to: &commentViewModels)
|
||||||
|
|
||||||
// Iterate throught first level of comments and download descendants/
|
|
||||||
let descendants = context.descendants.toStatusViewModel()
|
|
||||||
for status in descendants {
|
|
||||||
commentViewModels.append(CommentViewModel(status: status, showDivider: true))
|
|
||||||
try await self.getCommentDescendants(for: status.id, client: client, to: &commentViewModels)
|
|
||||||
}
|
|
||||||
|
|
||||||
return commentViewModels
|
return commentViewModels
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user