Set default folder when saving a forked notebook (#1767)

This commit is contained in:
Jannik Becher 2023-03-10 17:02:30 +01:00 committed by GitHub
parent 0f38c59662
commit ae797040cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,12 @@ defmodule LivebookWeb.SessionLive.PersistenceComponent do
|> assign_new(:attrs, fn -> attrs end)
|> assign_new(:new_attrs, fn -> attrs end)
|> assign_new(:draft_file, fn ->
file || Livebook.Config.local_file_system_home()
file ||
case assigns.session.origin do
# If it's a forked notebook, default to the same folder
{:file, file} -> FileSystem.File.containing_dir(file)
_ -> Livebook.Config.local_file_system_home()
end
end)
|> assign_new(:saved_file, fn -> file end)