Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port fixes from 0.28 to 0.30 #287

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
@out fields restore from session
  • Loading branch information
Adrian Salceanu committed Aug 6, 2024
commit d82113d39c4afbeaefc6c2c40ea2963d1df482e6
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Stipple"
uuid = "4acbeb90-81a0-11ea-1966-bdaff8155998"
authors = ["Adrian <e@essenciary.com>"]
version = "0.28.12"
version = "0.28.13"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
14 changes: 9 additions & 5 deletions src/ModelStorage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ function init_from_storage( t::Type{M};

for f in fieldnames(CM)
field = getfield(model, f)

if field isa Reactive
# restore fields only if a stored model exists, if the field is not part of the internal fields and is not write protected
(
isnothing(stored_model) || f ∈ [Stipple.CHANNELFIELDNAME, Stipple.AUTOFIELDS...] || Stipple.isreadonly(f, model) || Stipple.isprivate(f, model) ||
! hasproperty(stored_model, f) || ! hasproperty(model, f) || (field[!] = getfield(stored_model, f)[])
)
if isnothing(stored_model) || f ∈ [Stipple.CHANNELFIELDNAME, Stipple.AUTOFIELDS...] ||
Stipple.isprivate(f, model) || ! hasproperty(stored_model, f) || ! hasproperty(model, f)
else
# restore field value from stored model
(field[!] = getfield(stored_model, f)[])
end

# register reactive handlers to automatically save model on session when model changes
if f ∉ [Stipple.AUTOFIELDS...]
Expand All @@ -42,7 +45,8 @@ function init_from_storage( t::Type{M};
end
end
else
isnothing(stored_model) || Stipple.isprivate(f, model) || Stipple.isreadonly(f, model) || ! hasproperty(stored_model, f) || ! hasproperty(model, f) || setfield!(model, f, getfield(stored_model, f))
isnothing(stored_model) || Stipple.isprivate(f, model) || Stipple.isreadonly(f, model) ||
! hasproperty(stored_model, f) || ! hasproperty(model, f) || setfield!(model, f, getfield(stored_model, f))
end
end

Expand Down
3 changes: 2 additions & 1 deletion src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}()
const HANDLERS_FUNCTIONS = LittleDict{Type{<:ReactiveModel},Function}()

function DEFAULT_LAYOUT(; title::String = "Genie App",
meta::D = Dict(), head_content::Union{AbstractString, Vector} = "") where {D <:AbstractDict}
meta::D = Dict(),
head_content::Union{AbstractString, Vector} = "") where {D <:AbstractDict}
tags = Genie.Renderers.Html.for_each(x -> """<meta name="$(string(x.first))" content="$(string(x.second))">\n""", meta)
"""
<!DOCTYPE html>
Expand Down
Loading