-
Notifications
You must be signed in to change notification settings - Fork 387
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Looking forward to this one
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Bit of excessive spacing here
760aafc
to
9ad2ed5
Compare
@Sherlouk Applied your suggestions.. thanks for the feedback! |
// assume the collectionview is pinned to the view's bounds | ||
let contentInset = feed.collectionView.contentInset | ||
return view.bounds.width - contentInset.left - contentInset.right | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this so that I could re-use it in the completion block after the fetch; see below
if let current = strongSelf.result {
let issueResult = IssuesViewController.updateIssueResultModelTitle(
newTitle: newTitle,
oldTitle: strongSelf.currentIssueTitle ?? "",
username: strongSelf.client.userSession?.username ?? Constants.Strings.unknown,
issueResultModel: current,
width: strongSelf.insetWidth
)
strongSelf.client.cache.set(value: issueResult)
}
aa85c53
to
3b31118
Compare
Use localized string for title
3b31118
to
7c0360a
Compare
@Sherlouk - I'm doing something wrong - I've been having trouble adding files to local pods, and getting the new XCode beta seemed to help, so I pulled this PR down to check on it, and the V3EditIssueTitleRequest in GitHubAPI didn't compile (didn't actually show up in XCode at all) - so I amended the commit, re-added the file so that it compiled and pushed it back up, and now there's this huge diff in For starters, I don't actually know the correct way to add a file to a local pod. When I try to add the file, it says Group: "GitHubAPI", and for target I'm putting a checkmark next to GithubAPI-iOS, because XCode doesn't complain and everything compiles when I do that. But I'm not sure that's correct? |
} | ||
|
||
var viewerCanUpdate: Bool { | ||
return result?.viewerCanUpdate ?? false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IssueManagingContextController
already has access to IssueResult. These don't have to be delegate methods right? Can't these values just be fetched from the model when the edit VC is initialized?
protocol EditIssueTitleViewControllerDelegate: class { | ||
func sendEditTitleRequest(newTitle: String, viewController: EditIssueTitleViewController) | ||
var currentIssueTitle: String? { get } | ||
var viewerCanUpdate: Bool { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my notes about IssueManagingContextController
already having access to the model. IMO these last 2 properties can be removed.
import SnapKit | ||
|
||
protocol EditIssueTitleViewControllerDelegate: class { | ||
func sendEditTitleRequest(newTitle: String, viewController: EditIssueTitleViewController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: delegate pattern has self
param first, then other data params. Something like this would be more consistent:
func sendEditTitleRequest(from viewController: EditIssueTitleViewController, with title: String)
var viewerCanUpdate: Bool { get } | ||
} | ||
|
||
class EditIssueTitleViewController: UIViewController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
width: Styles.Sizes.contextMenuSize.width, | ||
height: 120 | ||
) | ||
title = NSLocalizedString("Edit", comment: "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String "Edit"
already exists, mind tossing that in Constants.swift
?
@@ -286,6 +288,13 @@ final class IssuesViewController: MessageViewController, | |||
activityController.popoverPresentationController?.barButtonItem = sender | |||
present(activityController, animated: trueUnlessReduceMotionEnabled) | |||
} | |||
|
|||
var insetWidth: CGFloat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
?
// assume the collectionview is pinned to the view's bounds | ||
let contentInset = feed.collectionView.contentInset | ||
let width = view.bounds.width - contentInset.left - contentInset.right | ||
let width = insetWidth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just move insetWidth
to the param? Doesn't need a let
now right?
} | ||
|
||
viewController.setRightBarItemIdle() | ||
viewController.dismiss(animated: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is strongly retaining the viewController
param
|
||
func sendEditTitleRequest(newTitle: String, viewController: EditIssueTitleViewController) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just put all the sending stuff inside the edit VC? Can include the cache updating stuff since the issue VC listens for model changes and will reload. Would totally eliminate the need for this delegate API and keep things really separated.
Squawk.show(error: error) | ||
} | ||
|
||
viewController.setRightBarItemIdle() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the edit VC sets its right bar spinning, but the issue VC is required to set it back? Adds a lot of implicit logic. Another +1 for just putting all this logic inside the edit VC...
530084b
to
25b9037
Compare
25b9037
to
a33747b
Compare
@BrianLitwin just lmk when this is ready for another look! I'm going to try to get the push notifications release out and then fast-follow w/ another release including this, that way this PR has time to bake but doesn't slow down the next update. |
1e9d8f9
to
b2a4cd7
Compare
bff9c30
to
331df69
Compare
Hey @BrianLitwin you still planning to jump back on this? No rush at all, just checking in since it seemed you were almost done with it. Obv I’m just excited for this awesome addition and let me know if I’m overstepping by f/u and I’ll make sure I refrain from doing so again in future... |
@BrianLitwin lmk if you have plans to revisit this. Def a high-impact feature! Leaving it open for now. |
@rnystrom with the new Bookmark storage model, there's no reason to worry about updating the Bookmark Store anymore if you edited an Issue's title? Because we are not saving the bookmark title anymore, but saving the graphQL id and then fetching the title + other info from graphQL? |
This has three pieces of key functionality: * sends a v3 network request to update the issue title * updates the IssueTitleSectionController (the title the user sees when they open an Issue) * updates the Issue Timeline These can be tested/verified manually. I also added a unit test to verify that the User's interaction with the EditIssueTitleViewController works as expected, eg a network request won't be sent unless a user edits the issue title and calls onSave(). This is an update of GitHawkApp#2348 - in this version of the PR, I'm using the pipeline IssueManagingContextController uses w/ it's other view controllers, ie updating things optimistically and triggered by the contextMenuWillDismiss() method. I didn't add any funcionality to update the Bookmarks api with the new title b/c my understanding is that those are not stored anymore, are requested from the github api. I updated some string constants (requested in original pr) and I removed the width parameter from a helper function [titleStringSizing] because it was convenient and I couldn't find anywhere that parameter was used Something to note is that issue titles that have already been requested and displayed won't be updated. Eg if you go from Bookmarks to an issue and edit the title and go back to bookmarks, the issue title on the bookmark won't be updated. [titleStringSizing]: https://github.com/GitHawkApp/GitHawk/blob/45e9cf6428d5edfe00a73eb18450c50c03871510/Classes/Issues/IssueViewModels.swift#L13
This has three pieces of key functionality: * sends a v3 network request to update the issue title * updates the IssueTitleSectionController (the title the user sees when they open an Issue) * updates the Issue Timeline These can be tested/verified manually. I also added a unit test to verify that the User's interaction with the EditIssueTitleViewController works as expected, eg a network request won't be sent unless a user edits the issue title and calls onSave(). This is an update of GitHawkApp#2348 - in this version of the PR, I'm using the IssueManagingContextController pipineline that it uses w/ it's other view controllers, ie updating optimistically and triggered by the contextMenuWillDismiss() method. EditIssueTitle's behavior is intended to be very similar to Labels, People, and Milestones. I didn't add any funcionality to update the Bookmarks api with the new title b/c my understanding is that those are not stored anymore but are requested from the github api. I updated some string constants (requested in original pr) and I removed the width parameter from a helper function [titleStringSizing] because it was convenient and I couldn't find anywhere that parameter was used [titleStringSizing]: https://github.com/GitHawkApp/GitHawk/blob/45e9cf6428d5edfe00a73eb18450c50c03871510/Classes/Issues/IssueViewModels.swift#L13
This has three pieces of key functionality: * sends a v3 network request to update the issue title * updates the IssueTitleSectionController (the title the user sees when they open an Issue) * updates the Issue Timeline These can be tested/verified manually. I also added a unit test to verify that the User's interaction with the EditIssueTitleViewController works as expected, eg a network request won't be sent unless a user edits the issue title and calls onSave(). This is an update of GitHawkApp#2348 - in this version of the PR, EditIssueTitle's behavior is intended to be very similar to Labels, People, and Milestones. Ie it updates the UI optimistically and these updates are triggered by ContextMenuWillDismiss(). I didn't add any funcionality to update Bookmarks after an issue title is edited because my understanding is that the bookmark titles are not stored anymore but are retrieved from the github api. I updated some string constants (requested in original pr) and I removed the width parameter from a helper function [titleStringSizing] because it was convenient and I couldn't find anywhere that parameter was used [titleStringSizing]: https://github.com/GitHawkApp/GitHawk/blob/45e9cf6428d5edfe00a73eb18450c50c03871510/Classes/Issues/IssueViewModels.swift#L13
This has three pieces of key functionality: * sends a v3 network request to update the issue title * updates the IssueTitleSectionController (the title the user sees when they open an Issue) * updates the Issue Timeline These can be tested/verified manually. I also added a unit test to verify that the User's interaction with the EditIssueTitleViewController works as expected, eg a network request won't be sent unless a user edits the issue title and calls onSave(). This is an update of GitHawkApp#2348 - in this version of the PR, EditIssueTitle's behavior is intended to be very similar to Labels, People, and Milestones. Ie it updates the UI optimistically and these updates are triggered by ContextMenuWillDismiss(). I didn't add any funcionality to update Bookmarks after an issue title is edited because my understanding is that the bookmark titles are not stored anymore but are retrieved from the github api. I updated some string constants (requested in original pr) and I removed the width parameter from a helper function [titleStringSizing] because it was convenient and I couldn't find anywhere that parameter was used [titleStringSizing]: https://github.com/GitHawkApp/GitHawk/blob/45e9cf6428d5edfe00a73eb18450c50c03871510/Classes/Issues/IssueViewModels.swift#L13
This has three pieces of key functionality: * sends a v3 network request to update the issue title * updates the IssueTitleSectionController (the title the user sees when they open an Issue) * updates the Issue Timeline These can be tested/verified manually. I also added a unit test to verify that the User's interaction with the EditIssueTitleViewController works as expected, eg a network request won't be sent unless a user edits the issue title and calls onSave(). This is an update of GitHawkApp#2348 - in this version of the PR, EditIssueTitle's behavior is intended to be very similar to Labels, People, and Milestones. Ie it updates the UI optimistically and these updates are triggered by ContextMenuWillDismiss(). I didn't add any funcionality to update Bookmarks after an issue title is edited because my understanding is that the bookmark titles are not stored anymore but are retrieved from the github api. I updated some string constants (requested in original pr) and I removed the width parameter from a helper function [titleStringSizing] because it was convenient and I couldn't find anywhere that parameter was used [titleStringSizing]: https://github.com/GitHawkApp/GitHawk/blob/45e9cf6428d5edfe00a73eb18450c50c03871510/Classes/Issues/IssueViewModels.swift#L13
Connected to #2054
See that thread for video and pics.. I did adjust the height to 120 as was recommended there.
Manually tested that editing the title updates three areas:
Included unit tests as well.
Used the viewerCanUpdate flag to determine editing privileges.
I also manually tested super long titles.. the textview handles them well and that shouldn't be an issue.
Update:
I realized this also needs to update the bookmark struct that the nav controller will use to set a new bookmark - eg currently, if you edit a title -> then bookmark the issue -> the bookmark will reference the original title, not the edited one.
@rnystrom Thanks for your review! I'm learning a lot. I'm going to update the Edit VC to follow a pattern more similar to People, Milestones, etc.. update everything optimistically and reset if there's a network failure. Was looking at the EditComment VC for cues, that was prob not the optimal apprach.
Updating the Bookmark API seems like a non-trivial issue, might need a separate PR, for the time being i'll do my best.