Skip to content

Commit 3ce24d9

Browse files
committed
update feature
- `Repository.FetchAllRemotesAsync()` now return `bool` (success/failure) - `Launcher.FetchAllRepositoriesAsync()` now sends a summary notification (`Fetched X/Y repositories`) to the active page when done.
1 parent 6239a26 commit 3ce24d9

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎src/ViewModels/Launcher.cs‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,21 @@ public async Task FetchAllRepositoriesAsync()
130130
var pages = new List<LauncherPage>();
131131
pages.AddRange(Pages);
132132

133-
var count = 0;
133+
var total = 0;
134+
var succeeded = 0;
135+
134136
foreach (var page in pages)
135137
{
136-
if (page.Data is Repository repo)
137-
{
138-
if (await repo.FetchAllRemotesAsync())
139-
count++;
140-
}
138+
if (page.Data is not Repository repo)
139+
continue;
140+
141+
total++;
142+
if (await repo.FetchAllRemotesAsync())
143+
succeeded++;
141144
}
142145

143-
if (count > 0)
144-
Models.Notification.Send(null, $"Fetched {count} repositories");
146+
if (total > 0)
147+
Models.Notification.Send(null, $"Fetched {succeeded}/{total} repositories", succeeded < total);
145148
}
146149

147150
public void SwitchWorkspace(Workspace to)

‎src/ViewModels/Repository.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ public async Task<bool> FetchAllRemotesAsync()
703703
return false;
704704

705705
CommandLog log = null;
706+
var succeeded = true;
706707

707708
try
708709
{
@@ -717,18 +718,23 @@ public async Task<bool> FetchAllRemotesAsync()
717718
log = CreateLog("Fetch");
718719

719720
foreach (var remote in _remotes)
720-
await new Commands.Fetch(FullPath, remote).Use(log).ExecAsync();
721+
{
722+
var succ = await new Commands.Fetch(FullPath, remote).Use(log).ExecAsync();
723+
if (!succ)
724+
succeeded = false;
725+
}
721726

722727
_lastFetchTime = DateTime.Now;
723728
}
724729
catch
725730
{
726731
// Ignore all exceptions.
732+
succeeded = false;
727733
}
728734

729735
IsAutoFetching = false;
730736
log?.Complete();
731-
return true;
737+
return succeeded;
732738
}
733739

734740
public async Task PullAsync(bool autoStart)

0 commit comments

Comments
 (0)