From b5d883865dafa7dbe37596e2ff8c79bca87e758e Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 18 Nov 2022 00:16:21 +0800 Subject: [PATCH] fix: prefer the original mode to top-two-tier tree mode --- .../ThreadViewModel+LoadThreadState.swift | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift index 050670be7..1c6c40190 100644 --- a/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift +++ b/Mastodon/Scene/Thread/ThreadViewModel+LoadThreadState.swift @@ -92,19 +92,27 @@ extension ThreadViewModel.LoadThreadState { from: response.value.ancestors ) ) + // deprecated: Tree mode replies + // viewModel.mastodonStatusThreadViewModel.appendDescendant( + // domain: threadContext.domain, + // nodes: MastodonStatusThreadViewModel.Node.children( + // of: threadContext.statusID, + // from: response.value.descendants + // ) + // ) + + // new: the same order from API viewModel.mastodonStatusThreadViewModel.appendDescendant( domain: threadContext.domain, - nodes: MastodonStatusThreadViewModel.Node.children( - of: threadContext.statusID, - from: response.value.descendants - ) + nodes: response.value.descendants.map { status in + return .init(statusID: status.id, children: []) + } ) } catch { logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch status context for \(threadContext.statusID) fail: \(error.localizedDescription)") await enter(state: Fail.self) } - - } + } // end Task } }