Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 75de7aa

Browse files
LucianoPAlmeidarnystrom
authored andcommitted
Changing request review message to self when the same user (#2558)
* Changing request review message to self when the same user * Fixing PR comments
1 parent f8b8fe5 commit 75de7aa

File tree

3 files changed

+66
-12
lines changed

3 files changed

+66
-12
lines changed

Classes/Issues/Request/IssueRequestModel.swift

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,70 @@ final class IssueRequestModel: ListDiffable {
4242
self.date = date
4343
self.event = event
4444

45+
let styledString: StyledTextString
46+
if actor == user {
47+
styledString = IssueRequestModel.buildSelfString(
48+
user: actor,
49+
date: date,
50+
event: event
51+
)
52+
} else {
53+
styledString = IssueRequestModel.buildString(
54+
actor: actor,
55+
user: user,
56+
date: date,
57+
event: event
58+
)
59+
}
60+
61+
self.string = StyledTextRenderer(
62+
string: styledString,
63+
contentSizeCategory: contentSizeCategory,
64+
inset: UIEdgeInsets(
65+
top: Styles.Sizes.inlineSpacing,
66+
left: 0,
67+
bottom: Styles.Sizes.inlineSpacing,
68+
right: 0
69+
)
70+
).warm(width: width)
71+
}
72+
73+
static private func buildSelfString(
74+
user: String,
75+
date: Date,
76+
event: Event
77+
) -> StyledTextString {
78+
let phrase: String
79+
switch event {
80+
case .assigned: phrase = NSLocalizedString(" self-assigned this", comment: "")
81+
case .unassigned: phrase = NSLocalizedString(" removed their assignment", comment: "")
82+
case .reviewRequested: phrase = NSLocalizedString(" self-requested a review", comment: "")
83+
case .reviewRequestRemoved: phrase = NSLocalizedString(" removed their request for review", comment: "")
84+
}
85+
86+
let builder = StyledTextBuilder(styledText: StyledText(
87+
style: Styles.Text.secondary.with(foreground: Styles.Colors.Gray.medium.color)
88+
))
89+
.save()
90+
.add(styledText: StyledText(text: user, style: Styles.Text.secondaryBold.with(attributes: [
91+
MarkdownAttribute.username: user,
92+
.foregroundColor: Styles.Colors.Gray.dark.color
93+
])
94+
))
95+
.restore()
96+
.add(text: phrase)
97+
.add(text: " \(date.agoString(.long))", attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])
98+
99+
return builder.build()
100+
}
101+
102+
static private func buildString(
103+
actor: String,
104+
user: String,
105+
date: Date,
106+
event: Event
107+
) -> StyledTextString {
108+
45109
let phrase: String
46110
switch event {
47111
case .assigned: phrase = NSLocalizedString(" assigned", comment: "")
@@ -66,16 +130,7 @@ final class IssueRequestModel: ListDiffable {
66130
.restore()
67131
.add(text: " \(date.agoString(.long))", attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])
68132

69-
self.string = StyledTextRenderer(
70-
string: builder.build(),
71-
contentSizeCategory: contentSizeCategory,
72-
inset: UIEdgeInsets(
73-
top: Styles.Sizes.inlineSpacing,
74-
left: 0,
75-
bottom: Styles.Sizes.inlineSpacing,
76-
right: 0
77-
)
78-
).warm(width: width)
133+
return builder.build()
79134
}
80135

81136
// MARK: ListDiffable

Classes/Settings/DefaultReactionDetailController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class DefaultReactionDetailController: UITableViewController {
9696

9797
private func updateSections() {
9898
tableView.performBatchUpdates({
99-
if enabledSwitch.isOn {
99+
if enabledSwitch.isOn {
100100
self.tableView.insertSections(IndexSet(integer: 1), with: .top)
101101
} else {
102102
self.tableView.deleteSections(IndexSet(integer: 1), with: .top)

Classes/Utility/NSRegularExpression+StaticString.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import Foundation
1010

11-
1211
extension NSRegularExpression {
1312

1413
convenience init(_ pattern: StaticString, options: NSRegularExpression.Options = []) {

0 commit comments

Comments
 (0)