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

Commit 81638d1

Browse files
committed
Merge fixes/repository-list into release/1.0.16.1
2 parents 1e7be3d + cac1da8 commit 81638d1

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/GitHub.App/Services/ModelService.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ IObservable<IEnumerable<AccountCacheItem>> GetUser()
9898
{
9999
return hostCache.GetAndRefreshObject("user",
100100
() => apiClient.GetUser().Select(AccountCacheItem.Create), TimeSpan.FromMinutes(5), TimeSpan.FromDays(7))
101-
.Take(1)
101+
.PublishLast()
102+
.RefCount()
102103
.ToList();
103104
}
104105

@@ -107,7 +108,7 @@ IObservable<IEnumerable<AccountCacheItem>> GetUserOrganizations()
107108
return GetUserFromCache().SelectMany(user =>
108109
hostCache.GetAndRefreshObject(user.Login + "|orgs",
109110
() => apiClient.GetOrganizations().Select(AccountCacheItem.Create).ToList(),
110-
TimeSpan.FromMinutes(5), TimeSpan.FromDays(7)))
111+
TimeSpan.FromMinutes(2), TimeSpan.FromDays(7)))
111112
.Catch<IEnumerable<AccountCacheItem>, KeyNotFoundException>(
112113
// This could in theory happen if we try to call this before the user is logged in.
113114
e =>
@@ -125,8 +126,12 @@ IObservable<IEnumerable<AccountCacheItem>> GetUserOrganizations()
125126
public IObservable<IReadOnlyList<IRepositoryModel>> GetRepositories()
126127
{
127128
return GetUserRepositories(RepositoryType.Owner)
128-
.Take(1)
129-
.Concat(GetUserRepositories(RepositoryType.Member).Take(1))
129+
.PublishLast()
130+
.RefCount()
131+
.Concat(GetUserRepositories(RepositoryType.Member)
132+
.PublishLast()
133+
.RefCount()
134+
)
130135
.Concat(GetAllRepositoriesForAllOrganizations());
131136
}
132137

@@ -174,7 +179,7 @@ IObservable<IReadOnlyList<IRepositoryModel>> GetUserRepositories(RepositoryType
174179
return Observable.Defer(() => GetUserFromCache().SelectMany(user =>
175180
hostCache.GetAndRefreshObject(string.Format(CultureInfo.InvariantCulture, "{0}|{1}:repos", user.Login, repositoryType),
176181
() => GetUserRepositoriesFromApi(repositoryType),
177-
TimeSpan.FromMinutes(5),
182+
TimeSpan.FromMinutes(2),
178183
TimeSpan.FromDays(7)))
179184
.ToReadOnlyList(Create))
180185
.Catch<IReadOnlyList<IRepositoryModel>, KeyNotFoundException>(
@@ -202,7 +207,10 @@ IObservable<IReadOnlyList<IRepositoryModel>> GetAllRepositoriesForAllOrganizatio
202207
{
203208
return GetUserOrganizations()
204209
.SelectMany(org => org.ToObservable())
205-
.SelectMany(org => GetOrganizationRepositories(org.Login).Take(1));
210+
.SelectMany(org => GetOrganizationRepositories(org.Login)
211+
.PublishLast()
212+
.RefCount()
213+
);
206214
}
207215

208216
IObservable<IReadOnlyList<IRepositoryModel>> GetOrganizationRepositories(string organization)
@@ -211,7 +219,7 @@ IObservable<IReadOnlyList<IRepositoryModel>> GetOrganizationRepositories(string
211219
hostCache.GetAndRefreshObject(string.Format(CultureInfo.InvariantCulture, "{0}|{1}|repos", user.Login, organization),
212220
() => apiClient.GetRepositoriesForOrganization(organization).Select(
213221
RepositoryCacheItem.Create).ToList(),
214-
TimeSpan.FromMinutes(5),
222+
TimeSpan.FromMinutes(2),
215223
TimeSpan.FromDays(7)))
216224
.ToReadOnlyList(Create))
217225
.Catch<IReadOnlyList<IRepositoryModel>, KeyNotFoundException>(

0 commit comments

Comments
 (0)