diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-03-07 15:52:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 15:52:24 -0600 |
commit | e74f94bc72cdbb2282096b8d36677ba6655ab5be (patch) | |
tree | 997aa96761801e1cf23d69c455a2d1b1f5379e80 /src/state/models/post-thread-view.ts | |
parent | 2f3fc4fe4e799084799631323b73fc97820144c8 (diff) | |
download | voidsky-e74f94bc72cdbb2282096b8d36677ba6655ab5be.tar.zst |
Big batch of UI updates (#276)
* Replace react-native-root-toast with a custom toast that fits the visual style * Tune dark mode colors * Tune colors a bit more * Move the reply prompt to a fixed position in the footer * Fully hide muted posts but give a control to show anyway (close #270) * Improve thread rendering (better clarity on reply lines) * Add follower/following counts to side menu * Fix issues with display name overflows
Diffstat (limited to 'src/state/models/post-thread-view.ts')
-rw-r--r-- | src/state/models/post-thread-view.ts | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/state/models/post-thread-view.ts b/src/state/models/post-thread-view.ts index ad989cc53..d58ee691b 100644 --- a/src/state/models/post-thread-view.ts +++ b/src/state/models/post-thread-view.ts @@ -21,6 +21,8 @@ export class PostThreadViewPostModel { _reactKey: string = '' _depth = 0 _isHighlightedPost = false + _showParentReplyLine = false + _showChildReplyLine = false _hasMore = false // data @@ -30,6 +32,14 @@ export class PostThreadViewPostModel { replies?: (PostThreadViewPostModel | GetPostThread.NotFoundPost)[] richText?: RichText + get uri() { + return this.post.uri + } + + get parentUri() { + return this.postRecord?.reply?.parent.uri + } + constructor( public rootStore: RootStoreModel, reactKey: string, @@ -65,6 +75,7 @@ export class PostThreadViewPostModel { assignTreeModels( keyGen: Generator<string>, v: GetPostThread.ThreadViewPost, + higlightedPostUri: string, includeParent = true, includeChildren = true, ) { @@ -77,8 +88,16 @@ export class PostThreadViewPostModel { v.parent, ) parentModel._depth = this._depth - 1 + parentModel._showChildReplyLine = true if (v.parent.parent) { - parentModel.assignTreeModels(keyGen, v.parent, true, false) + parentModel._showParentReplyLine = true //parentModel.uri !== higlightedPostUri + parentModel.assignTreeModels( + keyGen, + v.parent, + higlightedPostUri, + true, + false, + ) } this.parent = parentModel } else if (GetPostThread.isNotFoundPost(v.parent)) { @@ -96,8 +115,17 @@ export class PostThreadViewPostModel { item, ) itemModel._depth = this._depth + 1 - if (item.replies) { - itemModel.assignTreeModels(keyGen, item, false, true) + itemModel._showParentReplyLine = + itemModel.parentUri !== higlightedPostUri + if (item.replies?.length) { + itemModel._showChildReplyLine = true + itemModel.assignTreeModels( + keyGen, + item, + higlightedPostUri, + false, + true, + ) } replies.push(itemModel) } else if (GetPostThread.isNotFoundPost(item)) { @@ -333,6 +361,7 @@ export class PostThreadViewModel { thread.assignTreeModels( keyGen, res.data.thread as GetPostThread.ThreadViewPost, + thread.uri, ) this.thread = thread } |