As the user types we reuse the directory listing, we only do an actual loading when the directory changes (or the component receives an update to force reload):
|
with {:ok, files} <- FileSystem.File.list(dir) do |
Also, ideally we would colocate setting loading: true with the actual listing, rather than setting it "upfront":
|
{:noreply, assign(socket, loading: socket.assigns.file.path != path)} |
In order for the UI to update, likely the best way would be to do the listing async in a task.
As the user types we reuse the directory listing, we only do an actual loading when the directory changes (or the component receives an update to force reload):
livebook/lib/livebook_web/live/file_select_component.ex
Line 706 in 3bc7cca
Also, ideally we would colocate setting
loading: truewith the actual listing, rather than setting it "upfront":livebook/lib/livebook_web/live/file_select_component.ex
Line 549 in 3bc7cca
In order for the UI to update, likely the best way would be to do the listing async in a task.