Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic collapse child comments #841

Merged
merged 32 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5c36133
[Feature] Added automatic collapse child comments, including settings…
schmeat Jan 3, 2024
25a70ba
- Updated icon for collapse comment settings
schmeat Jan 3, 2024
71052be
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 3, 2024
e74dd8a
- Added isCollapsed flag to parentCollapsed to make only parent comme…
schmeat Jan 3, 2024
155bc1d
- Updated logic for calculating when to hide comments automatically
schmeat Jan 3, 2024
e24c713
- Code clean up for auto collapse comments
schmeat Jan 3, 2024
b839613
- Updated text and location of Collapse comments in settings
schmeat Jan 3, 2024
67e60e9
- Switch back enum to struct
schmeat Jan 4, 2024
24980b0
- switch back enum to struct
schmeat Jan 4, 2024
0d513de
- switching enum to struct, third time's the charm?
schmeat Jan 4, 2024
ea36093
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 4, 2024
c3a0ce0
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 4, 2024
d5be159
- Rough logic and UI for collapse comments automatically with a bar b…
schmeat Jan 5, 2024
4212d58
- Updated appearance of the collapsed child comment text box
schmeat Jan 5, 2024
467929a
- Iterating through depth 1 comments to also uncollapse for comment r…
schmeat Jan 5, 2024
5aa5391
- added padding top and bottom to CollapsedCommentReplies
schmeat Jan 6, 2024
44ca122
- restricted height and changed colour to .accent for CollapsedCommen…
schmeat Jan 6, 2024
05e83b2
- refactored uncollapse comment logic into method
schmeat Jan 6, 2024
7f0b9e9
- Fixed logic for top level comment collapsing/uncollapsing
schmeat Jan 7, 2024
ccb8279
Update Mlem/Views/Shared/Comments/Components/CollapsedCommentReplies.…
schmeat Jan 7, 2024
722694f
- set isCommentReplyHidden to false when disappearing view so that it…
schmeat Jan 8, 2024
b11eeba
Update Mlem/Views/Shared/Comments/Comment Item.swift
schmeat Jan 8, 2024
32f55ef
- Check different child count to prevent child comment button from sh…
schmeat Jan 8, 2024
72d6cd9
- formatting
schmeat Jan 8, 2024
6317985
- Added page context to collapsing child comments, bypassing a lot of…
schmeat Jan 10, 2024
3830ba0
- formatting
schmeat Jan 10, 2024
347be9b
- re-added ondisappear for coming back from profile
schmeat Jan 11, 2024
f005efa
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 14, 2024
67dd861
- added check before reloading comments on page (thanks sjmarf)
schmeat Jan 14, 2024
270f90c
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 16, 2024
a4085d6
Merge branch 'dev' into feature/collapse-child-comments
schmeat Jan 17, 2024
ac1e036
Merge branch 'dev' of https://github.com/schmeat/mlem into feature/co…
schmeat Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Mlem/API/Internal/HierarchicalComment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ class HierarchicalComment: ObservableObject {
@Published var isCollapsed: Bool = false

init(comment: APICommentView, children: [HierarchicalComment], parentCollapsed: Bool, collapsed: Bool) {
let collapseChildCommentsFlag = UserDefaults.standard.bool(forKey: "collapseChildComments")
let depth = max(0, comment.comment.path.split(separator: ".").count - 2)

self.commentView = comment
self.children = children
self.depth = max(0, commentView.comment.path.split(separator: ".").count - 2)
self.isParentCollapsed = parentCollapsed
self.isCollapsed = collapsed
self.depth = depth
self.isParentCollapsed = collapseChildCommentsFlag && depth > 1 || parentCollapsed
self.isCollapsed = collapseChildCommentsFlag && depth == 1 || collapsed
schmeat marked this conversation as resolved.
Show resolved Hide resolved
self.links = comment.comment.content.parseLinks()
}
}
Expand Down
3 changes: 2 additions & 1 deletion Mlem/Icons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import SwiftUI

/// SFSymbol names for icons
struct Icons {
enum Icons {
Sjmarf marked this conversation as resolved.
Show resolved Hide resolved
// votes
static let votes: String = "arrow.up.arrow.down.square"
static let upvote: String = "arrow.up"
Expand Down Expand Up @@ -183,6 +183,7 @@ struct Icons {
static let developerMode: String = "wrench.adjustable.fill"
static let limitImageHeightSetting: String = "rectangle.compress.vertical"
static let swipeUpGestureSetting: String = "arrow.up.to.line.alt"
static let collapseComments: String = "arrow.down.and.line.horizontal.and.arrow.up"

// misc
static let switchUser: String = "person.crop.circle.badge.plus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct CommentSettingsView: View {
@AppStorage("shouldShowUserServerInComment") var shouldShowUserServerInComment: Bool = false

@AppStorage("showCommentJumpButton") var showCommentJumpButton: Bool = true
@AppStorage("collapseChildComments") var collapseChildComments: Bool = false
@AppStorage("commentJumpButtonSide") var commentJumpButtonSide: JumpButtonLocation = .bottomTrailing

var body: some View {
Expand All @@ -61,6 +62,11 @@ struct CommentSettingsView: View {
settingName: "Compact Comments",
isTicked: $compactComments
)
SwitchableSettingsItem(
settingPictureSystemName: Icons.collapseComments,
settingName: "Collapse Comments",
isTicked: $collapseChildComments
)

NavigationLink(.commentSettings(.layoutWidget)) {
Label {
Expand Down