Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
75 changes: 65 additions & 10 deletions Classes/Issues/Request/IssueRequestModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,70 @@ final class IssueRequestModel: ListDiffable {
self.date = date
self.event = event

let styledString: StyledTextString
if actor == user {
styledString = IssueRequestModel.buildSelfString(
user: actor,
date: date,
event: event
)
} else {
styledString = IssueRequestModel.buildString(
actor: actor,
user: user,
date: date,
event: event
)
}

self.string = StyledTextRenderer(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You don't need self. here right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need, but I think is better for consistency since all other members being initialized require self. So doing all members even this with it :))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They need self. because the parameter names match the variable names

Copy link
Collaborator Author

@LucianoPAlmeida LucianoPAlmeida Dec 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but what I mean by consistency is

        self.id = id
        self.actor = actor
        self.user = user
        self.date = date
        self.event = event
        string = ... // Also a member 
        // Even it not needing, to maintain consistency in all memeber initialization 
       self.string = ... 

But can change if it is a problem :)

string: styledString,
contentSizeCategory: contentSizeCategory,
inset: UIEdgeInsets(
top: Styles.Sizes.inlineSpacing,
left: 0,
bottom: Styles.Sizes.inlineSpacing,
right: 0
)
).warm(width: width)
}

static private func buildSelfString(
user: String,
date: Date,
event: Event
) -> StyledTextString {
let phrase: String
switch event {
case .assigned: phrase = NSLocalizedString(" self-assigned this", comment: "")
case .unassigned: phrase = NSLocalizedString(" removed their assignment", comment: "")
case .reviewRequested: phrase = NSLocalizedString(" self-requested a review", comment: "")
case .reviewRequestRemoved: phrase = NSLocalizedString(" removed their request for review", comment: "")
}

let builder = StyledTextBuilder(styledText: StyledText(
style: Styles.Text.secondary.with(foreground: Styles.Colors.Gray.medium.color)
))
.save()
.add(styledText: StyledText(text: user, style: Styles.Text.secondaryBold.with(attributes: [
MarkdownAttribute.username: user,
.foregroundColor: Styles.Colors.Gray.dark.color
])
))
.restore()
.add(text: phrase)
.add(text: " \(date.agoString(.long))", attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])

return builder.build()
}

static private func buildString(
actor: String,
user: String,
date: Date,
event: Event
) -> StyledTextString {

let phrase: String
switch event {
case .assigned: phrase = NSLocalizedString(" assigned", comment: "")
Expand All @@ -66,16 +130,7 @@ final class IssueRequestModel: ListDiffable {
.restore()
.add(text: " \(date.agoString(.long))", attributes: [MarkdownAttribute.details: DateDetailsFormatter().string(from: date)])

self.string = StyledTextRenderer(
string: builder.build(),
contentSizeCategory: contentSizeCategory,
inset: UIEdgeInsets(
top: Styles.Sizes.inlineSpacing,
left: 0,
bottom: Styles.Sizes.inlineSpacing,
right: 0
)
).warm(width: width)
return builder.build()
}

// MARK: ListDiffable
Expand Down
2 changes: 1 addition & 1 deletion Classes/Settings/DefaultReactionDetailController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DefaultReactionDetailController: UITableViewController {

private func updateSections() {
tableView.performBatchUpdates({
if enabledSwitch.isOn {
if enabledSwitch.isOn {
self.tableView.insertSections(IndexSet(integer: 1), with: .top)
} else {
self.tableView.deleteSections(IndexSet(integer: 1), with: .top)
Expand Down
1 change: 0 additions & 1 deletion Classes/Utility/NSRegularExpression+StaticString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


extension NSRegularExpression {

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