Work around elements not refreshing on url operations

This commit is contained in:
Joey Yakimowich-Payne 2020-02-17 19:46:56 -07:00 committed by Andreas Rumpf
commit 38a21f34e6
3 changed files with 9 additions and 3 deletions

View file

@ -2,6 +2,7 @@ import options, tables, sugar, httpcore
from dom import window, Location, document, decodeURI
include karax/prelude
import karax/[kdom]
import jester/[patterns]
import threadlist, postlist, header, profile, newthread, error, about
@ -56,6 +57,10 @@ proc onPopState(event: dom.Event) =
state = newState() # Reload the state to remove stale data.
state.url = copyLocation(window.location)
# For some reason this is needed so that the back/forward buttons reload
# the post list when different categories are selected
window.location.reload()
redraw()
type Params = Table[string, string]

View file

@ -39,15 +39,15 @@ when defined(js):
loading: false,
status: Http200,
loginModal: newLoginModal(
() => (state.lastUpdate = fromUnix(0); getStatus()),
() => (state.lastUpdate = fromUnix(0); getStatus(); window.location.reload()),
() => state.signupModal.show()
),
signupModal: newSignupModal(
() => (state.lastUpdate = fromUnix(0); getStatus()),
() => (state.lastUpdate = fromUnix(0); getStatus(); window.location.reload()),
() => state.loginModal.show()
),
userMenu: newUserMenu(
() => (state.lastUpdate = fromUnix(0); getStatus(logout=true))
() => (state.lastUpdate = fromUnix(0); getStatus(logout=true); window.location.reload())
)
)

View file

@ -97,6 +97,7 @@ when defined(js):
let url = n.getAttr("href")
navigateTo(url)
window.location.href = url
proc newFormData*(form: dom.Element): FormData
{.importcpp: "new FormData(@)", constructor.}