fix: components not using parent page patchShan; fix: chat example nil pointer error when sync outside action
This commit is contained in:
@@ -111,11 +111,11 @@ func main() {
|
||||
newRoom.Join(&UserAndSync[Chat, UserInfo]{user: ¤tUser, sync: c})
|
||||
currentRoom = newRoom
|
||||
roomNameString = newRoom.Name
|
||||
c.Sync()
|
||||
}
|
||||
|
||||
switchRoomAction := c.Action(func() {
|
||||
switchRoom()
|
||||
c.Sync()
|
||||
})
|
||||
|
||||
switchRoom()
|
||||
|
||||
@@ -13,6 +13,11 @@ import (
|
||||
func main() {
|
||||
v := via.New()
|
||||
|
||||
v.Config(via.Options{
|
||||
LogLvl: via.LogLevelDebug,
|
||||
DevMode: true,
|
||||
})
|
||||
|
||||
v.AppendToHead(
|
||||
h.Link(h.Rel("stylesheet"), h.Href("https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css")),
|
||||
h.Script(h.Src("https://unpkg.com/echarts@6.0.0/dist/echarts.min.js")),
|
||||
@@ -35,7 +40,7 @@ func chartCompFn(c *via.Context) {
|
||||
data := make([]float64, 1000)
|
||||
labels := make([]string, 1000)
|
||||
|
||||
isLive := false
|
||||
isLive := true
|
||||
refreshRate := c.Signal(1)
|
||||
tkr := time.NewTicker(1000 * time.Millisecond)
|
||||
|
||||
@@ -71,7 +76,7 @@ func chartCompFn(c *via.Context) {
|
||||
return h.Div(
|
||||
h.Div(h.ID("chart"), h.Style("width:100%;height:400px;"),
|
||||
h.Script(h.Raw(`
|
||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
var myChart = echarts.init(document.getElementById('chart'), prefersDark.matches ? 'dark' : 'light');
|
||||
var option = {
|
||||
backgroundColor: prefersDark.matches ? 'transparent' : '#ffffff',
|
||||
|
||||
Reference in New Issue
Block a user