fixed performance and variable mangling error

This commit is contained in:
hariroshan 2023-01-13 12:59:12 +05:30
parent 666d222cba
commit d9e2c50299
3 changed files with 10 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import Native.Event as Event
import Native.Frame as Frame
import Native.Layout as Layout exposing (rootLayout)
import Native.Page as Page
import Process
import Task
type alias Flick =
@ -302,7 +304,7 @@ detailsPage model =
Just flick ->
Page.pageWithActionBar [ Event.on "navigatedTo" (D.field "isBackNavigation" D.bool |> D.map Back) ]
(Native.actionBar [ NA.title flick.title ]
[ Native.navigationButton [NA.text "Back"] []
[ Native.navigationButton [ NA.text "Back" ] []
]
)
(Layout.scrollView

View File

@ -319,10 +319,8 @@ module ListView = {
current.data
->Js.Nullable.toOption
->Belt.Option.forEach(data => {
if !Belt.Array.eq(data.items, newItems, (x, y) => x == y) {
data->Types.setItems(newItems)
data->Types.refresh
}
data->Types.setItems(newItems)
data->Types.refresh
})
}
)

View File

@ -87,7 +87,11 @@ let addView: (. Types.htmlElement, Types.htmlElement) => unit = %raw(`
getExpression(parentElement.getAttribute("item-template-selector"))
parentElement.data.itemTemplateSelector = ($value, $index, _) => {
return eval(expression)
// Mangling the variable can affect the variables used in the expression
const replacedExpression = expression
.replaceAll("$value", Object.keys({$value})[0])
.replaceAll("$index", Object.keys({$index})[0])
return eval(replacedExpression)
}
parentElement.data.itemTemplates = keyedTemplates
return