{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments/41272504","id":41272504,"diff_hunk":"@@ -0,0 +1,51 @@\n+//\n+//  UIViewController+WMFSearchButton.m\n+//  Wikipedia\n+//\n+//  Created by Brian Gerstle on 9/30/15.\n+//  Copyright © 2015 Wikimedia Foundation. All rights reserved.\n+//\n+\n+#import \"UIViewController+WMFSearchButton.h\"\n+#import \"WMFSearchViewController.h\"\n+#import \"UIBarButtonItem+WMFButtonConvenience.h\"\n+#import \"WMFArticleContainerViewController.h\"\n+#import \"SessionSingleton.h\"\n+\n+NS_ASSUME_NONNULL_BEGIN\n+\n+@implementation UIViewController (WMFSearchButton)\n+\n+- (UIBarButtonItem*)wmf_searchBarButtonItemWithDelegate:(UIViewController<WMFSearchPresentationDelegate>*)delegate {\n+    @weakify(self);\n+    @weakify(delegate);\n+    return [UIBarButtonItem wmf_buttonType:WMFButtonTypeMagnify handler:^(id sender) {\n+        @strongify(self);\n+        @strongify(delegate);\n+        if (!delegate || !self) {\n+            return;\n+        }\n+\n+        MWKSite* searchSite;\n+        if ([delegate respondsToSelector:@selector(searchSite)]) {","path":"Wikipedia/UI-V5/UIViewController+WMFSearchButton.m","position":30,"original_position":30,"commit_id":"80997c669156ca18073d28c34e71a23440c2f4e0","original_commit_id":"80997c669156ca18073d28c34e71a23440c2f4e0","user":{"login":"coreyfloyd","id":64771,"avatar_url":"https://avatars.githubusercontent.com/u/64771?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyfloyd","html_url":"https://github.com/coreyfloyd","followers_url":"https://api.github.com/users/coreyfloyd/followers","following_url":"https://api.github.com/users/coreyfloyd/following{/other_user}","gists_url":"https://api.github.com/users/coreyfloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyfloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyfloyd/subscriptions","organizations_url":"https://api.github.com/users/coreyfloyd/orgs","repos_url":"https://api.github.com/users/coreyfloyd/repos","events_url":"https://api.github.com/users/coreyfloyd/events{/privacy}","received_events_url":"https://api.github.com/users/coreyfloyd/received_events","type":"User","site_admin":false},"body":"Why are we doing this?","created_at":"2015-10-06T14:40:16Z","updated_at":"2015-10-06T14:40:16Z","html_url":"https://github.com/wikimedia/wikipedia-ios/pull/138#discussion_r41272504","pull_request_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments/41272504"},"html":{"href":"https://github.com/wikimedia/wikipedia-ios/pull/138#discussion_r41272504"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138","id":46459608,"html_url":"https://github.com/wikimedia/wikipedia-ios/pull/138","diff_url":"https://github.com/wikimedia/wikipedia-ios/pull/138.diff","patch_url":"https://github.com/wikimedia/wikipedia-ios/pull/138.patch","issue_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/138","number":138,"state":"open","locked":false,"title":"New search UX","user":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"body":"Phab: [T113071](https://phabricator.wikimedia.org/T113071)\r\n\r\n- [x] implement modal transition w/ blur\r\n- [x] restyle search field\r\n  - [x] \"text field\" appearance\r\n  - [x] \"X\" button to close search text field (**note** the close button looks different than mocks, but will be fixed when get new icons)\r\n- [x] add search button to... \r\n  - [x] home view\r\n  - [x] article view\r\n  - [x] saved\r\n  - [x] recent\r\n\r\n---\r\n\r\n### New\r\n\r\n#### `WMFSearchPresentationDelegate`\r\nProvides dependencies for creating & presenting a search controller and responding to its results.  The \"informal protocol\" leaves search result handling to the individual view controllers.  Not as DRY as I would like, but I think our object graph needs a little pruning & refactoring in general (see observations).\r\n\r\n#### `UIViewController+WMFSearchButton`\r\nCategory which allows view controllers to create a search button (with a `WMFSearchPresentationDelegate`, often `self`), which handles creating & presenting a `WMFSearchViewController`.  As mentioned above, delegates still need to implement reacting to search result selection.  Currently this is repeated in Home, ArticleList, and ArticleContainer classes which all:\r\n\r\n- Create an article container, using dependency injection\r\n- Push it on the navigation stack\r\n- Add it to history w/ the correct discovery method\r\n- Save history list\r\n\r\nI'm not happy w/ the amount of repetition, which IMO would be best solved by protocol extensions in Swift, but since that's not an option, we might need to leave with this as is.  The other options I can think of are:\r\n\r\n- Using VC hierarchy to propagate article presentation to a suitable controller (e.g. root or navigation controller)\r\n- Factoring out the history list logic into another class which listens for presentation notifications\r\n  - This is tricky, and also means we should think about whether putting the title on screen counts, or whether we need to get the data successfully to add it to the history list.\r\n\r\n### Changed\r\n\r\n`MWKUserDataStore` is now a persistent property of `MWKDataStore`. The idea is to facilitate dependency injection and prevent unexpected behavior due to re-instantiation of the `userDataStore` and its associated lists.\r\n\r\n`WMFArticleListCollectionViewController` now has a selection delegate which, if set, silences its default behavior of pushing an article container.  This allows search to use a list controller which, through delegation, allows the search view controller's delegate to present the selected search result.","created_at":"2015-09-30T21:32:55Z","updated_at":"2015-10-06T14:40:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c1b25a763435cbe4494c1a005f5cf0e37bbb699","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138/commits","review_comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138/comments","review_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/138/comments","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/80997c669156ca18073d28c34e71a23440c2f4e0","head":{"label":"wikimedia:feature/global-search/T113071","ref":"feature/global-search/T113071","sha":"80997c669156ca18073d28c34e71a23440c2f4e0","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13863130,"name":"wikipedia-ios","full_name":"wikimedia/wikipedia-ios","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/wikipedia-ios","description":"The official Wikipedia iOS client.","fork":false,"url":"https://api.github.com/repos/wikimedia/wikipedia-ios","forks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/forks","keys_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/teams","hooks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/events","assignees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/tags","blobs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/languages","stargazers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscription","commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/merges","archive_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/downloads","issues_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/releases{/id}","created_at":"2013-10-25T14:36:56Z","updated_at":"2015-10-01T11:43:57Z","pushed_at":"2015-10-06T14:29:31Z","git_url":"git://github.com/wikimedia/wikipedia-ios.git","ssh_url":"git@github.com:wikimedia/wikipedia-ios.git","clone_url":"https://github.com/wikimedia/wikipedia-ios.git","svn_url":"https://github.com/wikimedia/wikipedia-ios","homepage":"https://www.mediawiki.org/wiki/Wikimedia_Apps","size":92431,"stargazers_count":399,"watchers_count":399,"language":"Objective-C","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":112,"mirror_url":null,"open_issues_count":3,"forks":112,"open_issues":3,"watchers":399,"default_branch":"master"}},"base":{"label":"wikimedia:master","ref":"master","sha":"b7350be2921467a2049578778a34faf39d171acc","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13863130,"name":"wikipedia-ios","full_name":"wikimedia/wikipedia-ios","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/wikipedia-ios","description":"The official Wikipedia iOS client.","fork":false,"url":"https://api.github.com/repos/wikimedia/wikipedia-ios","forks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/forks","keys_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/teams","hooks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/events","assignees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/tags","blobs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/languages","stargazers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscription","commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/merges","archive_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/downloads","issues_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/releases{/id}","created_at":"2013-10-25T14:36:56Z","updated_at":"2015-10-01T11:43:57Z","pushed_at":"2015-10-06T14:29:31Z","git_url":"git://github.com/wikimedia/wikipedia-ios.git","ssh_url":"git@github.com:wikimedia/wikipedia-ios.git","clone_url":"https://github.com/wikimedia/wikipedia-ios.git","svn_url":"https://github.com/wikimedia/wikipedia-ios","homepage":"https://www.mediawiki.org/wiki/Wikimedia_Apps","size":92431,"stargazers_count":399,"watchers_count":399,"language":"Objective-C","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":112,"mirror_url":null,"open_issues_count":3,"forks":112,"open_issues":3,"watchers":399,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138"},"html":{"href":"https://github.com/wikimedia/wikipedia-ios/pull/138"},"issue":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/138"},"comments":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/138/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/138/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/80997c669156ca18073d28c34e71a23440c2f4e0"}}}}