Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/views/native/partials/log-page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class="w-full flex-1 bg-theme-surface"

@if (! $page['loaded'] && $page['error'] === null)
@foreach (range(1, 3) as $skeleton)
@include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits'])
@include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits', 'pulse' => $page['showing']])
@endforeach
@endif

Expand All @@ -42,7 +42,7 @@ class="w-full flex-1 bg-theme-surface"

@if ($page['lastCommit'])
@if ($page['nextCursor'] !== null)
@include('native.partials.rail-loading')
@include('native.partials.rail-loading', ['pulse' => $page['showing']])
@else
@include('native.partials.rail-end', ['lane' => $page['lastCommit']->lane(), 'message' => "That's the root commit. There's nothing before it."])
@endif
Expand Down
4 changes: 2 additions & 2 deletions resources/views/native/partials/profile-page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class="w-full flex-1 bg-theme-surface"
>
@if (! $page['loaded'] && $page['error'] === null)
@foreach (range(1, 3) as $skeleton)
@include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits'])
@include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits', 'pulse' => $page['showing']])
@endforeach
@endif

Expand Down Expand Up @@ -46,7 +46,7 @@ class="w-full flex-1 bg-theme-surface"

@if (! $page['isEmpty'] || $page['pinnedCommit'])
@if ($page['nextCursor'] !== null)
@include('native.partials.rail-loading')
@include('native.partials.rail-loading', ['pulse' => $page['showing']])
@elseif ($page['tab'] === 'replies')
@include('native.partials.rail-end', ['lane' => $user->lane(), 'message' => $isMe ? 'That was your first reply.' : "That's {$user->handle()}'s first reply."])
@else
Expand Down
7 changes: 6 additions & 1 deletion resources/views/native/partials/rail-loading.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{{--
While the next page loads, a skeleton row stands in on a Rail Gray rail ending in its dot, as the web's CommitSkeleton.
A list with nothing kept to show yet shows a few of them, the first time only.
It pulses only on the page you're on ($pulse). The pager lays out the pages beside it too, and a looping animation
there never stops: SwiftUI keeps redrawing it off screen, and the main thread keeps waiting on it while you scroll.
A loop only starts when its view appears, so the pulsing column gets a key of its own and comes in afresh, already
pulsing, when you swipe to its page.
--}}
@php($ref ??= 'loading-more')
@php($pulse ??= true)
@php($label ??= 'Loading more commits')
<native:row ref="{{ $ref }}" class="w-full bg-theme-surface" a11y-label="{{ $label }}">
<native:column :width="64" />
<native:column class="flex-1">
<native:column class="w-full min-h-[64] py-3 pr-4 gap-[10] opacity-[0.5]" animate-duration="900" :animate-loop="true">
<native:column native:key="{{ $pulse ? 'pulsing' : 'still' }}" class="w-full min-h-[64] py-3 pr-4 gap-[10] opacity-[0.5]" :animate-duration="$pulse ? 900 : 0" :animate-loop="$pulse">
<native:column class="w-2/5 h-[12] mt-1 rounded bg-theme-wash" />
<native:column class="w-4/5 h-[12] rounded bg-theme-wash" />
<native:column class="w-3/5 h-[12] rounded bg-theme-wash" />
Expand Down
18 changes: 18 additions & 0 deletions tests/Feature/Screens/LogCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ function shownCommitIds(TestableComponent $screen): array
$again->assertSee('Fresh commit');
});

it('pulses skeleton rows only on the log you are on', function () {
holdRefreshes();
fakeFreshLog([commitJson(['id' => 'c1', 'body' => 'Fresh commit'])]);

$pulses = fn (array $list): bool => findNode($list, fn (array $node): bool => ($node['props']['animate-loop'] ?? false) === true) !== null;

$screen = Native::visit('/log');

expect($pulses(showingLog($screen)))->toBeTrue()
->and(showsLoading(nodeByRef($screen, 'log-latest')))->toBeTrue()
->and($pulses(nodeByRef($screen, 'log-latest')))->toBeFalse();

$screen->call('showPage', 1);

expect($pulses(showingLog($screen)))->toBeTrue()
->and($pulses(nodeByRef($screen, 'log-following')))->toBeFalse();
});

it('holds new commits in a pill with the right count, and puts them on top without a request', function () {
holdRefreshes();
keep('log/following', pageJson([commitJson(['id' => 'c1', 'body' => 'Seen before'])]));
Expand Down
Loading