fix(member-live): re-read view-settings cookie on live navigation
This commit is contained in:
parent
fe6d1c52f9
commit
a64835fe6d
1 changed files with 11 additions and 5 deletions
|
|
@ -504,21 +504,27 @@ function getCookie(name) {
|
||||||
return match ? decodeURIComponent(match[1]) : null
|
return match ? decodeURIComponent(match[1]) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `params` is a function so it is re-evaluated on every channel join, not just
|
||||||
|
// at socket construction. This matters for the member view settings: a live
|
||||||
|
// navigation back to the overview re-mounts the LiveView on the same socket, so
|
||||||
|
// the cookie must be re-read at that point — a static params object would echo
|
||||||
|
// the stale value captured at initial page load (view settings would appear to
|
||||||
|
// reset until a hard reload).
|
||||||
let liveSocket = new LiveSocket("/live", Socket, {
|
let liveSocket = new LiveSocket("/live", Socket, {
|
||||||
longPollFallbackMs: 2500,
|
longPollFallbackMs: 2500,
|
||||||
params: {
|
params: () => ({
|
||||||
_csrf_token: csrfToken,
|
_csrf_token: csrfToken,
|
||||||
timezone: getBrowserTimezone(),
|
timezone: getBrowserTimezone(),
|
||||||
view_settings: getCookie("member_view_settings")
|
view_settings: getCookie("member_view_settings")
|
||||||
},
|
}),
|
||||||
hooks: Hooks
|
hooks: Hooks
|
||||||
})
|
})
|
||||||
|
|
||||||
// Persist the member-overview view settings per browser/device (§1.5/§1.20). The
|
// Persist the member-overview view settings per browser/device (§1.5/§1.20). The
|
||||||
// LiveView pushes "store-view-settings" (density + compact field toggles) on
|
// LiveView pushes "store-view-settings" (density + compact field toggles) on
|
||||||
// change; we write a long-lived cookie that the LiveView reads back on the next
|
// change; we write a long-lived cookie that the LiveView reads back on the dead
|
||||||
// full page load (via the request cookie on the dead render and via connect
|
// render (via the request cookie) and on every connected mount/join (via the
|
||||||
// params on the connected mount).
|
// connect params, re-evaluated per join — see the LiveSocket params function).
|
||||||
// Return the members list to the top after a sort or filter change. The server
|
// Return the members list to the top after a sort or filter change. The server
|
||||||
// resets the keyset stream to page 1 on those changes and pushes this event; a
|
// resets the keyset stream to page 1 on those changes and pushes this event; a
|
||||||
// user scrolled down would otherwise be stranded past the shorter content with
|
// user scrolled down would otherwise be stranded past the shorter content with
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue