Skip to content

Commit

Permalink
Revert "Decide if choose is disabled on handle info"
Browse files Browse the repository at this point in the history
This reverts commit 43a2cbc.
  • Loading branch information
Benjamin-Philip committed Dec 24, 2021
1 parent 43a2cbc commit e272920
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/livebook_web/live/session_live/persistence_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do
attrs: attrs,
new_attrs: attrs,
draft_file: nil,
choose_disabled: nil,
saved_file: nil
)}
end
Expand Down Expand Up @@ -117,7 +116,7 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do
tabindex="-1">
Cancel
</button>
<%= unless @choose_disabled do %>
<%= unless String.at(@draft_file.path, -1) == "/" do %>
<button class="button-base button-blue"
phx-click="confirm_file"
tabindex="-1">
Expand Down Expand Up @@ -162,8 +161,7 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do
@impl true
def handle_event("open_file_select", %{}, socket) do
file = socket.assigns.new_attrs.file || Livebook.Config.default_dir()
choose_disabled = FileSystem.File.dir?(file)
{:noreply, assign(socket, draft_file: file, choose_disabled: choose_disabled)}
{:noreply, assign(socket, draft_file: file)}
end

def handle_event("close_file_select", %{}, socket) do
Expand Down Expand Up @@ -226,8 +224,7 @@ defmodule LivebookWeb.SessionLive.PersistenceLive do

@impl true
def handle_info({:set_file, file, _file_info}, socket) do
choose_disabled = FileSystem.File.dir?(file)
{:noreply, assign(socket, draft_file: file, choose_disabled: choose_disabled)}
{:noreply, assign(socket, draft_file: file)}
end

def handle_info(:confirm_file, socket) do
Expand Down

0 comments on commit e272920

Please sign in to comment.