Skip to content

Commit

Permalink
improve ux. (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Livinglist committed Jul 20, 2023
1 parent c43199e commit d30fe00
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct Comment: Item {
public let level: Int?
public var metadata: String? {
if let count = kids?.count, count != 0 {
return "\(count) cmts | \(timeAgo) by \(by.orEmpty)"
return "\(count) cmt\(count > 1 ? "s":"") | \(timeAgo) by \(by.orEmpty)"
} else {
return "\(timeAgo) by \(by.orEmpty)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct Story: Item {
if isJob {
return "\(timeAgo) by \(by.orEmpty)"
} else {
return "\(score.orZero) pts | \(descendants.orZero) cmts | \(timeAgo) by \(by.orEmpty)"
return "\(score.orZero) pt\(score.orZero > 1 ? "s":"") | \(descendants.orZero) cmt\(descendants.orZero > 1 ? "s":"") | \(timeAgo) by \(by.orEmpty)"
}
}

Expand Down
1 change: 1 addition & 0 deletions Shared/Models/Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum Status {
case loading
// Loading with no loading indicator.
case backgroundLoading
case refreshing
case loaded
case error

Expand Down
6 changes: 3 additions & 3 deletions Shared/Models/Stores/StoryStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ extension HomeView {
private var currentPage: Int = 0
private var storyIds: [Int] = .init()

func fetchStories() async {
self.status = .loading
func fetchStories(status: Status = .loading) async {
self.status = status
self.currentPage = 0
self.storyIds = await StoriesRepository.shared.fetchStoryIds(from: self.storyType)

Expand All @@ -32,7 +32,7 @@ extension HomeView {
}

func refresh() async -> Void {
await fetchStories()
await fetchStories(status: .refreshing)
}

func loadMore() async {
Expand Down
2 changes: 1 addition & 1 deletion Shared/Views/ItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct ItemView: View {
.foregroundColor(getColor())
}
if let descendants = item.descendants {
Text("\(descendants) comment\(descendants <= 1 ? "" : "s")")
Text("\(descendants) cmt\(descendants <= 1 ? "" : "s")")
.borderedFootnote()
.foregroundColor(getColor())
}
Expand Down
4 changes: 2 additions & 2 deletions Shared/Views/Widgets/CommentTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension ItemView {

onLoadMore()
} label: {
Text("Load \(comment.kids.countOrZero) \(comment.kids.isMoreThanOne ? "replies" : "reply")")
Text("\(comment.kids.countOrZero) \(comment.kids.isMoreThanOne ? "replies" : "reply")")
.font(.footnote.weight(.bold))
.foregroundColor(getColor(level: level))
.frame(width: 140)
Expand Down Expand Up @@ -180,7 +180,7 @@ extension ItemView {
.foregroundColor(getColor(level: level))
}
if let descendants = comment.descendants {
Text("\(descendants) comment\(descendants <= 1 ? "" : "s")")
Text("\(descendants) cmt\(descendants <= 1 ? "" : "s")")
.borderedFootnote()
.foregroundColor(getColor(level: level))
}
Expand Down

0 comments on commit d30fe00

Please sign in to comment.