@@ -153,7 +153,7 @@ IObservable<AccountCacheItem> GetUserFromCache()
153153 /// <param name="repo"></param>
154154 /// <param name="collection"></param>
155155 /// <returns></returns>
156- public ITrackingCollection < IPullRequestModel > GetPullRequests ( ILocalRepositoryModel repo ,
156+ public ITrackingCollection < IPullRequestModel > GetPullRequests ( IRepositoryModel repo ,
157157 ITrackingCollection < IPullRequestModel > collection )
158158 {
159159 // Since the api to list pull requests returns all the data for each pr, cache each pr in its own entry
@@ -163,7 +163,7 @@ public ITrackingCollection<IPullRequestModel> GetPullRequests(ILocalRepositoryMo
163163 // and replaces it instead of appending, so items get refreshed in-place as they come in.
164164
165165 var keyobs = GetUserFromCache ( )
166- . Select ( user => string . Format ( CultureInfo . InvariantCulture , "{0}|{1}:{2}" , CacheIndex . PRPrefix , user . Login , repo . Name ) ) ;
166+ . Select ( user => string . Format ( CultureInfo . InvariantCulture , "{0}|{1}:{2}" , CacheIndex . PRPrefix , repo . Owner , repo . Name ) ) ;
167167
168168 var source = Observable . Defer ( ( ) => keyobs
169169 . SelectMany ( key =>
@@ -188,16 +188,16 @@ public ITrackingCollection<IPullRequestModel> GetPullRequests(ILocalRepositoryMo
188188 return collection ;
189189 }
190190
191- public IObservable < IPullRequestModel > GetPullRequest ( ILocalRepositoryModel repo , int number )
191+ public IObservable < IPullRequestModel > GetPullRequest ( string owner , string name , int number )
192192 {
193193 return Observable . Defer ( ( ) =>
194194 {
195195 return hostCache . GetAndRefreshObject ( PRPrefix + '|' + number , ( ) =>
196196 Observable . CombineLatest (
197- apiClient . GetPullRequest ( repo . CloneUrl . Owner , repo . CloneUrl . RepositoryName , number ) ,
198- apiClient . GetPullRequestFiles ( repo . CloneUrl . Owner , repo . CloneUrl . RepositoryName , number ) . ToList ( ) ,
199- apiClient . GetIssueComments ( repo . CloneUrl . Owner , repo . CloneUrl . RepositoryName , number ) . ToList ( ) ,
200- apiClient . GetPullRequestReviewComments ( repo . CloneUrl . Owner , repo . CloneUrl . RepositoryName , number ) . ToList ( ) ,
197+ apiClient . GetPullRequest ( owner , name , number ) ,
198+ apiClient . GetPullRequestFiles ( owner , name , number ) . ToList ( ) ,
199+ apiClient . GetIssueComments ( owner , name , number ) . ToList ( ) ,
200+ apiClient . GetPullRequestReviewComments ( owner , name , number ) . ToList ( ) ,
201201 ( pr , files , comments , reviewComments ) => new
202202 {
203203 PullRequest = pr ,
@@ -216,6 +216,19 @@ public IObservable<IPullRequestModel> GetPullRequest(ILocalRepositoryModel repo,
216216 } ) ;
217217 }
218218
219+ public IObservable < IRemoteRepositoryModel > GetRepository ( string owner , string repo )
220+ {
221+ var keyobs = GetUserFromCache ( )
222+ . Select ( user => string . Format ( CultureInfo . InvariantCulture , "{0}|{1}" , CacheIndex . RepoPrefix , user . Login ) ) ;
223+
224+ return Observable . Defer ( ( ) => keyobs
225+ . SelectMany ( key =>
226+ hostCache . GetAndFetchLatest (
227+ key ,
228+ ( ) => apiClient . GetRepository ( owner , repo ) . Select ( RepositoryCacheItem . Create ) )
229+ . Select ( Create ) ) ) ;
230+ }
231+
219232 public ITrackingCollection < IRemoteRepositoryModel > GetRepositories ( ITrackingCollection < IRemoteRepositoryModel > collection )
220233 {
221234 var keyobs = GetUserFromCache ( )
@@ -390,7 +403,8 @@ IRemoteRepositoryModel Create(RepositoryCacheItem item)
390403 new UriString ( item . CloneUrl ) ,
391404 item . Private ,
392405 item . Fork ,
393- Create ( item . Owner ) )
406+ Create ( item . Owner ) ,
407+ item . Parent != null ? Create ( item . Parent ) : null )
394408 {
395409 CreatedAt = item . CreatedAt ,
396410 UpdatedAt = item . UpdatedAt
@@ -504,6 +518,7 @@ public RepositoryCacheItem(Repository apiRepository)
504518 CreatedAt = apiRepository . CreatedAt ;
505519 UpdatedAt = apiRepository . UpdatedAt ;
506520 Timestamp = apiRepository . UpdatedAt ;
521+ Parent = apiRepository . Parent != null ? new RepositoryCacheItem ( apiRepository . Parent ) : null ;
507522 }
508523
509524 public long Id { get ; set ; }
@@ -515,6 +530,7 @@ public RepositoryCacheItem(Repository apiRepository)
515530 public bool Fork { get ; set ; }
516531 public DateTimeOffset CreatedAt { get ; set ; }
517532 public DateTimeOffset UpdatedAt { get ; set ; }
533+ public RepositoryCacheItem Parent { get ; set ; }
518534 }
519535
520536 public class PullRequestCacheItem : CacheItem
0 commit comments