Fix bug in sync button

- it was fetching from remote but not re-fetching base branch data
This commit is contained in:
Mattias Granlund 2024-07-15 15:15:10 +01:00
parent 6692acd261
commit ced7394d7b

View File

@ -6,12 +6,13 @@
import { getContext } from '$lib/utils/context'; import { getContext } from '$lib/utils/context';
import { VirtualBranchService } from '$lib/vbranches/virtualBranch'; import { VirtualBranchService } from '$lib/vbranches/virtualBranch';
const gitHostListing = getGitHostListingService();
const baseBranchService = getContext(BaseBranchService); const baseBranchService = getContext(BaseBranchService);
const vbranchService = getContext(VirtualBranchService); const vbranchService = getContext(VirtualBranchService);
const baseBranch = baseBranchService.base; const baseBranch = baseBranchService.base;
$: baseServiceBusy$ = baseBranchService.loading; const listingService = getGitHostListingService();
let loading = $state(false);
</script> </script>
<Button <Button
@ -22,16 +23,24 @@
outline outline
icon="update-small" icon="update-small"
help="Last fetch from upstream" help="Last fetch from upstream"
loading={$baseServiceBusy$} {loading}
on:mousedown={async (e) => { on:mousedown={async (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
await baseBranchService.fetchFromRemotes('modal'); loading = true;
vbranchService.refresh(); try {
$gitHostListing?.refresh(); await baseBranchService.fetchFromRemotes('modal');
await Promise.all([
$listingService?.refresh(),
vbranchService.refresh(),
baseBranchService.refresh()
]);
} finally {
loading = false;
}
}} }}
> >
{#if $baseServiceBusy$} {#if loading}
<div class="sync-btn__busy-label">busy…</div> <div class="sync-btn__busy-label">busy…</div>
{:else if $baseBranch?.lastFetched} {:else if $baseBranch?.lastFetched}
<TimeAgo date={$baseBranch?.lastFetched} /> <TimeAgo date={$baseBranch?.lastFetched} />