Skip to content

Commit

Permalink
chore: Update WithScroll trait to refresh items when clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Jul 20, 2024
1 parent 61c4eb7 commit 7dcf0de
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Layout/Concerns/WithScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,35 @@ public function mountWithScroll(): void
}
}

#[Computed]
#[Computed(persist: true)]
public function items(): array
{
return $this->models;
}

public function fetch(): void
{
unset($this->items);

$this->nextPage();

$this->mergePageItems(
$this->getPageItems()->all()
);
}

public function refresh(): void
{
unset($this->items);

$this->dispatch('$refresh');
}

public function clear(): void
{
$this->reset('models');

unset($this->items);
$this->refresh();

$this->resetPage();
}
Expand Down

0 comments on commit 7dcf0de

Please sign in to comment.