diff --git a/Project.toml b/Project.toml index 4b791c34..2b1e73bb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Stipple" uuid = "4acbeb90-81a0-11ea-1966-bdaff8155998" authors = ["Adrian "] -version = "0.28.12" +version = "0.28.13" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/ModelStorage.jl b/src/ModelStorage.jl index 9dc139e4..ee709154 100644 --- a/src/ModelStorage.jl +++ b/src/ModelStorage.jl @@ -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...] @@ -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 diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index 4b1c68bd..9da050e5 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -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 -> """\n""", meta) """